| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/policy/core/common/cloud/device_management_service.h" | 5 #include "components/policy/core/common/cloud/device_management_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const int kInvalidURL = 404; // This error is not coming from the GFE. | 47 const int kInvalidURL = 404; // This error is not coming from the GFE. |
| 48 const int kInvalidSerialNumber = 405; | 48 const int kInvalidSerialNumber = 405; |
| 49 const int kDomainMismatch = 406; | 49 const int kDomainMismatch = 406; |
| 50 const int kDeviceIdConflict = 409; | 50 const int kDeviceIdConflict = 409; |
| 51 const int kDeviceNotFound = 410; | 51 const int kDeviceNotFound = 410; |
| 52 const int kPendingApproval = 412; | 52 const int kPendingApproval = 412; |
| 53 const int kInternalServerError = 500; | 53 const int kInternalServerError = 500; |
| 54 const int kServiceUnavailable = 503; | 54 const int kServiceUnavailable = 503; |
| 55 const int kPolicyNotFound = 902; | 55 const int kPolicyNotFound = 902; |
| 56 const int kDeprovisioned = 903; | 56 const int kDeprovisioned = 903; |
| 57 const int kArcDisabled = 904; |
| 57 | 58 |
| 58 // Delay after first unsuccessful upload attempt. After each additional failure, | 59 // Delay after first unsuccessful upload attempt. After each additional failure, |
| 59 // the delay increases exponentially. Can be changed for testing to prevent | 60 // the delay increases exponentially. Can be changed for testing to prevent |
| 60 // timeouts. | 61 // timeouts. |
| 61 long g_retry_delay_ms = 10000; | 62 long g_retry_delay_ms = 10000; |
| 62 | 63 |
| 63 bool IsProxyError(const net::URLRequestStatus status) { | 64 bool IsProxyError(const net::URLRequestStatus status) { |
| 64 switch (status.error()) { | 65 switch (status.error()) { |
| 65 case net::ERR_PROXY_CONNECTION_FAILED: | 66 case net::ERR_PROXY_CONNECTION_FAILED: |
| 66 case net::ERR_TUNNEL_CONNECTION_FAILED: | 67 case net::ERR_TUNNEL_CONNECTION_FAILED: |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 case DeviceManagementRequestJob::TYPE_ATTRIBUTE_UPDATE_PERMISSION: | 144 case DeviceManagementRequestJob::TYPE_ATTRIBUTE_UPDATE_PERMISSION: |
| 144 return dm_protocol::kValueRequestDeviceAttributeUpdatePermission; | 145 return dm_protocol::kValueRequestDeviceAttributeUpdatePermission; |
| 145 case DeviceManagementRequestJob::TYPE_ATTRIBUTE_UPDATE: | 146 case DeviceManagementRequestJob::TYPE_ATTRIBUTE_UPDATE: |
| 146 return dm_protocol::kValueRequestDeviceAttributeUpdate; | 147 return dm_protocol::kValueRequestDeviceAttributeUpdate; |
| 147 case DeviceManagementRequestJob::TYPE_GCM_ID_UPDATE: | 148 case DeviceManagementRequestJob::TYPE_GCM_ID_UPDATE: |
| 148 return dm_protocol::kValueRequestGcmIdUpdate; | 149 return dm_protocol::kValueRequestGcmIdUpdate; |
| 149 case DeviceManagementRequestJob::TYPE_ANDROID_MANAGEMENT_CHECK: | 150 case DeviceManagementRequestJob::TYPE_ANDROID_MANAGEMENT_CHECK: |
| 150 return dm_protocol::kValueRequestCheckAndroidManagement; | 151 return dm_protocol::kValueRequestCheckAndroidManagement; |
| 151 case DeviceManagementRequestJob::TYPE_CERT_BASED_REGISTRATION: | 152 case DeviceManagementRequestJob::TYPE_CERT_BASED_REGISTRATION: |
| 152 return dm_protocol::kValueRequestCertBasedRegister; | 153 return dm_protocol::kValueRequestCertBasedRegister; |
| 154 case DeviceManagementRequestJob::TYPE_ACTIVE_DIRECTORY_ENROLL_PLAY_USER: |
| 155 return dm_protocol::kValueRequestActiveDirectoryEnrollPlayUser; |
| 156 case DeviceManagementRequestJob::TYPE_ACTIVE_DIRECTORY_PLAY_ACTIVITY: |
| 157 return dm_protocol::kValueRequestActiveDirectoryPlayActivity; |
| 153 } | 158 } |
| 154 NOTREACHED() << "Invalid job type " << type; | 159 NOTREACHED() << "Invalid job type " << type; |
| 155 return ""; | 160 return ""; |
| 156 } | 161 } |
| 157 | 162 |
| 158 } // namespace | 163 } // namespace |
| 159 | 164 |
| 160 // Request job implementation used with DeviceManagementService. | 165 // Request job implementation used with DeviceManagementService. |
| 161 class DeviceManagementRequestJobImpl : public DeviceManagementRequestJob { | 166 class DeviceManagementRequestJobImpl : public DeviceManagementRequestJob { |
| 162 public: | 167 public: |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 return; | 343 return; |
| 339 case kDomainMismatch: | 344 case kDomainMismatch: |
| 340 ReportError(DM_STATUS_SERVICE_DOMAIN_MISMATCH); | 345 ReportError(DM_STATUS_SERVICE_DOMAIN_MISMATCH); |
| 341 return; | 346 return; |
| 342 case kDeprovisioned: | 347 case kDeprovisioned: |
| 343 ReportError(DM_STATUS_SERVICE_DEPROVISIONED); | 348 ReportError(DM_STATUS_SERVICE_DEPROVISIONED); |
| 344 return; | 349 return; |
| 345 case kDeviceIdConflict: | 350 case kDeviceIdConflict: |
| 346 ReportError(DM_STATUS_SERVICE_DEVICE_ID_CONFLICT); | 351 ReportError(DM_STATUS_SERVICE_DEVICE_ID_CONFLICT); |
| 347 return; | 352 return; |
| 353 case kArcDisabled: |
| 354 ReportError(DM_STATUS_SERVICE_ARC_DISABLED); |
| 355 return; |
| 348 default: | 356 default: |
| 349 // Handle all unknown 5xx HTTP error codes as temporary and any other | 357 // Handle all unknown 5xx HTTP error codes as temporary and any other |
| 350 // unknown error as one that needs more time to recover. | 358 // unknown error as one that needs more time to recover. |
| 351 if (response_code >= 500 && response_code <= 599) | 359 if (response_code >= 500 && response_code <= 599) |
| 352 ReportError(DM_STATUS_TEMPORARY_UNAVAILABLE); | 360 ReportError(DM_STATUS_TEMPORARY_UNAVAILABLE); |
| 353 else | 361 else |
| 354 ReportError(DM_STATUS_HTTP_STATUS_ERROR); | 362 ReportError(DM_STATUS_HTTP_STATUS_ERROR); |
| 355 return; | 363 return; |
| 356 } | 364 } |
| 357 } | 365 } |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 } | 669 } |
| 662 } | 670 } |
| 663 | 671 |
| 664 const JobQueue::iterator elem = | 672 const JobQueue::iterator elem = |
| 665 std::find(queued_jobs_.begin(), queued_jobs_.end(), job); | 673 std::find(queued_jobs_.begin(), queued_jobs_.end(), job); |
| 666 if (elem != queued_jobs_.end()) | 674 if (elem != queued_jobs_.end()) |
| 667 queued_jobs_.erase(elem); | 675 queued_jobs_.erase(elem); |
| 668 } | 676 } |
| 669 | 677 |
| 670 } // namespace policy | 678 } // namespace policy |
| OLD | NEW |