Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: services/preferences/public/cpp/persistent_pref_store_client.h

Issue 2743563003: Pref service: add persistent pref store frontend and backend. (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/preferences/public/cpp/persistent_pref_store_client.h
diff --git a/services/preferences/public/cpp/persistent_pref_store_client.h b/services/preferences/public/cpp/persistent_pref_store_client.h
new file mode 100644
index 0000000000000000000000000000000000000000..7a1a29ab136f82d55d8a339f41d660049b462bd3
--- /dev/null
+++ b/services/preferences/public/cpp/persistent_pref_store_client.h
@@ -0,0 +1,74 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_
+#define SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_
+
+#include <memory>
+#include <string>
+
+#include "base/macros.h"
+#include "components/prefs/persistent_pref_store.h"
+#include "services/preferences/public/cpp/pref_store_client_mixin.h"
+#include "services/preferences/public/interfaces/preferences.mojom.h"
+
+namespace base {
+class Value;
+class DictionaryValue;
+}
+
+namespace prefs {
+
+// An implementation of PersistentPrefStore backed by a
+// mojom::PersistentPrefStore and a mojom::PrefStoreObserver.
+class PersistentPrefStoreClient
+ : public PrefStoreClientMixin<PersistentPrefStore> {
+ public:
+ explicit PersistentPrefStoreClient(
+ mojom::PersistentPrefStoreConnectorPtr connector);
+
+ // WriteablePrefStore:
+ void SetValue(const std::string& key,
+ std::unique_ptr<base::Value> value,
+ uint32_t flags) override;
+ void RemoveValue(const std::string& key, uint32_t flags) override;
+ bool GetMutableValue(const std::string& key, base::Value** result) override;
+ void ReportValueChanged(const std::string& key, uint32_t flags) override;
+ void SetValueSilently(const std::string& key,
+ std::unique_ptr<base::Value> value,
+ uint32_t flags) override;
+
+ // PersistentPrefStore:
+ bool ReadOnly() const override;
+ PrefReadError GetReadError() const override;
+ PrefReadError ReadPrefs() override;
+ void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override;
+ void CommitPendingWrite() override;
+ void SchedulePendingLossyWrites() override;
+ void ClearMutableValues() override;
+
+ protected:
+ // base::RefCounted<PrefStore>:
+ ~PersistentPrefStoreClient() override;
+
+ private:
+ void OnCreateComplete(PrefReadError read_error,
+ bool read_only,
+ std::unique_ptr<base::DictionaryValue> cached_prefs,
+ mojom::PersistentPrefStorePtr pref_store,
+ mojom::PrefStoreObserverRequest observer_request);
+
+ mojom::PersistentPrefStoreConnectorPtr connector_;
+ bool read_only_ = false;
+ PrefReadError read_error_ = PersistentPrefStore::PREF_READ_ERROR_NONE;
+ mojom::PersistentPrefStorePtr pref_store_;
+
+ std::unique_ptr<ReadErrorDelegate> error_delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreClient);
+};
+
+} // namespace prefs
+
+#endif // SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_
« no previous file with comments | « services/preferences/public/cpp/BUILD.gn ('k') | services/preferences/public/cpp/persistent_pref_store_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698