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

Side by Side Diff: components/policy/core/common/policy_service_impl.cc

Issue 2422083002: Remove usage of FOR_EACH_OBSERVER macro in components/policy (Closed)
Patch Set: Created 4 years, 2 months 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
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/policy/core/common/policy_service_impl.h" 5 #include "components/policy/core/common/policy_service_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 update_task_ptr_factory_.GetWeakPtr())); 180 update_task_ptr_factory_.GetWeakPtr()));
181 } 181 }
182 182
183 void PolicyServiceImpl::NotifyNamespaceUpdated( 183 void PolicyServiceImpl::NotifyNamespaceUpdated(
184 const PolicyNamespace& ns, 184 const PolicyNamespace& ns,
185 const PolicyMap& previous, 185 const PolicyMap& previous,
186 const PolicyMap& current) { 186 const PolicyMap& current) {
187 DCHECK(thread_checker_.CalledOnValidThread()); 187 DCHECK(thread_checker_.CalledOnValidThread());
188 ObserverMap::iterator iterator = observers_.find(ns.domain); 188 ObserverMap::iterator iterator = observers_.find(ns.domain);
189 if (iterator != observers_.end()) { 189 if (iterator != observers_.end()) {
190 FOR_EACH_OBSERVER(PolicyService::Observer, 190 for (auto& observer : *iterator->second)
191 *iterator->second, 191 observer.OnPolicyUpdated(ns, previous, current);
192 OnPolicyUpdated(ns, previous, current));
193 } 192 }
194 } 193 }
195 194
196 void PolicyServiceImpl::MergeAndTriggerUpdates() { 195 void PolicyServiceImpl::MergeAndTriggerUpdates() {
197 // Merge from each provider in their order of priority. 196 // Merge from each provider in their order of priority.
198 const PolicyNamespace chrome_namespace(POLICY_DOMAIN_CHROME, std::string()); 197 const PolicyNamespace chrome_namespace(POLICY_DOMAIN_CHROME, std::string());
199 PolicyBundle bundle; 198 PolicyBundle bundle;
200 for (Iterator it = providers_.begin(); it != providers_.end(); ++it) { 199 for (Iterator it = providers_.begin(); it != providers_.end(); ++it) {
201 PolicyBundle provided_bundle; 200 PolicyBundle provided_bundle;
202 provided_bundle.CopyFrom((*it)->policies()); 201 provided_bundle.CopyFrom((*it)->policies());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 for (Iterator it = providers_.begin(); it != providers_.end(); ++it) { 259 for (Iterator it = providers_.begin(); it != providers_.end(); ++it) {
261 if (!(*it)->IsInitializationComplete(policy_domain)) { 260 if (!(*it)->IsInitializationComplete(policy_domain)) {
262 all_complete = false; 261 all_complete = false;
263 break; 262 break;
264 } 263 }
265 } 264 }
266 if (all_complete) { 265 if (all_complete) {
267 initialization_complete_[domain] = true; 266 initialization_complete_[domain] = true;
268 ObserverMap::iterator iter = observers_.find(policy_domain); 267 ObserverMap::iterator iter = observers_.find(policy_domain);
269 if (iter != observers_.end()) { 268 if (iter != observers_.end()) {
270 FOR_EACH_OBSERVER(PolicyService::Observer, 269 for (auto& observer : *iter->second)
271 *iter->second, 270 observer.OnPolicyServiceInitialized(policy_domain);
272 OnPolicyServiceInitialized(policy_domain));
273 } 271 }
274 } 272 }
275 } 273 }
276 } 274 }
277 275
278 void PolicyServiceImpl::CheckRefreshComplete() { 276 void PolicyServiceImpl::CheckRefreshComplete() {
279 // Invoke all the callbacks if a refresh has just fully completed. 277 // Invoke all the callbacks if a refresh has just fully completed.
280 if (refresh_pending_.empty() && !refresh_callbacks_.empty()) { 278 if (refresh_pending_.empty() && !refresh_callbacks_.empty()) {
281 std::vector<base::Closure> callbacks; 279 std::vector<base::Closure> callbacks;
282 callbacks.swap(refresh_callbacks_); 280 callbacks.swap(refresh_callbacks_);
283 std::vector<base::Closure>::iterator it; 281 std::vector<base::Closure>::iterator it;
284 for (it = callbacks.begin(); it != callbacks.end(); ++it) 282 for (it = callbacks.begin(); it != callbacks.end(); ++it)
285 it->Run(); 283 it->Run();
286 } 284 }
287 } 285 }
288 286
289 } // namespace policy 287 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698