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