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

Unified Diff: services/preferences/persistent_pref_store_impl.h

Issue 2743563003: Pref service: add persistent pref store frontend and backend. (Closed)
Patch Set: rebase 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
« no previous file with comments | « services/preferences/DEPS ('k') | services/preferences/persistent_pref_store_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/preferences/persistent_pref_store_impl.h
diff --git a/services/preferences/persistent_pref_store_impl.h b/services/preferences/persistent_pref_store_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..9b7aeff89adabb1b802046749d659e40e400ae0c
--- /dev/null
+++ b/services/preferences/persistent_pref_store_impl.h
@@ -0,0 +1,67 @@
+// 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_PERSISTENT_PREF_STORE_IMPL_H_
+#define SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_
+
+#include <memory>
+#include <string>
+#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 PersistentPrefStoreImpl : public mojom::PersistentPrefStoreConnector,
+ public PrefStore::Observer {
+ public:
+ PersistentPrefStoreImpl(
+ scoped_refptr<PersistentPrefStore> backing_pref_store,
+ mojom::TrackedPreferenceValidationDelegatePtr validation_delegate);
+
+ ~PersistentPrefStoreImpl() 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_;
+
+ DISALLOW_COPY_AND_ASSIGN(PersistentPrefStoreImpl);
+};
+
+} // namespace prefs
+
+#endif // SERVICES_PREFERENCES_PERSISTENT_PREF_STORE_IMPL_H_
« no previous file with comments | « services/preferences/DEPS ('k') | services/preferences/persistent_pref_store_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698