| 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/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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |