diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-02 13:45:06 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-02 13:45:06 +0000 |
commit | 96a2458cfe2e5d27e32c8b81db8257eaae0073ae (patch) | |
tree | 0e27ef25294861277eb5ec0959125e6974db8a01 /chrome | |
parent | 9d032be5235749c3a13498e99a24bd24879c89ba (diff) | |
download | chromium_src-96a2458cfe2e5d27e32c8b81db8257eaae0073ae.zip chromium_src-96a2458cfe2e5d27e32c8b81db8257eaae0073ae.tar.gz chromium_src-96a2458cfe2e5d27e32c8b81db8257eaae0073ae.tar.bz2 |
Clean up error handling and timestamp initialization for cloud policy.
BUG=chromium-os:23685
TEST=See bug.
Review URL: http://codereview.chromium.org/8773034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/policy/cloud_policy_controller.cc | 15 | ||||
-rw-r--r-- | chrome/browser/policy/device_policy_cache.cc | 4 | ||||
-rw-r--r-- | chrome/browser/policy/device_token_fetcher.cc | 17 |
3 files changed, 24 insertions, 12 deletions
diff --git a/chrome/browser/policy/cloud_policy_controller.cc b/chrome/browser/policy/cloud_policy_controller.cc index 346f593..93f450e 100644 --- a/chrome/browser/policy/cloud_policy_controller.cc +++ b/chrome/browser/policy/cloud_policy_controller.cc @@ -139,19 +139,19 @@ void CloudPolicyController::OnError(DeviceManagementBackend::ErrorCode code) { << "device manager, re-registering device."; // Will retry fetching a token but gracefully backing off. SetState(STATE_TOKEN_ERROR); - break; + return; } case DeviceManagementBackend::kErrorServiceInvalidSerialNumber: { VLOG(1) << "The device is no longer enlisted for the domain."; token_fetcher_->SetSerialNumberInvalidState(); SetState(STATE_TOKEN_ERROR); - break; + return; } case DeviceManagementBackend::kErrorServiceManagementNotSupported: { VLOG(1) << "The device is no longer managed."; token_fetcher_->SetUnmanagedState(); SetState(STATE_TOKEN_UNMANAGED); - break; + return; } case DeviceManagementBackend::kErrorServicePolicyNotFound: case DeviceManagementBackend::kErrorRequestInvalid: @@ -161,17 +161,20 @@ void CloudPolicyController::OnError(DeviceManagementBackend::ErrorCode code) { VLOG(1) << "An error in the communication with the policy server occurred" << ", will retry in a few hours."; SetState(STATE_POLICY_UNAVAILABLE); - break; + return; } case DeviceManagementBackend::kErrorRequestFailed: case DeviceManagementBackend::kErrorTemporaryUnavailable: { VLOG(1) << "A temporary error in the communication with the policy server" << " occurred."; - } - default: // Will retry last operation but gracefully backing off. SetState(STATE_POLICY_ERROR); + return; + } } + + NOTREACHED(); + SetState(STATE_POLICY_ERROR); } void CloudPolicyController::OnDeviceTokenChanged() { diff --git a/chrome/browser/policy/device_policy_cache.cc b/chrome/browser/policy/device_policy_cache.cc index 818e233..f96a722 100644 --- a/chrome/browser/policy/device_policy_cache.cc +++ b/chrome/browser/policy/device_policy_cache.cc @@ -303,7 +303,9 @@ void DevicePolicyCache::InstallInitialPolicy( data_store_->set_user_name(policy_data.username()); data_store_->set_device_id(policy_data.device_id()); *device_token = policy_data.request_token(); - SetPolicyInternal(policy, NULL, false); + base::Time timestamp; + if (SetPolicyInternal(policy, ×tamp, true)) + set_last_policy_refresh_time(timestamp); } // static diff --git a/chrome/browser/policy/device_token_fetcher.cc b/chrome/browser/policy/device_token_fetcher.cc index e96b4fb..540c4df 100644 --- a/chrome/browser/policy/device_token_fetcher.cc +++ b/chrome/browser/policy/device_token_fetcher.cc @@ -119,24 +119,31 @@ void DeviceTokenFetcher::OnError(DeviceManagementBackend::ErrorCode code) { switch (code) { case DeviceManagementBackend::kErrorServiceManagementNotSupported: SetUnmanagedState(); - break; + return; case DeviceManagementBackend::kErrorRequestFailed: case DeviceManagementBackend::kErrorTemporaryUnavailable: case DeviceManagementBackend::kErrorServiceDeviceNotFound: case DeviceManagementBackend::kErrorServiceDeviceIdConflict: SetState(STATE_TEMPORARY_ERROR); - break; + return; case DeviceManagementBackend::kErrorServiceManagementTokenInvalid: // Most probably the GAIA auth cookie has expired. We can not do anything // until the user logs-in again. SetState(STATE_BAD_AUTH); - break; + return; case DeviceManagementBackend::kErrorServiceInvalidSerialNumber: SetSerialNumberInvalidState(); - break; - default: + return; + case DeviceManagementBackend::kErrorRequestInvalid: + case DeviceManagementBackend::kErrorHttpStatus: + case DeviceManagementBackend::kErrorResponseDecoding: + case DeviceManagementBackend::kErrorServiceActivationPending: + case DeviceManagementBackend::kErrorServicePolicyNotFound: SetState(STATE_ERROR); + return; } + NOTREACHED(); + SetState(STATE_ERROR); } void DeviceTokenFetcher::Initialize(DeviceManagementService* service, |