OLD | NEW |
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> |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace prefs { | 21 namespace prefs { |
22 | 22 |
23 class PersistentPrefStoreImpl : public PrefStore::Observer { | 23 class PersistentPrefStoreImpl : public PrefStore::Observer { |
24 public: | 24 public: |
25 using ObservedPrefs = std::set<std::string>; | 25 using ObservedPrefs = std::set<std::string>; |
26 | 26 |
27 // If |initialized()| is false after construction, |on_initialized| will be | 27 // If |initialized()| is false after construction, |on_initialized| will be |
28 // called when it becomes true. | 28 // called when it becomes true. |
29 PersistentPrefStoreImpl( | 29 PersistentPrefStoreImpl( |
30 scoped_refptr<PersistentPrefStore> backing_pref_store, | 30 scoped_refptr<PersistentPrefStore> backing_pref_store, |
31 mojom::TrackedPreferenceValidationDelegatePtr validation_delegate, | |
32 base::OnceClosure on_initialized); | 31 base::OnceClosure on_initialized); |
33 | 32 |
34 ~PersistentPrefStoreImpl() override; | 33 ~PersistentPrefStoreImpl() override; |
35 | 34 |
36 mojom::PersistentPrefStoreConnectionPtr CreateConnection( | 35 mojom::PersistentPrefStoreConnectionPtr CreateConnection( |
37 ObservedPrefs observed_prefs); | 36 ObservedPrefs observed_prefs); |
38 | 37 |
39 bool initialized() { return !initializing_; } | 38 bool initialized() { return !initializing_; } |
40 | 39 |
41 private: | 40 private: |
42 class Connection; | 41 class Connection; |
43 | 42 |
44 void SetValue(const std::string& key, | 43 void SetValue(const std::string& key, |
45 std::unique_ptr<base::Value> value, | 44 std::unique_ptr<base::Value> value, |
46 uint32_t flags); | 45 uint32_t flags); |
47 | 46 |
48 void CommitPendingWrite(); | 47 void CommitPendingWrite(); |
49 void SchedulePendingLossyWrites(); | 48 void SchedulePendingLossyWrites(); |
50 void ClearMutableValues(); | 49 void ClearMutableValues(); |
51 | 50 |
52 // PrefStore::Observer: | 51 // PrefStore::Observer: |
53 void OnPrefValueChanged(const std::string& key) override; | 52 void OnPrefValueChanged(const std::string& key) override; |
54 void OnInitializationCompleted(bool succeeded) override; | 53 void OnInitializationCompleted(bool succeeded) override; |
55 | 54 |
56 void OnConnectionError(Connection* connection); | 55 void OnConnectionError(Connection* connection); |
57 | 56 |
58 scoped_refptr<PersistentPrefStore> backing_pref_store_; | 57 scoped_refptr<PersistentPrefStore> backing_pref_store_; |
59 mojom::TrackedPreferenceValidationDelegatePtr validation_delegate_; | |
60 | 58 |
61 bool initializing_ = false; | 59 bool initializing_ = false; |
62 | 60 |
63 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_; | 61 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_; |
64 | 62 |
65 base::OnceClosure on_initialized_; | 63 base::OnceClosure on_initialized_; |
66 | 64 |
67 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreImpl); | 65 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreImpl); |
68 }; | 66 }; |
69 | 67 |
70 } // namespace prefs | 68 } // namespace prefs |
71 | 69 |
72 #endif // SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ | 70 #endif // SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ |
OLD | NEW |