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

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

Issue 2812863002: Pref service: Add a ScopedDictionaryPrefUpdate to track value changes. (Closed)
Patch Set: rebase Created 3 years, 8 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_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 #include <vector>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/observer_list.h" 13 #include "base/observer_list.h"
13 #include "mojo/public/cpp/bindings/binding.h" 14 #include "mojo/public/cpp/bindings/binding.h"
14 #include "services/preferences/public/interfaces/preferences.mojom.h" 15 #include "services/preferences/public/interfaces/preferences.mojom.h"
15 16
16 namespace base { 17 namespace base {
17 class DictionaryValue; 18 class DictionaryValue;
18 class Value; 19 class Value;
19 } 20 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 52
52 base::DictionaryValue& GetMutableValues(); 53 base::DictionaryValue& GetMutableValues();
53 void ReportPrefValueChanged(const std::string& key); 54 void ReportPrefValueChanged(const std::string& key);
54 55
55 private: 56 private:
56 // prefs::mojom::PreferenceObserver: 57 // prefs::mojom::PreferenceObserver:
57 void OnPrefsChanged(std::vector<mojom::PrefUpdatePtr> updates) override; 58 void OnPrefsChanged(std::vector<mojom::PrefUpdatePtr> updates) override;
58 void OnInitializationCompleted(bool succeeded) override; 59 void OnInitializationCompleted(bool succeeded) override;
59 60
60 void OnPrefChanged(const std::string& key, 61 void OnPrefChanged(const std::string& key,
61 std::unique_ptr<base::Value> value); 62 mojom::PrefUpdateValuePtr update_value);
62 63
63 // Cached preferences. 64 // Cached preferences.
64 // If null, indicates that initialization failed. 65 // If null, indicates that initialization failed.
65 std::unique_ptr<base::DictionaryValue> cached_prefs_; 66 std::unique_ptr<base::DictionaryValue> cached_prefs_;
66 67
67 base::ObserverList<PrefStore::Observer, true> observers_; 68 base::ObserverList<PrefStore::Observer, true> observers_;
68 69
69 // Has the PrefStore we're observing been initialized? 70 // Has the PrefStore we're observing been initialized?
70 bool initialized_ = false; 71 bool initialized_ = false;
71 72
72 mojo::Binding<mojom::PrefStoreObserver> observer_binding_; 73 mojo::Binding<mojom::PrefStoreObserver> observer_binding_;
73 74
74 DISALLOW_COPY_AND_ASSIGN(PrefStoreClientMixin); 75 DISALLOW_COPY_AND_ASSIGN(PrefStoreClientMixin);
75 }; 76 };
76 77
77 extern template class PrefStoreClientMixin<::PrefStore>; 78 extern template class PrefStoreClientMixin<::PrefStore>;
78 extern template class PrefStoreClientMixin<::PersistentPrefStore>; 79 extern template class PrefStoreClientMixin<::PersistentPrefStore>;
79 80
80 } // namespace prefs 81 } // namespace prefs
81 82
82 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_CLIENT_MIXIN_H_ 83 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_CLIENT_MIXIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698