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

Side by Side Diff: services/preferences/persistent_pref_store_impl.h

Issue 2791893002: Pref service: Batch pref updates. (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
« no previous file with comments | « no previous file | services/preferences/persistent_pref_store_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_PERSISTENT_PREF_STORE_IMPL_H_ 5 #ifndef SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_
6 #define SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ 6 #define SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <unordered_map> 10 #include <unordered_map>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "services/preferences/public/interfaces/preferences.mojom.h" 14 #include "services/preferences/public/interfaces/preferences.mojom.h"
15 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h" 15 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h"
16 16
17 namespace base {
18 class Value;
19 }
20
21 namespace prefs { 17 namespace prefs {
22 18
23 class PersistentPrefStoreImpl : public PrefStore::Observer { 19 class PersistentPrefStoreImpl : public PrefStore::Observer {
24 public: 20 public:
25 using ObservedPrefs = std::set<std::string>; 21 using ObservedPrefs = std::set<std::string>;
26 22
27 // If |initialized()| is false after construction, |on_initialized| will be 23 // If |initialized()| is false after construction, |on_initialized| will be
28 // called when it becomes true. 24 // called when it becomes true.
29 PersistentPrefStoreImpl( 25 PersistentPrefStoreImpl(
30 scoped_refptr<PersistentPrefStore> backing_pref_store, 26 scoped_refptr<PersistentPrefStore> backing_pref_store,
31 base::OnceClosure on_initialized); 27 base::OnceClosure on_initialized);
32 28
33 ~PersistentPrefStoreImpl() override; 29 ~PersistentPrefStoreImpl() override;
34 30
35 mojom::PersistentPrefStoreConnectionPtr CreateConnection( 31 mojom::PersistentPrefStoreConnectionPtr CreateConnection(
36 ObservedPrefs observed_prefs); 32 ObservedPrefs observed_prefs);
37 33
38 bool initialized() { return !initializing_; } 34 bool initialized() { return !initializing_; }
39 35
40 private: 36 private:
41 class Connection; 37 class Connection;
42 38
43 void SetValue(const std::string& key, 39 void SetValues(std::vector<mojom::PrefUpdatePtr> updates);
44 std::unique_ptr<base::Value> value,
45 uint32_t flags);
46 40
47 void CommitPendingWrite(); 41 void CommitPendingWrite();
48 void SchedulePendingLossyWrites(); 42 void SchedulePendingLossyWrites();
49 void ClearMutableValues(); 43 void ClearMutableValues();
50 44
51 // PrefStore::Observer: 45 // PrefStore::Observer:
52 void OnPrefValueChanged(const std::string& key) override; 46 void OnPrefValueChanged(const std::string& key) override;
53 void OnInitializationCompleted(bool succeeded) override; 47 void OnInitializationCompleted(bool succeeded) override;
54 48
55 void OnConnectionError(Connection* connection); 49 void OnConnectionError(Connection* connection);
56 50
57 scoped_refptr<PersistentPrefStore> backing_pref_store_; 51 scoped_refptr<PersistentPrefStore> backing_pref_store_;
58 52
59 bool initializing_ = false; 53 bool initializing_ = false;
60 54
61 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_; 55 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_;
62 56
63 base::OnceClosure on_initialized_; 57 base::OnceClosure on_initialized_;
64 58
65 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreImpl); 59 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreImpl);
66 }; 60 };
67 61
68 } // namespace prefs 62 } // namespace prefs
69 63
70 #endif // SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ 64 #endif // SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | services/preferences/persistent_pref_store_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698