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 "base/prefs/testing_pref_store.h" | 5 #include "base/prefs/testing_pref_store.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 bool TestingPrefStore::HasObservers() const { | 39 bool TestingPrefStore::HasObservers() const { |
40 return observers_.might_have_observers(); | 40 return observers_.might_have_observers(); |
41 } | 41 } |
42 | 42 |
43 bool TestingPrefStore::IsInitializationComplete() const { | 43 bool TestingPrefStore::IsInitializationComplete() const { |
44 return init_complete_; | 44 return init_complete_; |
45 } | 45 } |
46 | 46 |
47 void TestingPrefStore::SetValue(const std::string& key, | 47 void TestingPrefStore::SetValue(const std::string& key, |
48 scoped_ptr<base::Value> value, | 48 scoped_ptr<base::Value> value, |
49 uint32 flags) { | 49 uint32_t flags) { |
50 if (prefs_.SetValue(key, std::move(value))) { | 50 if (prefs_.SetValue(key, std::move(value))) { |
51 committed_ = false; | 51 committed_ = false; |
52 NotifyPrefValueChanged(key); | 52 NotifyPrefValueChanged(key); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 void TestingPrefStore::SetValueSilently(const std::string& key, | 56 void TestingPrefStore::SetValueSilently(const std::string& key, |
57 scoped_ptr<base::Value> value, | 57 scoped_ptr<base::Value> value, |
58 uint32 flags) { | 58 uint32_t flags) { |
59 if (prefs_.SetValue(key, std::move(value))) | 59 if (prefs_.SetValue(key, std::move(value))) |
60 committed_ = false; | 60 committed_ = false; |
61 } | 61 } |
62 | 62 |
63 void TestingPrefStore::RemoveValue(const std::string& key, uint32 flags) { | 63 void TestingPrefStore::RemoveValue(const std::string& key, uint32_t flags) { |
64 if (prefs_.RemoveValue(key)) { | 64 if (prefs_.RemoveValue(key)) { |
65 committed_ = false; | 65 committed_ = false; |
66 NotifyPrefValueChanged(key); | 66 NotifyPrefValueChanged(key); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 bool TestingPrefStore::ReadOnly() const { | 70 bool TestingPrefStore::ReadOnly() const { |
71 return read_only_; | 71 return read_only_; |
72 } | 72 } |
73 | 73 |
(...skipping 30 matching lines...) Expand all Loading... |
104 void TestingPrefStore::NotifyInitializationCompleted() { | 104 void TestingPrefStore::NotifyInitializationCompleted() { |
105 DCHECK(!init_complete_); | 105 DCHECK(!init_complete_); |
106 init_complete_ = true; | 106 init_complete_ = true; |
107 if (read_success_ && read_error_ != PREF_READ_ERROR_NONE && error_delegate_) | 107 if (read_success_ && read_error_ != PREF_READ_ERROR_NONE && error_delegate_) |
108 error_delegate_->OnError(read_error_); | 108 error_delegate_->OnError(read_error_); |
109 FOR_EACH_OBSERVER( | 109 FOR_EACH_OBSERVER( |
110 Observer, observers_, OnInitializationCompleted(read_success_)); | 110 Observer, observers_, OnInitializationCompleted(read_success_)); |
111 } | 111 } |
112 | 112 |
113 void TestingPrefStore::ReportValueChanged(const std::string& key, | 113 void TestingPrefStore::ReportValueChanged(const std::string& key, |
114 uint32 flags) { | 114 uint32_t flags) { |
115 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); | 115 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); |
116 } | 116 } |
117 | 117 |
118 void TestingPrefStore::SetString(const std::string& key, | 118 void TestingPrefStore::SetString(const std::string& key, |
119 const std::string& value) { | 119 const std::string& value) { |
120 SetValue(key, make_scoped_ptr(new base::StringValue(value)), | 120 SetValue(key, make_scoped_ptr(new base::StringValue(value)), |
121 DEFAULT_PREF_WRITE_FLAGS); | 121 DEFAULT_PREF_WRITE_FLAGS); |
122 } | 122 } |
123 | 123 |
124 void TestingPrefStore::SetInteger(const std::string& key, int value) { | 124 void TestingPrefStore::SetInteger(const std::string& key, int value) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 read_success_ = read_success; | 172 read_success_ = read_success; |
173 } | 173 } |
174 | 174 |
175 void TestingPrefStore::set_read_error( | 175 void TestingPrefStore::set_read_error( |
176 PersistentPrefStore::PrefReadError read_error) { | 176 PersistentPrefStore::PrefReadError read_error) { |
177 DCHECK(!init_complete_); | 177 DCHECK(!init_complete_); |
178 read_error_ = read_error; | 178 read_error_ = read_error; |
179 } | 179 } |
180 | 180 |
181 TestingPrefStore::~TestingPrefStore() {} | 181 TestingPrefStore::~TestingPrefStore() {} |
OLD | NEW |