fune/toolkit/components/xulstore/XULStore.h
Doug Thayer 2707a3d1f2 Bug 1638166 - Flush writes to xulstore before fastshutdown r=lina
Some background information on why we want to flush writes: we're
currently working on a "fast shutdown" project, which will simply
call _exit(0) once a certain phase (controlled via pref) in
shutdown is hit. This will allow us to skip a lot of ceremony,
like freeing memory, removing listeners on observer notifications,
etc. However, we don't want to be cavalier about data loss, so
for the time being we want to ensure that all file writes which we
previously had some assurance would complete will continue to
complete. This means explicitly calling them immediately before a
fast shutdown. We also want to call these before we turn on late
write checking, which we control via another pref. This late write
checking surfaces writes via telemetry which we didn't notice with
local testing. However we want to ensure that we flush our writes
before this point so we don't have lots of noise in the telemetry.

Lina I'm requesting review from you since it looks like you did the
reviews on most of the initial code. However, please let me know if
there's someone more suitable.

Depends on D75389

Differential Revision: https://phabricator.services.mozilla.com/D75572
2020-05-18 22:47:14 +00:00

56 lines
2 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/*
* This file declares the XULStore API for C++ via the mozilla::XULStore
* namespace and the mozilla::XULStoreIterator class. It also declares
* the mozilla::XULStore::GetService() function that the component manager
* uses to instantiate and retrieve the nsIXULStore singleton.
*/
#ifndef mozilla_XULStore_h
#define mozilla_XULStore_h
#include "nsIXULStore.h"
namespace mozilla {
class XULStoreIterator final {
public:
bool HasMore() const;
nsresult GetNext(nsAString* item);
private:
XULStoreIterator() = delete;
XULStoreIterator(const XULStoreIterator&) = delete;
XULStoreIterator& operator=(const XULStoreIterator&) = delete;
~XULStoreIterator() = delete;
};
template <>
class DefaultDelete<XULStoreIterator> {
public:
void operator()(XULStoreIterator* ptr) const;
};
namespace XULStore {
// Instantiates and retrieves the nsIXULStore singleton that JS uses to access
// the store. C++ code should use the mozilla::XULStore::* functions instead.
already_AddRefed<nsIXULStore> GetService();
nsresult SetValue(const nsAString& doc, const nsAString& id,
const nsAString& attr, const nsAString& value);
nsresult HasValue(const nsAString& doc, const nsAString& id,
const nsAString& attr, bool& has_value);
nsresult GetValue(const nsAString& doc, const nsAString& id,
const nsAString& attr, nsAString& value);
nsresult RemoveValue(const nsAString& doc, const nsAString& id,
const nsAString& attr);
nsresult GetIDs(const nsAString& doc, UniquePtr<XULStoreIterator>& iter);
nsresult GetAttrs(const nsAString& doc, const nsAString& id,
UniquePtr<XULStoreIterator>& iter);
nsresult Shutdown();
}; // namespace XULStore
}; // namespace mozilla
#endif // mozilla_XULStore_h