Index: services/preferences/user_prefs.h |
diff --git a/services/preferences/user_prefs.h b/services/preferences/user_prefs.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a74d6e7d99850da28c1a49033c5cf0cbdcb8692b |
--- /dev/null |
+++ b/services/preferences/user_prefs.h |
@@ -0,0 +1,62 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef SERVICES_PREFERENCES_USER_PREFS_H_ |
+#define SERVICES_PREFERENCES_USER_PREFS_H_ |
+ |
+#include <memory> |
+#include <unordered_map> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "base/values.h" |
+#include "services/preferences/public/interfaces/preferences.mojom.h" |
+#include "services/preferences/public/interfaces/tracked_preference_validation_delegate.mojom.h" |
+ |
+namespace prefs { |
+ |
+class UserPrefs : public mojom::PersistentPrefStoreConnector, |
+ public PrefStore::Observer { |
+ public: |
+ UserPrefs(scoped_refptr<PersistentPrefStore> backing_pref_store, |
+ mojom::TrackedPreferenceValidationDelegatePtr validation_delegate); |
+ |
+ ~UserPrefs() override; |
+ |
+ // mojom::PersistentPrefStoreConnector override: |
+ void Connect(const ConnectCallback& callback) override; |
+ |
+ private: |
+ class Connection; |
+ |
+ void SetValue(const std::string& key, |
+ std::unique_ptr<base::Value> value, |
+ uint32_t flags); |
+ |
+ void CommitPendingWrite(); |
+ void SchedulePendingLossyWrites(); |
+ void ClearMutableValues(); |
+ |
+ // PrefStore::Observer: |
+ void OnPrefValueChanged(const std::string& key) override; |
+ void OnInitializationCompleted(bool succeeded) override; |
+ |
+ void CallConnectCallback( |
+ const mojom::PersistentPrefStoreConnector::ConnectCallback& callback); |
+ void OnConnectionError(Connection* connection); |
+ |
+ scoped_refptr<PersistentPrefStore> backing_pref_store_; |
+ mojom::TrackedPreferenceValidationDelegatePtr validation_delegate_; |
+ |
+ bool loading_ = false; |
+ std::vector<ConnectCallback> connect_callbacks_; |
+ |
+ std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(UserPrefs); |
+}; |
+ |
+} // namespace prefs |
+ |
+#endif // SERVICES_PREFERENCES_USER_PREFS_H_ |