| 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" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 observer.OnPrefValueChanged(key); | 118 observer.OnPrefValueChanged(key); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void TestingPrefStore::SetString(const std::string& key, | 121 void TestingPrefStore::SetString(const std::string& key, |
| 122 const std::string& value) { | 122 const std::string& value) { |
| 123 SetValue(key, base::MakeUnique<base::StringValue>(value), | 123 SetValue(key, base::MakeUnique<base::StringValue>(value), |
| 124 DEFAULT_PREF_WRITE_FLAGS); | 124 DEFAULT_PREF_WRITE_FLAGS); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void TestingPrefStore::SetInteger(const std::string& key, int value) { | 127 void TestingPrefStore::SetInteger(const std::string& key, int value) { |
| 128 SetValue(key, base::MakeUnique<base::FundamentalValue>(value), | 128 SetValue(key, base::MakeUnique<base::Value>(value), |
| 129 DEFAULT_PREF_WRITE_FLAGS); | 129 DEFAULT_PREF_WRITE_FLAGS); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void TestingPrefStore::SetBoolean(const std::string& key, bool value) { | 132 void TestingPrefStore::SetBoolean(const std::string& key, bool value) { |
| 133 SetValue(key, base::MakeUnique<base::FundamentalValue>(value), | 133 SetValue(key, base::MakeUnique<base::Value>(value), |
| 134 DEFAULT_PREF_WRITE_FLAGS); | 134 DEFAULT_PREF_WRITE_FLAGS); |
| 135 } | 135 } |
| 136 | 136 |
| 137 bool TestingPrefStore::GetString(const std::string& key, | 137 bool TestingPrefStore::GetString(const std::string& key, |
| 138 std::string* value) const { | 138 std::string* value) const { |
| 139 const base::Value* stored_value; | 139 const base::Value* stored_value; |
| 140 if (!prefs_.GetValue(key, &stored_value) || !stored_value) | 140 if (!prefs_.GetValue(key, &stored_value) || !stored_value) |
| 141 return false; | 141 return false; |
| 142 | 142 |
| 143 return stored_value->GetAsString(value); | 143 return stored_value->GetAsString(value); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 read_success_ = read_success; | 179 read_success_ = read_success; |
| 180 } | 180 } |
| 181 | 181 |
| 182 void TestingPrefStore::set_read_error( | 182 void TestingPrefStore::set_read_error( |
| 183 PersistentPrefStore::PrefReadError read_error) { | 183 PersistentPrefStore::PrefReadError read_error) { |
| 184 DCHECK(!init_complete_); | 184 DCHECK(!init_complete_); |
| 185 read_error_ = read_error; | 185 read_error_ = read_error; |
| 186 } | 186 } |
| 187 | 187 |
| 188 TestingPrefStore::~TestingPrefStore() {} | 188 TestingPrefStore::~TestingPrefStore() {} |
| OLD | NEW |