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

Side by Side Diff: blimp/engine/common/blimp_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: Additional test to confirm proper observer calls. 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 "blimp/engine/common/blimp_pref_store.h"
6
7 #include <memory>
8 #include <utility>
9
10 #include "base/values.h"
11
12 namespace blimp {
13 namespace engine {
14
15 BlimpPrefStore::BlimpPrefStore() {}
16
17 BlimpPrefStore::~BlimpPrefStore() {}
18
19 bool BlimpPrefStore::GetValue(const std::string& key,
20 const base::Value** value) const {
21 return prefs_.GetValue(key, value);
22 }
23
24 bool BlimpPrefStore::GetMutableValue(const std::string& key,
25 base::Value** value) {
26 return prefs_.GetValue(key, value);
27 }
28
29 void BlimpPrefStore::AddObserver(PrefStore::Observer* observer) {
30 observers_.AddObserver(observer);
31 }
32
33 void BlimpPrefStore::RemoveObserver(PrefStore::Observer* observer) {
34 observers_.RemoveObserver(observer);
35 }
36
37 bool BlimpPrefStore::HasObservers() const {
38 return observers_.might_have_observers();
39 }
40
41 bool BlimpPrefStore::IsInitializationComplete() const {
42 return true;
43 }
44
45 void BlimpPrefStore::SetValue(const std::string& key,
46 std::unique_ptr<base::Value> value,
47 uint32_t flags) {
48 DCHECK(value);
49 if (prefs_.SetValue(key, std::move(value)))
50 ReportValueChanged(key, flags);
51 }
52
53 void BlimpPrefStore::SetValueSilently(const std::string& key,
54 std::unique_ptr<base::Value> value,
55 uint32_t flags) {
56 prefs_.SetValue(key, std::move(value));
57 }
58
59 void BlimpPrefStore::RemoveValue(const std::string& key, uint32_t flags) {
60 if (prefs_.RemoveValue(key))
61 ReportValueChanged(key, flags);
62 }
63
64 bool BlimpPrefStore::ReadOnly() const {
65 return false;
66 }
67
68 PersistentPrefStore::PrefReadError BlimpPrefStore::GetReadError() const {
69 return PersistentPrefStore::PREF_READ_ERROR_NONE;
70 }
71
72 PersistentPrefStore::PrefReadError BlimpPrefStore::ReadPrefs() {
73 return PersistentPrefStore::PREF_READ_ERROR_NONE;
74 }
75
76 void BlimpPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate_raw) {
77 }
78
79 void BlimpPrefStore::ReportValueChanged(const std::string& key,
80 uint32_t flags) {
81 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
82 }
83
84 } // namespace engine
85 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698