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

Side by Side Diff: services/preferences/public/cpp/persistent_pref_store_client.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_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 <map>
8 #include <memory> 9 #include <memory>
10 #include <set>
9 #include <string> 11 #include <string>
12 #include <unordered_map>
13 #include <utility>
10 #include <vector> 14 #include <vector>
11 15
12 #include "base/macros.h" 16 #include "base/macros.h"
13 #include "components/prefs/persistent_pref_store.h" 17 #include "components/prefs/persistent_pref_store.h"
14 #include "components/prefs/pref_value_store.h" 18 #include "components/prefs/pref_value_store.h"
15 #include "services/preferences/public/cpp/pref_store_client_mixin.h" 19 #include "services/preferences/public/cpp/pref_store_client_mixin.h"
16 #include "services/preferences/public/interfaces/preferences.mojom.h" 20 #include "services/preferences/public/interfaces/preferences.mojom.h"
17 21
18 namespace base { 22 namespace base {
19 class Value; 23 class Value;
(...skipping 16 matching lines...) Expand all
36 explicit PersistentPrefStoreClient( 40 explicit PersistentPrefStoreClient(
37 mojom::PersistentPrefStoreConnectionPtr connection); 41 mojom::PersistentPrefStoreConnectionPtr connection);
38 42
39 // WriteablePrefStore: 43 // WriteablePrefStore:
40 void SetValue(const std::string& key, 44 void SetValue(const std::string& key,
41 std::unique_ptr<base::Value> value, 45 std::unique_ptr<base::Value> value,
42 uint32_t flags) override; 46 uint32_t flags) override;
43 void RemoveValue(const std::string& key, uint32_t flags) override; 47 void RemoveValue(const std::string& key, uint32_t flags) override;
44 bool GetMutableValue(const std::string& key, base::Value** result) override; 48 bool GetMutableValue(const std::string& key, base::Value** result) override;
45 void ReportValueChanged(const std::string& key, uint32_t flags) override; 49 void ReportValueChanged(const std::string& key, uint32_t flags) override;
50 void ReportSubValuesChanged(
51 const std::string& key,
52 std::set<std::vector<std::string>> path_components,
53 uint32_t flags) override;
46 void SetValueSilently(const std::string& key, 54 void SetValueSilently(const std::string& key,
47 std::unique_ptr<base::Value> value, 55 std::unique_ptr<base::Value> value,
48 uint32_t flags) override; 56 uint32_t flags) override;
49 57
50 // PersistentPrefStore: 58 // PersistentPrefStore:
51 bool ReadOnly() const override; 59 bool ReadOnly() const override;
52 PrefReadError GetReadError() const override; 60 PrefReadError GetReadError() const override;
53 PrefReadError ReadPrefs() override; 61 PrefReadError ReadPrefs() override;
54 void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override; 62 void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override;
55 void CommitPendingWrite() override; 63 void CommitPendingWrite() override;
56 void SchedulePendingLossyWrites() override; 64 void SchedulePendingLossyWrites() override;
57 void ClearMutableValues() override; 65 void ClearMutableValues() override;
58 66
59 protected: 67 protected:
60 // base::RefCounted<PrefStore>: 68 // base::RefCounted<PrefStore>:
61 ~PersistentPrefStoreClient() override; 69 ~PersistentPrefStoreClient() override;
62 70
63 private: 71 private:
64 void OnConnect(mojom::PersistentPrefStoreConnectionPtr connection, 72 void OnConnect(mojom::PersistentPrefStoreConnectionPtr connection,
65 std::unordered_map<PrefValueStore::PrefStoreType, 73 std::unordered_map<PrefValueStore::PrefStoreType,
66 prefs::mojom::PrefStoreConnectionPtr> 74 prefs::mojom::PrefStoreConnectionPtr>
67 other_pref_stores); 75 other_pref_stores);
68 76
69 void QueueWrite(const std::string& key, uint32_t flags); 77 void QueueWrite(const std::string& key,
78 std::set<std::vector<std::string>> path_components,
79 uint32_t flags);
70 void FlushPendingWrites(); 80 void FlushPendingWrites();
71 81
72 mojom::PrefStoreConnectorPtr connector_; 82 mojom::PrefStoreConnectorPtr connector_;
73 scoped_refptr<PrefRegistry> pref_registry_; 83 scoped_refptr<PrefRegistry> pref_registry_;
74 bool read_only_ = false; 84 bool read_only_ = false;
75 PrefReadError read_error_ = PersistentPrefStore::PREF_READ_ERROR_NONE; 85 PrefReadError read_error_ = PersistentPrefStore::PREF_READ_ERROR_NONE;
76 mojom::PersistentPrefStorePtr pref_store_; 86 mojom::PersistentPrefStorePtr pref_store_;
77 std::map<std::string, uint32_t> pending_writes_; 87 std::map<std::string, std::pair<std::set<std::vector<std::string>>, uint32_t>>
88 pending_writes_;
78 89
79 std::unique_ptr<ReadErrorDelegate> error_delegate_; 90 std::unique_ptr<ReadErrorDelegate> error_delegate_;
80 std::vector<PrefValueStore::PrefStoreType> already_connected_types_; 91 std::vector<PrefValueStore::PrefStoreType> already_connected_types_;
81 92
82 base::WeakPtrFactory<PersistentPrefStoreClient> weak_factory_; 93 base::WeakPtrFactory<PersistentPrefStoreClient> weak_factory_;
83 94
84 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreClient); 95 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreClient);
85 }; 96 };
86 97
87 } // namespace prefs 98 } // namespace prefs
88 99
89 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_ 100 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PERSISTENT_PREF_STORE_CLIENT_H_
OLDNEW
« no previous file with comments | « services/preferences/public/cpp/lib/util.cc ('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