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

Side by Side Diff: services/preferences/public/cpp/persistent_pref_store_client.h

Issue 2777483002: Pref service: Add initial support for pref registration. (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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_ 5 #ifndef SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_
6 #define SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_ 6 #define SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "components/prefs/persistent_pref_store.h" 12 #include "components/prefs/persistent_pref_store.h"
13 #include "services/preferences/public/cpp/pref_store_client_mixin.h" 13 #include "services/preferences/public/cpp/pref_store_client_mixin.h"
14 #include "services/preferences/public/interfaces/preferences.mojom.h" 14 #include "services/preferences/public/interfaces/preferences.mojom.h"
15 15
16 namespace base { 16 namespace base {
17 class Value; 17 class Value;
18 } 18 }
19 19
20 class PrefRegistry;
21
20 namespace prefs { 22 namespace prefs {
21 23
22 // An implementation of PersistentPrefStore backed by a 24 // An implementation of PersistentPrefStore backed by a
23 // mojom::PersistentPrefStore and a mojom::PrefStoreObserver. 25 // mojom::PersistentPrefStore and a mojom::PrefStoreObserver.
24 class PersistentPrefStoreClient 26 class PersistentPrefStoreClient
25 : public PrefStoreClientMixin<PersistentPrefStore> { 27 : public PrefStoreClientMixin<PersistentPrefStore> {
26 public: 28 public:
27 explicit PersistentPrefStoreClient(mojom::PrefStoreConnectorPtr connector); 29 PersistentPrefStoreClient(mojom::PrefStoreConnectorPtr connector,
30 scoped_refptr<PrefRegistry> pref_registry);
28 31
29 explicit PersistentPrefStoreClient( 32 explicit PersistentPrefStoreClient(
30 mojom::PersistentPrefStoreConnectionPtr connection); 33 mojom::PersistentPrefStoreConnectionPtr connection);
31 34
32 // WriteablePrefStore: 35 // WriteablePrefStore:
33 void SetValue(const std::string& key, 36 void SetValue(const std::string& key,
34 std::unique_ptr<base::Value> value, 37 std::unique_ptr<base::Value> value,
35 uint32_t flags) override; 38 uint32_t flags) override;
36 void RemoveValue(const std::string& key, uint32_t flags) override; 39 void RemoveValue(const std::string& key, uint32_t flags) override;
37 bool GetMutableValue(const std::string& key, base::Value** result) override; 40 bool GetMutableValue(const std::string& key, base::Value** result) override;
(...skipping 15 matching lines...) Expand all
53 // base::RefCounted<PrefStore>: 56 // base::RefCounted<PrefStore>:
54 ~PersistentPrefStoreClient() override; 57 ~PersistentPrefStoreClient() override;
55 58
56 private: 59 private:
57 void OnConnect(mojom::PersistentPrefStoreConnectionPtr connection, 60 void OnConnect(mojom::PersistentPrefStoreConnectionPtr connection,
58 std::unordered_map<PrefValueStore::PrefStoreType, 61 std::unordered_map<PrefValueStore::PrefStoreType,
59 prefs::mojom::PrefStoreConnectionPtr> 62 prefs::mojom::PrefStoreConnectionPtr>
60 other_pref_stores); 63 other_pref_stores);
61 64
62 mojom::PrefStoreConnectorPtr connector_; 65 mojom::PrefStoreConnectorPtr connector_;
66 scoped_refptr<PrefRegistry> pref_registry_;
63 bool read_only_ = false; 67 bool read_only_ = false;
64 PrefReadError read_error_ = PersistentPrefStore::PREF_READ_ERROR_NONE; 68 PrefReadError read_error_ = PersistentPrefStore::PREF_READ_ERROR_NONE;
65 mojom::PersistentPrefStorePtr pref_store_; 69 mojom::PersistentPrefStorePtr pref_store_;
66 70
67 std::unique_ptr<ReadErrorDelegate> error_delegate_; 71 std::unique_ptr<ReadErrorDelegate> error_delegate_;
68 72
69 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreClient); 73 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreClient);
70 }; 74 };
71 75
72 } // namespace prefs 76 } // namespace prefs
73 77
74 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_ 78 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_
OLDNEW
« 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