1 // Copyright 2015 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.
5 #include "components/cronet/android/cronet_in_memory_pref_store.h"
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
10 CronetInMemoryPrefStore::CronetInMemoryPrefStore() {}
12 CronetInMemoryPrefStore::~CronetInMemoryPrefStore() {}
14 bool CronetInMemoryPrefStore::GetValue(const std::string
& key
,
15 const base::Value
** value
) const {
16 return prefs_
.GetValue(key
, value
);
19 bool CronetInMemoryPrefStore::GetMutableValue(const std::string
& key
,
20 base::Value
** value
) {
21 return prefs_
.GetValue(key
, value
);
24 void CronetInMemoryPrefStore::AddObserver(PrefStore::Observer
* observer
) {
25 observers_
.AddObserver(observer
);
28 void CronetInMemoryPrefStore::RemoveObserver(PrefStore::Observer
* observer
) {
29 observers_
.RemoveObserver(observer
);
32 bool CronetInMemoryPrefStore::HasObservers() const {
33 return observers_
.might_have_observers();
36 bool CronetInMemoryPrefStore::IsInitializationComplete() const {
40 void CronetInMemoryPrefStore::SetValue(
41 const std::string
& key
, base::Value
* value
, uint32 flags
) {
43 if (prefs_
.SetValue(key
, value
))
44 ReportValueChanged(key
, flags
);
47 void CronetInMemoryPrefStore::SetValueSilently(const std::string
& key
,
50 prefs_
.SetValue(key
, value
);
53 void CronetInMemoryPrefStore::RemoveValue(const std::string
& key
,
55 if (prefs_
.RemoveValue(key
))
56 ReportValueChanged(key
, flags
);
59 bool CronetInMemoryPrefStore::ReadOnly() const {
63 PersistentPrefStore::PrefReadError
64 CronetInMemoryPrefStore::GetReadError() const {
65 return PersistentPrefStore::PREF_READ_ERROR_NONE
;
68 PersistentPrefStore::PrefReadError
CronetInMemoryPrefStore::ReadPrefs() {
69 return PersistentPrefStore::PREF_READ_ERROR_NONE
;
72 void CronetInMemoryPrefStore::ReadPrefsAsync(
73 ReadErrorDelegate
* error_delegate_raw
) {
76 void CronetInMemoryPrefStore::ReportValueChanged(const std::string
& key
,
78 FOR_EACH_OBSERVER(Observer
, observers_
, OnPrefValueChanged(key
));