| 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, |
| 31 base::OnceClosure on_initialized); | 32 base::OnceClosure on_initialized); |
| 32 | 33 |
| 33 ~PersistentPrefStoreImpl() override; | 34 ~PersistentPrefStoreImpl() override; |
| 34 | 35 |
| 35 mojom::PersistentPrefStoreConnectionPtr CreateConnection( | 36 mojom::PersistentPrefStoreConnectionPtr CreateConnection( |
| 36 ObservedPrefs observed_prefs); | 37 ObservedPrefs observed_prefs); |
| 37 | 38 |
| 38 bool initialized() { return !initializing_; } | 39 bool initialized() { return !initializing_; } |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 class Connection; | 42 class Connection; |
| 42 | 43 |
| 43 void SetValue(const std::string& key, | 44 void SetValue(const std::string& key, |
| 44 std::unique_ptr<base::Value> value, | 45 std::unique_ptr<base::Value> value, |
| 45 uint32_t flags); | 46 uint32_t flags); |
| 46 | 47 |
| 47 void CommitPendingWrite(); | 48 void CommitPendingWrite(); |
| 48 void SchedulePendingLossyWrites(); | 49 void SchedulePendingLossyWrites(); |
| 49 void ClearMutableValues(); | 50 void ClearMutableValues(); |
| 50 | 51 |
| 51 // PrefStore::Observer: | 52 // PrefStore::Observer: |
| 52 void OnPrefValueChanged(const std::string& key) override; | 53 void OnPrefValueChanged(const std::string& key) override; |
| 53 void OnInitializationCompleted(bool succeeded) override; | 54 void OnInitializationCompleted(bool succeeded) override; |
| 54 | 55 |
| 55 void OnConnectionError(Connection* connection); | 56 void OnConnectionError(Connection* connection); |
| 56 | 57 |
| 57 scoped_refptr<PersistentPrefStore> backing_pref_store_; | 58 scoped_refptr<PersistentPrefStore> backing_pref_store_; |
| 59 mojom::TrackedPreferenceValidationDelegatePtr validation_delegate_; |
| 58 | 60 |
| 59 bool initializing_ = false; | 61 bool initializing_ = false; |
| 60 | 62 |
| 61 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_; | 63 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_; |
| 62 | 64 |
| 63 base::OnceClosure on_initialized_; | 65 base::OnceClosure on_initialized_; |
| 64 | 66 |
| 65 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreImpl); | 67 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreImpl); |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 } // namespace prefs | 70 } // namespace prefs |
| 69 | 71 |
| 70 #endif // SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ | 72 #endif // SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ |
| OLD | NEW |