Index: chrome/browser/policy/device_token_fetcher.cc |
diff --git a/chrome/browser/policy/device_token_fetcher.cc b/chrome/browser/policy/device_token_fetcher.cc |
index 1952747394c6fbb36c3c29e0147414f002e2f15f..602550fe8af063e5e2041a1a35ed3ba00790f6db 100644 |
--- a/chrome/browser/policy/device_token_fetcher.cc |
+++ b/chrome/browser/policy/device_token_fetcher.cc |
@@ -87,11 +87,25 @@ void DeviceTokenFetcher::OnError(DeviceManagementBackend::ErrorCode code) { |
if (code == DeviceManagementBackend::kErrorServiceManagementNotSupported) { |
device_token_ = std::string(); |
device_id_ = std::string(); |
- file_util::Delete(token_path_, false); |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, |
+ FROM_HERE, |
+ // The Windows compiler needs explicit template instantiation. |
+ NewRunnableFunction<bool(*)(const FilePath&, bool), FilePath, bool>( |
+ &file_util::Delete, token_path_, false)); |
+ SetState(kStateNotManaged); |
+ return; |
} |
SetState(kStateFailure); |
} |
+void DeviceTokenFetcher::Restart() { |
+ DCHECK(!IsTokenPending()); |
+ device_token_.clear(); |
+ device_token_load_complete_event_.Reset(); |
+ MakeReadyToRequestDeviceToken(); |
+} |
+ |
void DeviceTokenFetcher::StartFetching() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
if (state_ == kStateNotStarted) { |
@@ -186,12 +200,13 @@ void DeviceTokenFetcher::SetState(FetcherState state) { |
state_ = state; |
if (state == kStateFailure) { |
device_token_load_complete_event_.Signal(); |
+ NotifyTokenError(); |
+ } else if (state == kStateNotManaged) { |
+ device_token_load_complete_event_.Signal(); |
+ NotifyNotManaged(); |
} else if (state == kStateHasDeviceToken) { |
device_token_load_complete_event_.Signal(); |
- NotificationService::current()->Notify( |
- NotificationType::DEVICE_TOKEN_AVAILABLE, |
- Source<DeviceTokenFetcher>(this), |
- NotificationService::NoDetails()); |
+ NotifyTokenSuccess(); |
} |
} |