OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ |
| 6 #define SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 #include <unordered_map> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "services/preferences/public/interfaces/preferences.mojom.h" |
| 15 #include "services/preferences/public/interfaces/tracked_preference_validation_d
elegate.mojom.h" |
| 16 |
| 17 namespace base { |
| 18 class Value; |
| 19 } |
| 20 |
| 21 namespace prefs { |
| 22 |
| 23 class PersistentPrefStoreImpl : public mojom::PersistentPrefStoreConnector, |
| 24 public PrefStore::Observer { |
| 25 public: |
| 26 PersistentPrefStoreImpl( |
| 27 scoped_refptr<PersistentPrefStore> backing_pref_store, |
| 28 mojom::TrackedPreferenceValidationDelegatePtr validation_delegate); |
| 29 |
| 30 ~PersistentPrefStoreImpl() override; |
| 31 |
| 32 // mojom::PersistentPrefStoreConnector override: |
| 33 void Connect(const ConnectCallback& callback) override; |
| 34 |
| 35 private: |
| 36 class Connection; |
| 37 |
| 38 void SetValue(const std::string& key, |
| 39 std::unique_ptr<base::Value> value, |
| 40 uint32_t flags); |
| 41 |
| 42 void CommitPendingWrite(); |
| 43 void SchedulePendingLossyWrites(); |
| 44 void ClearMutableValues(); |
| 45 |
| 46 // PrefStore::Observer: |
| 47 void OnPrefValueChanged(const std::string& key) override; |
| 48 void OnInitializationCompleted(bool succeeded) override; |
| 49 |
| 50 void CallConnectCallback( |
| 51 const mojom::PersistentPrefStoreConnector::ConnectCallback& callback); |
| 52 void OnConnectionError(Connection* connection); |
| 53 |
| 54 scoped_refptr<PersistentPrefStore> backing_pref_store_; |
| 55 mojom::TrackedPreferenceValidationDelegatePtr validation_delegate_; |
| 56 |
| 57 bool initializing_ = false; |
| 58 std::vector<ConnectCallback> pending_connect_callbacks_; |
| 59 |
| 60 std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreImpl); |
| 63 }; |
| 64 |
| 65 } // namespace prefs |
| 66 |
| 67 #endif // SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_ |
OLD | NEW |