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..e6fb7c8b5eb0e628a8fa30451bc1977fbd5c298a 100644 |
--- a/chrome/browser/policy/device_token_fetcher.cc |
+++ b/chrome/browser/policy/device_token_fetcher.cc |
@@ -87,11 +87,21 @@ 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, |
+ NewRunnableFunction(&file_util::Delete, token_path_, false)); |
} |
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 +196,10 @@ void DeviceTokenFetcher::SetState(FetcherState state) { |
state_ = state; |
if (state == kStateFailure) { |
device_token_load_complete_event_.Signal(); |
+ NotifyTokenError(); |
} else if (state == kStateHasDeviceToken) { |
device_token_load_complete_event_.Signal(); |
- NotificationService::current()->Notify( |
- NotificationType::DEVICE_TOKEN_AVAILABLE, |
- Source<DeviceTokenFetcher>(this), |
- NotificationService::NoDetails()); |
+ NotifyTokenSuccess(); |
} |
} |