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

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

Issue 2635093002: Switch Preferences to use Factory (Closed)
Patch Set: Missed test Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_PREFS_OBSERVER_STORE_H_ 5 #ifndef SERVICES_PREFERENCES_PUBLIC_CPP_PREFS_OBSERVER_STORE_H_
6 #define SERVICES_PREFERENCES_PUBLIC_CPP_PREFS_OBSERVER_STORE_H_ 6 #define SERVICES_PREFERENCES_PUBLIC_CPP_PREFS_OBSERVER_STORE_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 12 matching lines...) Expand all
23 // The cache is empty until the first notification of OnPreferencesChanged is 23 // The cache is empty until the first notification of OnPreferencesChanged is
24 // received from the prefs::mojom::PreferenceManager. Upon recieving an initial 24 // received from the prefs::mojom::PreferenceManager. Upon recieving an initial
25 // OnPreferencesChanged initialization will be considered as completed, and any 25 // OnPreferencesChanged initialization will be considered as completed, and any
26 // PrefStore::Observer will be notified of OnInitializationCompleted. 26 // PrefStore::Observer will be notified of OnInitializationCompleted.
27 // 27 //
28 // Currently this does not support RemoveValue. 28 // Currently this does not support RemoveValue.
29 class PrefObserverStore : public ValueMapPrefStore, 29 class PrefObserverStore : public ValueMapPrefStore,
30 public prefs::mojom::PreferencesObserver { 30 public prefs::mojom::PreferencesObserver {
31 public: 31 public:
32 explicit PrefObserverStore( 32 explicit PrefObserverStore(
33 prefs::mojom::PreferencesManagerPtr prefs_manager_ptr); 33 prefs::mojom::PreferencesFactoryPtr pref_factory_ptr);
34 34
35 // Adds a set of |keys| which PrefObserverStore will handle. Begins listening 35 // Adds a set of |keys| which PrefObserverStore will handle. Begins listening
36 // for changes to these from |prefs_manager_|. 36 // for changes to these from |prefs_manager_|.
37 void Subscribe(const std::set<std::string>& keys); 37 void Subscribe(const std::set<std::string>& keys);
38 38
39 // PrefStore: 39 // PrefStore:
40 bool GetValue(const std::string& key, 40 bool GetValue(const std::string& key,
41 const base::Value** value) const override; 41 const base::Value** value) const override;
42 42
43 // ValueMapPrefStore: 43 // ValueMapPrefStore:
(...skipping 16 matching lines...) Expand all
60 60
61 // Notifies |prefs_manager_| of the change in |key| - |value| pair. 61 // Notifies |prefs_manager_| of the change in |key| - |value| pair.
62 void SetValueOnPreferenceManager(const std::string& key, 62 void SetValueOnPreferenceManager(const std::string& key,
63 base::Value const & value); 63 base::Value const & value);
64 64
65 // prefs::mojom::PreferenceObserver: 65 // prefs::mojom::PreferenceObserver:
66 void OnPreferencesChanged( 66 void OnPreferencesChanged(
67 std::unique_ptr<base::DictionaryValue> preferences) override; 67 std::unique_ptr<base::DictionaryValue> preferences) override;
68 68
69 mojo::Binding<prefs::mojom::PreferencesObserver> prefs_binding_; 69 mojo::Binding<prefs::mojom::PreferencesObserver> prefs_binding_;
70 prefs::mojom::PreferencesFactoryPtr pref_factory_ptr_;
70 prefs::mojom::PreferencesManagerPtr prefs_manager_ptr_; 71 prefs::mojom::PreferencesManagerPtr prefs_manager_ptr_;
71 72
72 std::set<std::string> keys_; 73 std::set<std::string> keys_;
73 74
74 // True upon the first OnPreferencesChanged received after Init. 75 // True upon the first OnPreferencesChanged received after Init.
75 bool initialized_; 76 bool initialized_;
76 77
77 DISALLOW_COPY_AND_ASSIGN(PrefObserverStore); 78 DISALLOW_COPY_AND_ASSIGN(PrefObserverStore);
78 }; 79 };
79 80
80 } // namespace preferences 81 } // namespace preferences
81 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREFS_OBSERVER_STORE_H_ 82 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREFS_OBSERVER_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698