| 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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 DCHECK(!init_complete_); | 176 DCHECK(!init_complete_); |
| 177 block_async_read_ = block_async_read; | 177 block_async_read_ = block_async_read; |
| 178 if (pending_async_read_ && !block_async_read_) | 178 if (pending_async_read_ && !block_async_read_) |
| 179 NotifyInitializationCompleted(); | 179 NotifyInitializationCompleted(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void TestingPrefStore::ClearMutableValues() { | 182 void TestingPrefStore::ClearMutableValues() { |
| 183 NOTIMPLEMENTED(); | 183 NOTIMPLEMENTED(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void TestingPrefStore::OnStoreDeletionFromDisk() {} |
| 187 |
| 186 void TestingPrefStore::set_read_only(bool read_only) { | 188 void TestingPrefStore::set_read_only(bool read_only) { |
| 187 read_only_ = read_only; | 189 read_only_ = read_only; |
| 188 } | 190 } |
| 189 | 191 |
| 190 void TestingPrefStore::set_read_success(bool read_success) { | 192 void TestingPrefStore::set_read_success(bool read_success) { |
| 191 DCHECK(!init_complete_); | 193 DCHECK(!init_complete_); |
| 192 read_success_ = read_success; | 194 read_success_ = read_success; |
| 193 } | 195 } |
| 194 | 196 |
| 195 void TestingPrefStore::set_read_error( | 197 void TestingPrefStore::set_read_error( |
| 196 PersistentPrefStore::PrefReadError read_error) { | 198 PersistentPrefStore::PrefReadError read_error) { |
| 197 DCHECK(!init_complete_); | 199 DCHECK(!init_complete_); |
| 198 read_error_ = read_error; | 200 read_error_ = read_error; |
| 199 } | 201 } |
| 200 | 202 |
| 201 TestingPrefStore::~TestingPrefStore() { | 203 TestingPrefStore::~TestingPrefStore() { |
| 202 for (auto& pref : prefs_) { | 204 for (auto& pref : prefs_) { |
| 203 CheckPrefIsSerializable(pref.first, *pref.second); | 205 CheckPrefIsSerializable(pref.first, *pref.second); |
| 204 } | 206 } |
| 205 } | 207 } |
| 206 | 208 |
| 207 void TestingPrefStore::CheckPrefIsSerializable(const std::string& key, | 209 void TestingPrefStore::CheckPrefIsSerializable(const std::string& key, |
| 208 const base::Value& value) { | 210 const base::Value& value) { |
| 209 std::string json; | 211 std::string json; |
| 210 EXPECT_TRUE(base::JSONWriter::Write(value, &json)) | 212 EXPECT_TRUE(base::JSONWriter::Write(value, &json)) |
| 211 << "Pref \"" << key << "\" is not serializable as JSON."; | 213 << "Pref \"" << key << "\" is not serializable as JSON."; |
| 212 } | 214 } |
| OLD | NEW |