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

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

Issue 2474653003: PreferencesManager (Closed)
Patch Set: Update mojom to support separate subscriptions Created 4 years 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 17 matching lines...) Expand all
28 // OnPreferencesChanged initialization will be considered as completed, and any 28 // OnPreferencesChanged initialization will be considered as completed, and any
29 // PrefStore::Observer will be notified of OnInitializationCompleted. 29 // PrefStore::Observer will be notified of OnInitializationCompleted.
30 // 30 //
31 // Currently this does not support RemoveValue. 31 // Currently this does not support RemoveValue.
32 class PrefObserverStore : public ValueMapPrefStore, 32 class PrefObserverStore : public ValueMapPrefStore,
33 public prefs::mojom::PreferencesObserver { 33 public prefs::mojom::PreferencesObserver {
34 public: 34 public:
35 explicit PrefObserverStore( 35 explicit PrefObserverStore(
36 prefs::mojom::PreferencesManagerPtr prefs_manager_ptr); 36 prefs::mojom::PreferencesManagerPtr prefs_manager_ptr);
37 37
38 // Defines the set of |keys| which PrefOvserverStore will handle. Begins 38 // Adds a set of |keys| which PrefObserverStore will handle. Begins listening
39 // listening for changes to these from |prefs_manager_|. 39 // for changes to these from |prefs_manager_|.
40 void Init(const std::set<std::string>& keys); 40 void Subscribe(const std::set<std::string>& keys);
41 41
42 // PrefStore: 42 // PrefStore:
43 bool GetValue(const std::string& key, 43 bool GetValue(const std::string& key,
44 const base::Value** value) const override; 44 const base::Value** value) const override;
45 45
46 // ValueMapPrefStore: 46 // ValueMapPrefStore:
47 void SetValue(const std::string& key, 47 void SetValue(const std::string& key,
48 std::unique_ptr<base::Value> value, 48 std::unique_ptr<base::Value> value,
49 uint32_t flags) override; 49 uint32_t flags) override;
50 void RemoveValue(const std::string& key, uint32_t flags) override; 50 void RemoveValue(const std::string& key, uint32_t flags) override;
(...skipping 22 matching lines...) Expand all
73 73
74 std::set<std::string> keys_; 74 std::set<std::string> keys_;
75 75
76 // True upon the first OnPreferencesChanged received after Init. 76 // True upon the first OnPreferencesChanged received after Init.
77 bool initialized_; 77 bool initialized_;
78 78
79 DISALLOW_COPY_AND_ASSIGN(PrefObserverStore); 79 DISALLOW_COPY_AND_ASSIGN(PrefObserverStore);
80 }; 80 };
81 81
82 #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