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

Unified Diff: services/preferences/user_prefs.h

Issue 2743563003: Pref service: add persistent pref store frontend and backend. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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..69b4bf21967386349be296a2264ffbf503719d4c
--- /dev/null
+++ b/services/preferences/user_prefs.h
@@ -0,0 +1,65 @@
+// 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 "services/preferences/public/interfaces/preferences.mojom.h"
+#include "services/preferences/public/interfaces/tracked_preference_validation_delegate.mojom.h"
+
+namespace base {
+class Value;
+}
+
+namespace prefs {
+
+class UserPrefs : public mojom::PersistentPrefStoreConnector,
tibell 2017/03/10 02:18:27 Sorry to be a pain, but I think it would be nice t
Sam McNally 2017/03/10 02:43:25 Done.
+ 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 initializing_ = false;
+ std::vector<ConnectCallback> pending_connect_callbacks_;
+
+ std::unordered_map<Connection*, std::unique_ptr<Connection>> connections_;
tibell 2017/03/10 02:18:27 Could this just be set<std::unique_ptr<Connection>
Sam McNally 2017/03/10 02:43:25 Lookup by unique_ptr is inefficient.
+
+ DISALLOW_COPY_AND_ASSIGN(UserPrefs);
+};
+
+} // namespace prefs
+
+#endif // SERVICES_PREFERENCES_USER_PREFS_H_

Powered by Google App Engine
This is Rietveld 408576698