Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(833)

Side by Side Diff: components/prefs/testing_pref_store.cc

Issue 2444753002: Reduce usage of FOR_EACH_OBSERVER macro in components/ (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/prefs/pref_notifier_impl.cc ('k') | components/prefs/value_map_pref_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 void TestingPrefStore::CommitPendingWrite() { committed_ = true; } 93 void TestingPrefStore::CommitPendingWrite() { committed_ = true; }
94 94
95 void TestingPrefStore::SchedulePendingLossyWrites() {} 95 void TestingPrefStore::SchedulePendingLossyWrites() {}
96 96
97 void TestingPrefStore::SetInitializationCompleted() { 97 void TestingPrefStore::SetInitializationCompleted() {
98 NotifyInitializationCompleted(); 98 NotifyInitializationCompleted();
99 } 99 }
100 100
101 void TestingPrefStore::NotifyPrefValueChanged(const std::string& key) { 101 void TestingPrefStore::NotifyPrefValueChanged(const std::string& key) {
102 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); 102 for (Observer& observer : observers_)
103 observer.OnPrefValueChanged(key);
103 } 104 }
104 105
105 void TestingPrefStore::NotifyInitializationCompleted() { 106 void TestingPrefStore::NotifyInitializationCompleted() {
106 DCHECK(!init_complete_); 107 DCHECK(!init_complete_);
107 init_complete_ = true; 108 init_complete_ = true;
108 if (read_success_ && read_error_ != PREF_READ_ERROR_NONE && error_delegate_) 109 if (read_success_ && read_error_ != PREF_READ_ERROR_NONE && error_delegate_)
109 error_delegate_->OnError(read_error_); 110 error_delegate_->OnError(read_error_);
110 FOR_EACH_OBSERVER( 111 for (Observer& observer : observers_)
111 Observer, observers_, OnInitializationCompleted(read_success_)); 112 observer.OnInitializationCompleted(read_success_);
112 } 113 }
113 114
114 void TestingPrefStore::ReportValueChanged(const std::string& key, 115 void TestingPrefStore::ReportValueChanged(const std::string& key,
115 uint32_t flags) { 116 uint32_t flags) {
116 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); 117 for (Observer& observer : observers_)
118 observer.OnPrefValueChanged(key);
117 } 119 }
118 120
119 void TestingPrefStore::SetString(const std::string& key, 121 void TestingPrefStore::SetString(const std::string& key,
120 const std::string& value) { 122 const std::string& value) {
121 SetValue(key, base::MakeUnique<base::StringValue>(value), 123 SetValue(key, base::MakeUnique<base::StringValue>(value),
122 DEFAULT_PREF_WRITE_FLAGS); 124 DEFAULT_PREF_WRITE_FLAGS);
123 } 125 }
124 126
125 void TestingPrefStore::SetInteger(const std::string& key, int value) { 127 void TestingPrefStore::SetInteger(const std::string& key, int value) {
126 SetValue(key, base::MakeUnique<base::FundamentalValue>(value), 128 SetValue(key, base::MakeUnique<base::FundamentalValue>(value),
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 read_success_ = read_success; 179 read_success_ = read_success;
178 } 180 }
179 181
180 void TestingPrefStore::set_read_error( 182 void TestingPrefStore::set_read_error(
181 PersistentPrefStore::PrefReadError read_error) { 183 PersistentPrefStore::PrefReadError read_error) {
182 DCHECK(!init_complete_); 184 DCHECK(!init_complete_);
183 read_error_ = read_error; 185 read_error_ = read_error;
184 } 186 }
185 187
186 TestingPrefStore::~TestingPrefStore() {} 188 TestingPrefStore::~TestingPrefStore() {}
OLDNEW
« no previous file with comments | « components/prefs/pref_notifier_impl.cc ('k') | components/prefs/value_map_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698