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