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

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: fix build on Win; fix behavior for unmanaged devices 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..11b923f4741ba1663abec9ccd4bb25bebe3c5c6e 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);
+ // This line is necessary to work around Windows compiler weirdness.
danno 2010/11/23 12:10:14 Perhaps something more specific like: Without the
Jakob Kummerow (corp) 2010/11/23 12:25:26 Done. I changed the whole workaround to a solution
+ bool (*delete_function) (const FilePath&, bool) = &file_util::Delete;
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ NewRunnableFunction(delete_function, 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();
}
}

Powered by Google App Engine
This is Rietveld 408576698