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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/prefs/in_memory_pref_store.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "base/values.h"
11
12 InMemoryPrefStore::InMemoryPrefStore() {}
13
14 InMemoryPrefStore::~InMemoryPrefStore() {}
15
16 bool InMemoryPrefStore::GetValue(const std::string& key,
17 const base::Value** value) const {
18 return prefs_.GetValue(key, value);
19 }
20
21 bool InMemoryPrefStore::GetMutableValue(const std::string& key,
22 base::Value** value) {
23 return prefs_.GetValue(key, value);
24 }
25
26 void InMemoryPrefStore::AddObserver(PrefStore::Observer* observer) {
27 observers_.AddObserver(observer);
28 }
29
30 void InMemoryPrefStore::RemoveObserver(PrefStore::Observer* observer) {
31 observers_.RemoveObserver(observer);
32 }
33
34 bool InMemoryPrefStore::HasObservers() const {
35 return observers_.might_have_observers();
36 }
37
38 bool InMemoryPrefStore::IsInitializationComplete() const {
39 return true;
40 }
41
42 void InMemoryPrefStore::SetValue(const std::string& key,
43 std::unique_ptr<base::Value> value,
44 uint32_t flags) {
45 DCHECK(value);
46 if (prefs_.SetValue(key, std::move(value)))
47 ReportValueChanged(key, flags);
48 }
49
50 void InMemoryPrefStore::SetValueSilently(const std::string& key,
51 std::unique_ptr<base::Value> value,
52 uint32_t flags) {
53 prefs_.SetValue(key, std::move(value));
54 }
55
56 void InMemoryPrefStore::RemoveValue(const std::string& key, uint32_t flags) {
57 if (prefs_.RemoveValue(key))
58 ReportValueChanged(key, flags);
59 }
60
61 bool InMemoryPrefStore::ReadOnly() const {
62 return false;
63 }
64
65 PersistentPrefStore::PrefReadError InMemoryPrefStore::GetReadError() const {
66 return PersistentPrefStore::PREF_READ_ERROR_NONE;
67 }
68
69 PersistentPrefStore::PrefReadError InMemoryPrefStore::ReadPrefs() {
70 return PersistentPrefStore::PREF_READ_ERROR_NONE;
71 }
72
73 void InMemoryPrefStore::ReportValueChanged(const std::string& key,
74 uint32_t flags) {
75 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
76 }
OLDNEW
« 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