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 |
27 bool TestingPrefStore::GetMutableValue(const std::string& key, | 31 bool TestingPrefStore::GetMutableValue(const std::string& key, |
28 base::Value** value) { | 32 base::Value** value) { |
29 return prefs_.GetValue(key, value); | 33 return prefs_.GetValue(key, value); |
30 } | 34 } |
31 | 35 |
32 void TestingPrefStore::AddObserver(PrefStore::Observer* observer) { | 36 void TestingPrefStore::AddObserver(PrefStore::Observer* observer) { |
33 observers_.AddObserver(observer); | 37 observers_.AddObserver(observer); |
34 } | 38 } |
35 | 39 |
36 void TestingPrefStore::RemoveObserver(PrefStore::Observer* observer) { | 40 void TestingPrefStore::RemoveObserver(PrefStore::Observer* observer) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 read_success_ = read_success; | 183 read_success_ = read_success; |
180 } | 184 } |
181 | 185 |
182 void TestingPrefStore::set_read_error( | 186 void TestingPrefStore::set_read_error( |
183 PersistentPrefStore::PrefReadError read_error) { | 187 PersistentPrefStore::PrefReadError read_error) { |
184 DCHECK(!init_complete_); | 188 DCHECK(!init_complete_); |
185 read_error_ = read_error; | 189 read_error_ = read_error; |
186 } | 190 } |
187 | 191 |
188 TestingPrefStore::~TestingPrefStore() {} | 192 TestingPrefStore::~TestingPrefStore() {} |
OLD | NEW |