OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/prefs/testing_pref_store.h" | 5 #include "components/prefs/testing_pref_store.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 | 12 |
13 TestingPrefStore::TestingPrefStore() | 13 TestingPrefStore::TestingPrefStore() |
14 : read_only_(true), | 14 : read_only_(true), |
15 read_success_(true), | 15 read_success_(true), |
16 read_error_(PersistentPrefStore::PREF_READ_ERROR_NONE), | 16 read_error_(PersistentPrefStore::PREF_READ_ERROR_NONE), |
17 block_async_read_(false), | 17 block_async_read_(false), |
18 pending_async_read_(false), | 18 pending_async_read_(false), |
19 init_complete_(false), | 19 init_complete_(false), |
20 committed_(true) {} | 20 committed_(true) {} |
21 | 21 |
22 bool TestingPrefStore::GetValue(const std::string& key, | 22 bool TestingPrefStore::GetValue(const std::string& key, |
23 const base::Value** value) const { | 23 const base::Value** value) const { |
24 return prefs_.GetValue(key, value); | 24 return prefs_.GetValue(key, value); |
25 } | 25 } |
26 | 26 |
27 std::unique_ptr<base::DictionaryValue> TestingPrefStore::GetValues() const { | |
28 return prefs_.AsDictionaryValue(); | |
29 } | |
30 | |
31 bool TestingPrefStore::GetMutableValue(const std::string& key, | 27 bool TestingPrefStore::GetMutableValue(const std::string& key, |
32 base::Value** value) { | 28 base::Value** value) { |
33 return prefs_.GetValue(key, value); | 29 return prefs_.GetValue(key, value); |
34 } | 30 } |
35 | 31 |
36 void TestingPrefStore::AddObserver(PrefStore::Observer* observer) { | 32 void TestingPrefStore::AddObserver(PrefStore::Observer* observer) { |
37 observers_.AddObserver(observer); | 33 observers_.AddObserver(observer); |
38 } | 34 } |
39 | 35 |
40 void TestingPrefStore::RemoveObserver(PrefStore::Observer* observer) { | 36 void TestingPrefStore::RemoveObserver(PrefStore::Observer* observer) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 read_success_ = read_success; | 179 read_success_ = read_success; |
184 } | 180 } |
185 | 181 |
186 void TestingPrefStore::set_read_error( | 182 void TestingPrefStore::set_read_error( |
187 PersistentPrefStore::PrefReadError read_error) { | 183 PersistentPrefStore::PrefReadError read_error) { |
188 DCHECK(!init_complete_); | 184 DCHECK(!init_complete_); |
189 read_error_ = read_error; | 185 read_error_ = read_error; |
190 } | 186 } |
191 | 187 |
192 TestingPrefStore::~TestingPrefStore() {} | 188 TestingPrefStore::~TestingPrefStore() {} |
OLD | NEW |