| Index: components/policy/core/common/cloud/device_management_service.cc
|
| diff --git a/components/policy/core/common/cloud/device_management_service.cc b/components/policy/core/common/cloud/device_management_service.cc
|
| index 7061e6f3661bff2270b26f61593b287d5ddb3c05..8d632fb32e776165d0a76af963e8e74e8d29e907 100644
|
| --- a/components/policy/core/common/cloud/device_management_service.cc
|
| +++ b/components/policy/core/common/cloud/device_management_service.cc
|
| @@ -184,6 +184,9 @@ class DeviceManagementRequestJobImpl : public DeviceManagementRequestJob {
|
| // Invoked right before retrying this job.
|
| void PrepareRetry();
|
|
|
| + // Returns whether the retry should happen after a delay.
|
| + bool IsRetryWithDelay() { return retry_with_delay_; }
|
| +
|
| // Number of times that this job has been retried due to connection errors.
|
| int retries_count() { return retries_count_; }
|
|
|
| @@ -206,6 +209,9 @@ class DeviceManagementRequestJobImpl : public DeviceManagementRequestJob {
|
| // Whether the BYPASS_PROXY flag should be set by ConfigureRequest().
|
| bool bypass_proxy_;
|
|
|
| + // Whether the retry should happen after a delay.
|
| + bool retry_with_delay_;
|
| +
|
| // Number of times that this job has been retried due to connection errors.
|
| int retries_count_;
|
|
|
| @@ -355,6 +361,7 @@ bool DeviceManagementRequestJobImpl::ShouldRetry(
|
| // Retry the job if it failed due to a broken proxy, by bypassing the
|
| // proxy on the next try.
|
| bypass_proxy_ = true;
|
| + retry_with_delay_ = false;
|
| return true;
|
| }
|
|
|
| @@ -362,8 +369,10 @@ bool DeviceManagementRequestJobImpl::ShouldRetry(
|
| // often interrupted during ChromeOS startup when network is not yet ready.
|
| // Allowing the fetcher to retry once after that is enough to recover; allow
|
| // it to retry up to 3 times just in case.
|
| - if (IsConnectionError(fetcher->GetStatus()) && retries_count_ < kMaxRetries) {
|
| + if (IsConnectionError(fetcher->GetStatus()) && retries_count_ < kMaxRetries &&
|
| + type_ != DeviceManagementRequestJob::TYPE_POLICY_FETCH) {
|
| ++retries_count_;
|
| + retry_with_delay_ = true;
|
| return true;
|
| }
|
|
|
| @@ -407,7 +416,8 @@ em::DeviceManagementRequest* DeviceManagementRequestJob::GetRequest() {
|
| DeviceManagementRequestJob::DeviceManagementRequestJob(
|
| JobType type,
|
| const std::string& agent_parameter,
|
| - const std::string& platform_parameter) {
|
| + const std::string& platform_parameter)
|
| + : type_(type) {
|
| AddParameter(dm_protocol::kParamRequest, JobTypeToRequestType(type));
|
| AddParameter(dm_protocol::kParamDeviceType, dm_protocol::kValueDeviceType);
|
| AddParameter(dm_protocol::kParamAppType, dm_protocol::kValueAppType);
|
| @@ -544,7 +554,9 @@ void DeviceManagementService::OnURLFetchComplete(
|
|
|
| if (job->ShouldRetry(source)) {
|
| job->PrepareRetry();
|
| - int delay = g_retry_delay_ms << (job->retries_count() - 1);
|
| + int delay = job->IsRetryWithDelay()
|
| + ? g_retry_delay_ms << (job->retries_count() - 1)
|
| + : 0;
|
| LOG(WARNING) << "Dmserver request failed, retrying in " << delay / 1000
|
| << "s.";
|
| task_runner_->PostDelayedTask(
|
|
|