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

Side by Side Diff: chrome/browser/policy/device_token_fetcher.cc

Issue 8499021: UserPolicyCache only becomes ready after policy has been fetched. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/policy/device_token_fetcher.h" 5 #include "chrome/browser/policy/device_token_fetcher.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 break; 217 break;
218 } 218 }
219 219
220 scheduler_->CancelDelayedWork(); 220 scheduler_->CancelDelayedWork();
221 if (!delayed_work_at.is_null()) { 221 if (!delayed_work_at.is_null()) {
222 base::Time now(base::Time::Now()); 222 base::Time now(base::Time::Now());
223 int64 delay = std::max<int64>((delayed_work_at - now).InMilliseconds(), 0); 223 int64 delay = std::max<int64>((delayed_work_at - now).InMilliseconds(), 0);
224 scheduler_->PostDelayedWork( 224 scheduler_->PostDelayedWork(
225 base::Bind(&DeviceTokenFetcher::DoWork, base::Unretained(this)), delay); 225 base::Bind(&DeviceTokenFetcher::DoWork, base::Unretained(this)), delay);
226 } 226 }
227
228 // Inform the cache if a token fetch attempt has failed.
229 if (state_ != STATE_INACTIVE && state_ != STATE_TOKEN_AVAILABLE)
230 cache_->SetFetchingDone();
227 } 231 }
228 232
229 void DeviceTokenFetcher::DoWork() { 233 void DeviceTokenFetcher::DoWork() {
230 switch (state_) { 234 switch (state_) {
231 case STATE_INACTIVE: 235 case STATE_INACTIVE:
232 case STATE_TOKEN_AVAILABLE: 236 case STATE_TOKEN_AVAILABLE:
233 case STATE_BAD_SERIAL: 237 case STATE_BAD_SERIAL:
234 break; 238 break;
235 case STATE_UNMANAGED: 239 case STATE_UNMANAGED:
236 case STATE_ERROR: 240 case STATE_ERROR:
237 case STATE_TEMPORARY_ERROR: 241 case STATE_TEMPORARY_ERROR:
238 case STATE_BAD_AUTH: 242 case STATE_BAD_AUTH:
239 FetchTokenInternal(); 243 FetchTokenInternal();
240 break; 244 break;
241 } 245 }
242 } 246 }
243 247
244 } // namespace policy 248 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698