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

Side by Side Diff: components/policy/core/common/cloud/cloud_policy_service.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/cloud/cloud_policy_service.h" 5 #include "components/policy/core/common/cloud/cloud_policy_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 void CloudPolicyService::OnStoreError(CloudPolicyStore* store) { 150 void CloudPolicyService::OnStoreError(CloudPolicyStore* store) {
151 if (refresh_state_ == REFRESH_POLICY_STORE) 151 if (refresh_state_ == REFRESH_POLICY_STORE)
152 RefreshCompleted(false); 152 RefreshCompleted(false);
153 CheckInitializationCompleted(); 153 CheckInitializationCompleted();
154 } 154 }
155 155
156 void CloudPolicyService::CheckInitializationCompleted() { 156 void CloudPolicyService::CheckInitializationCompleted() {
157 if (!IsInitializationComplete() && store_->is_initialized()) { 157 if (!IsInitializationComplete() && store_->is_initialized()) {
158 initialization_complete_ = true; 158 initialization_complete_ = true;
159 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(this)); 159 for (auto& observer : observers_)
160 observer.OnInitializationCompleted(this);
160 } 161 }
161 } 162 }
162 163
163 void CloudPolicyService::RefreshCompleted(bool success) { 164 void CloudPolicyService::RefreshCompleted(bool success) {
164 // Clear state and |refresh_callbacks_| before actually invoking them, s.t. 165 // Clear state and |refresh_callbacks_| before actually invoking them, s.t.
165 // triggering new policy fetches behaves as expected. 166 // triggering new policy fetches behaves as expected.
166 std::vector<RefreshPolicyCallback> callbacks; 167 std::vector<RefreshPolicyCallback> callbacks;
167 callbacks.swap(refresh_callbacks_); 168 callbacks.swap(refresh_callbacks_);
168 refresh_state_ = REFRESH_NONE; 169 refresh_state_ = REFRESH_NONE;
169 170
(...skipping 15 matching lines...) Expand all
185 186
186 void CloudPolicyService::AddObserver(Observer* observer) { 187 void CloudPolicyService::AddObserver(Observer* observer) {
187 observers_.AddObserver(observer); 188 observers_.AddObserver(observer);
188 } 189 }
189 190
190 void CloudPolicyService::RemoveObserver(Observer* observer) { 191 void CloudPolicyService::RemoveObserver(Observer* observer) {
191 observers_.RemoveObserver(observer); 192 observers_.RemoveObserver(observer);
192 } 193 }
193 194
194 } // namespace policy 195 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_core.cc ('k') | components/policy/core/common/cloud/cloud_policy_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698