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

Unified Diff: services/preferences/public/cpp/pref_store_adapter.h

Issue 2635153002: Pref service: expose all read-only PrefStores through Mojo (Closed)
Patch Set: Create and register service Created 3 years, 10 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/public/cpp/pref_store_adapter.h
diff --git a/services/preferences/public/cpp/pref_store_adapter.h b/services/preferences/public/cpp/pref_store_adapter.h
new file mode 100644
index 0000000000000000000000000000000000000000..e850d42904732dc2fdcfb159266a594a3e3eca44
--- /dev/null
+++ b/services/preferences/public/cpp/pref_store_adapter.h
@@ -0,0 +1,44 @@
+// 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_PUBLIC_CPP_PREF_STORE_ADAPTER_H_
+#define SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_ADAPTER_H_
+
+#include <memory>
+
+#include "base/macros.h"
+#include "base/values.h"
+#include "components/prefs/pref_store.h"
+#include "services/preferences/public/cpp/pref_store_impl.h"
+
+namespace prefs {
+
+// Ties the life time of a |PrefStoreImpl| to a |PrefStore|. Otherwise acts as a
+// |PrefStore|, forwarding all calls to the wrapped |PrefStore|.
+class PrefStoreAdapter : public PrefStore {
+ public:
+ PrefStoreAdapter(scoped_refptr<PrefStore> pref_store,
+ std::unique_ptr<PrefStoreImpl> impl);
+
+ // PrefStore:
+ void AddObserver(PrefStore::Observer* observer) override;
+ void RemoveObserver(PrefStore::Observer* observer) override;
+ bool HasObservers() const override;
+ bool IsInitializationComplete() const override;
+ bool GetValue(const std::string& key,
+ const base::Value** result) const override;
+ std::unique_ptr<base::DictionaryValue> GetValues() const override;
+
+ private:
+ ~PrefStoreAdapter() override;
+
+ scoped_refptr<PrefStore> pref_store_;
+ std::unique_ptr<PrefStoreImpl> impl_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrefStoreAdapter);
+};
+
+} // namespace prefs
+
+#endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_ADAPTER_H_

Powered by Google App Engine
This is Rietveld 408576698