OLD | NEW |
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_PREF_STORE_CLIENT_MIXIN_H_ | 5 #ifndef SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_CLIENT_MIXIN_H_ |
6 #define SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_CLIENT_MIXIN_H_ | 6 #define SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_CLIENT_MIXIN_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 bool IsInitializationComplete() const override; | 38 bool IsInitializationComplete() const override; |
39 bool GetValue(const std::string& key, | 39 bool GetValue(const std::string& key, |
40 const base::Value** result) const override; | 40 const base::Value** result) const override; |
41 std::unique_ptr<base::DictionaryValue> GetValues() const override; | 41 std::unique_ptr<base::DictionaryValue> GetValues() const override; |
42 | 42 |
43 protected: | 43 protected: |
44 ~PrefStoreClientMixin() override; | 44 ~PrefStoreClientMixin() override; |
45 | 45 |
46 // Initializes |this|. This must be called before any of the other public or | 46 // Initializes |this|. This must be called before any of the other public or |
47 // protected member functions. | 47 // protected member functions. |
48 void Init(std::unique_ptr<base::DictionaryValue> initial_prefs, | 48 void Init(const base::DictionaryValue* initial_prefs, |
49 bool initialized, | 49 bool initialized, |
50 mojom::PrefStoreObserverRequest observer_request); | 50 mojom::PrefStoreObserverRequest observer_request); |
51 | 51 |
52 base::DictionaryValue& GetMutableValues(); | 52 base::DictionaryValue& GetMutableValues(); |
53 void ReportPrefValueChanged(const std::string& key); | 53 void ReportPrefValueChanged(const std::string& key); |
54 | 54 |
55 private: | 55 private: |
56 // prefs::mojom::PreferenceObserver: | 56 // prefs::mojom::PreferenceObserver: |
57 void OnPrefsChanged(std::vector<mojom::PrefUpdatePtr> updates) override; | 57 void OnPrefsChanged(std::vector<mojom::PrefUpdatePtr> updates) override; |
58 void OnInitializationCompleted(bool succeeded) override; | 58 void OnInitializationCompleted(bool succeeded) override; |
59 | 59 |
60 void OnPrefChanged(const std::string& key, | 60 void OnPrefChanged(const std::string& key, base::Optional<base::Value> value); |
61 std::unique_ptr<base::Value> value); | |
62 | 61 |
63 // Cached preferences. | 62 // Cached preferences. |
64 // If null, indicates that initialization failed. | 63 // If null, indicates that initialization failed. |
65 std::unique_ptr<base::DictionaryValue> cached_prefs_; | 64 std::unique_ptr<base::DictionaryValue> cached_prefs_; |
66 | 65 |
67 base::ObserverList<PrefStore::Observer, true> observers_; | 66 base::ObserverList<PrefStore::Observer, true> observers_; |
68 | 67 |
69 // Has the PrefStore we're observing been initialized? | 68 // Has the PrefStore we're observing been initialized? |
70 bool initialized_ = false; | 69 bool initialized_ = false; |
71 | 70 |
72 mojo::Binding<mojom::PrefStoreObserver> observer_binding_; | 71 mojo::Binding<mojom::PrefStoreObserver> observer_binding_; |
73 | 72 |
74 DISALLOW_COPY_AND_ASSIGN(PrefStoreClientMixin); | 73 DISALLOW_COPY_AND_ASSIGN(PrefStoreClientMixin); |
75 }; | 74 }; |
76 | 75 |
77 extern template class PrefStoreClientMixin<::PrefStore>; | 76 extern template class PrefStoreClientMixin<::PrefStore>; |
78 extern template class PrefStoreClientMixin<::PersistentPrefStore>; | 77 extern template class PrefStoreClientMixin<::PersistentPrefStore>; |
79 | 78 |
80 } // namespace prefs | 79 } // namespace prefs |
81 | 80 |
82 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_CLIENT_MIXIN_H_ | 81 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_CLIENT_MIXIN_H_ |
OLD | NEW |