Commit 96a2458c authored by mnissler@chromium.org's avatar mnissler@chromium.org

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
parent 9d032be5
......@@ -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() {
......
......@@ -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, &timestamp, true))
set_last_policy_refresh_time(timestamp);
}
// static
......
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment