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

Side by Side Diff: chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc

Issue 19733003: Implement cloud policy invalidations using the invalidation service framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 FetchPolicyOAuthTokenUsingRefreshToken(); 141 FetchPolicyOAuthTokenUsingRefreshToken();
142 } 142 }
143 } 143 }
144 144
145 if (!wait_for_policy_fetch_) { 145 if (!wait_for_policy_fetch_) {
146 // If this isn't blocking on a policy fetch then 146 // If this isn't blocking on a policy fetch then
147 // CloudPolicyManager::OnStoreLoaded() already published the cached policy. 147 // CloudPolicyManager::OnStoreLoaded() already published the cached policy.
148 // Start the refresh scheduler now, which will eventually refresh the 148 // Start the refresh scheduler now, which will eventually refresh the
149 // cached policy or make the first fetch once the OAuth2 token is 149 // cached policy or make the first fetch once the OAuth2 token is
150 // available. 150 // available.
151 StartRefreshScheduler(); 151 StartRefreshSchedulerIfReady();
152 } 152 }
153 } 153 }
154 154
155 void UserCloudPolicyManagerChromeOS::OnPolicyFetched( 155 void UserCloudPolicyManagerChromeOS::OnPolicyFetched(
156 CloudPolicyClient* client) { 156 CloudPolicyClient* client) {
157 // No action required. If we're blocked on a policy fetch, we'll learn about 157 // No action required. If we're blocked on a policy fetch, we'll learn about
158 // completion of it through OnInitialPolicyFetchComplete(). 158 // completion of it through OnInitialPolicyFetchComplete().
159 } 159 }
160 160
161 void UserCloudPolicyManagerChromeOS::OnRegistrationStateChanged( 161 void UserCloudPolicyManagerChromeOS::OnRegistrationStateChanged(
(...skipping 19 matching lines...) Expand all
181 DCHECK_EQ(client(), cloud_policy_client); 181 DCHECK_EQ(client(), cloud_policy_client);
182 CancelWaitForPolicyFetch(); 182 CancelWaitForPolicyFetch();
183 } 183 }
184 184
185 void UserCloudPolicyManagerChromeOS::OnComponentCloudPolicyRefreshNeeded() { 185 void UserCloudPolicyManagerChromeOS::OnComponentCloudPolicyRefreshNeeded() {
186 core()->RefreshSoon(); 186 core()->RefreshSoon();
187 } 187 }
188 188
189 void UserCloudPolicyManagerChromeOS::OnComponentCloudPolicyUpdated() { 189 void UserCloudPolicyManagerChromeOS::OnComponentCloudPolicyUpdated() {
190 CheckAndPublishPolicy(); 190 CheckAndPublishPolicy();
191 StartRefreshScheduler(); 191 StartRefreshSchedulerIfReady();
192 } 192 }
193 193
194 void UserCloudPolicyManagerChromeOS::FetchPolicyOAuthTokenUsingSigninProfile() { 194 void UserCloudPolicyManagerChromeOS::FetchPolicyOAuthTokenUsingSigninProfile() {
195 scoped_refptr<net::URLRequestContextGetter> signin_context; 195 scoped_refptr<net::URLRequestContextGetter> signin_context;
196 Profile* signin_profile = chromeos::ProfileHelper::GetSigninProfile(); 196 Profile* signin_profile = chromeos::ProfileHelper::GetSigninProfile();
197 if (signin_profile) 197 if (signin_profile)
198 signin_context = signin_profile->GetRequestContext(); 198 signin_context = signin_profile->GetRequestContext();
199 if (!signin_context.get()) { 199 if (!signin_context.get()) {
200 LOG(ERROR) << "No signin Profile for policy oauth token fetch!"; 200 LOG(ERROR) << "No signin Profile for policy oauth token fetch!";
201 OnOAuth2PolicyTokenFetched( 201 OnOAuth2PolicyTokenFetched(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 void UserCloudPolicyManagerChromeOS::OnInitialPolicyFetchComplete( 245 void UserCloudPolicyManagerChromeOS::OnInitialPolicyFetchComplete(
246 bool success) { 246 bool success) {
247 CancelWaitForPolicyFetch(); 247 CancelWaitForPolicyFetch();
248 } 248 }
249 249
250 void UserCloudPolicyManagerChromeOS::CancelWaitForPolicyFetch() { 250 void UserCloudPolicyManagerChromeOS::CancelWaitForPolicyFetch() {
251 wait_for_policy_fetch_ = false; 251 wait_for_policy_fetch_ = false;
252 CheckAndPublishPolicy(); 252 CheckAndPublishPolicy();
253 // Now that |wait_for_policy_fetch_| is guaranteed to be false, the scheduler 253 // Now that |wait_for_policy_fetch_| is guaranteed to be false, the scheduler
254 // can be started. 254 // can be started.
255 StartRefreshScheduler(); 255 StartRefreshSchedulerIfReady();
256 } 256 }
257 257
258 void UserCloudPolicyManagerChromeOS::StartRefreshScheduler() { 258 void UserCloudPolicyManagerChromeOS::StartRefreshSchedulerIfReady() {
259 if (core()->refresh_scheduler()) 259 if (core()->refresh_scheduler())
260 return; // Already started. 260 return; // Already started.
261 261
262 if (wait_for_policy_fetch_) 262 if (wait_for_policy_fetch_)
263 return; // Still waiting for the initial, blocking fetch. 263 return; // Still waiting for the initial, blocking fetch.
264 264
265 if (!service() || !local_state_) 265 if (!service() || !local_state_)
266 return; // Not connected. 266 return; // Not connected.
267 267
268 if (component_policy_service_ && 268 if (component_policy_service_ &&
269 !component_policy_service_->is_initialized()) { 269 !component_policy_service_->is_initialized()) {
270 // If the client doesn't have the list of components to fetch yet then don't 270 // If the client doesn't have the list of components to fetch yet then don't
271 // start the scheduler. The |component_policy_service_| will call back into 271 // start the scheduler. The |component_policy_service_| will call back into
272 // OnComponentCloudPolicyUpdated() once it's ready. 272 // OnComponentCloudPolicyUpdated() once it's ready.
273 return; 273 return;
274 } 274 }
275 275
276 core()->StartRefreshScheduler(); 276 StartRefreshScheduler();
277 core()->TrackRefreshDelayPref(local_state_, prefs::kUserPolicyRefreshRate); 277 core()->TrackRefreshDelayPref(local_state_, prefs::kUserPolicyRefreshRate);
278 } 278 }
279 279
280 } // namespace policy 280 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698