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

Unified Diff: chrome/browser/policy/device_token_fetcher.cc

Issue 5219006: Refresh policies from DM server periodically (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 10 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 side-by-side diff with in-line comments
Download patch
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();
}
}
« no previous file with comments | « chrome/browser/policy/device_token_fetcher.h ('k') | chrome/browser/policy/device_token_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698