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

Unified Diff: components/prefs/in_memory_pref_store.cc

Issue 1881253003: Create a PrefStore in support of Blimp metrics collection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix conflict with ptr migration work. Created 4 years, 8 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 | « components/prefs/in_memory_pref_store.h ('k') | components/prefs/in_memory_pref_store_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/prefs/in_memory_pref_store.cc
diff --git a/components/prefs/in_memory_pref_store.cc b/components/prefs/in_memory_pref_store.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c222a3680ac232aeb2ee1bdf6c43a8d953b290e7
--- /dev/null
+++ b/components/prefs/in_memory_pref_store.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2016 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.
+
+#include "components/prefs/in_memory_pref_store.h"
+
+#include <memory>
+#include <utility>
+
+#include "base/values.h"
+
+InMemoryPrefStore::InMemoryPrefStore() {}
+
+InMemoryPrefStore::~InMemoryPrefStore() {}
+
+bool InMemoryPrefStore::GetValue(const std::string& key,
+ const base::Value** value) const {
+ return prefs_.GetValue(key, value);
+}
+
+bool InMemoryPrefStore::GetMutableValue(const std::string& key,
+ base::Value** value) {
+ return prefs_.GetValue(key, value);
+}
+
+void InMemoryPrefStore::AddObserver(PrefStore::Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void InMemoryPrefStore::RemoveObserver(PrefStore::Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+bool InMemoryPrefStore::HasObservers() const {
+ return observers_.might_have_observers();
+}
+
+bool InMemoryPrefStore::IsInitializationComplete() const {
+ return true;
+}
+
+void InMemoryPrefStore::SetValue(const std::string& key,
+ std::unique_ptr<base::Value> value,
+ uint32_t flags) {
+ DCHECK(value);
+ if (prefs_.SetValue(key, std::move(value)))
+ ReportValueChanged(key, flags);
+}
+
+void InMemoryPrefStore::SetValueSilently(const std::string& key,
+ std::unique_ptr<base::Value> value,
+ uint32_t flags) {
+ prefs_.SetValue(key, std::move(value));
+}
+
+void InMemoryPrefStore::RemoveValue(const std::string& key, uint32_t flags) {
+ if (prefs_.RemoveValue(key))
+ ReportValueChanged(key, flags);
+}
+
+bool InMemoryPrefStore::ReadOnly() const {
+ return false;
+}
+
+PersistentPrefStore::PrefReadError InMemoryPrefStore::GetReadError() const {
+ return PersistentPrefStore::PREF_READ_ERROR_NONE;
+}
+
+PersistentPrefStore::PrefReadError InMemoryPrefStore::ReadPrefs() {
+ return PersistentPrefStore::PREF_READ_ERROR_NONE;
+}
+
+void InMemoryPrefStore::ReportValueChanged(const std::string& key,
+ uint32_t flags) {
+ FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
+}
« no previous file with comments | « components/prefs/in_memory_pref_store.h ('k') | components/prefs/in_memory_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698