| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 // Request job implementation used with DeviceManagementService. | 136 // Request job implementation used with DeviceManagementService. |
| 137 class DeviceManagementRequestJobImpl : public DeviceManagementRequestJob { | 137 class DeviceManagementRequestJobImpl : public DeviceManagementRequestJob { |
| 138 public: | 138 public: |
| 139 DeviceManagementRequestJobImpl( | 139 DeviceManagementRequestJobImpl( |
| 140 JobType type, | 140 JobType type, |
| 141 const std::string& agent_parameter, | 141 const std::string& agent_parameter, |
| 142 const std::string& platform_parameter, | 142 const std::string& platform_parameter, |
| 143 DeviceManagementService* service, | 143 DeviceManagementService* service, |
| 144 const scoped_refptr<net::URLRequestContextGetter>& request_context); | 144 const scoped_refptr<net::URLRequestContextGetter>& request_context); |
| 145 virtual ~DeviceManagementRequestJobImpl(); | 145 ~DeviceManagementRequestJobImpl() override; |
| 146 | 146 |
| 147 // Handles the URL request response. | 147 // Handles the URL request response. |
| 148 void HandleResponse(const net::URLRequestStatus& status, | 148 void HandleResponse(const net::URLRequestStatus& status, |
| 149 int response_code, | 149 int response_code, |
| 150 const net::ResponseCookies& cookies, | 150 const net::ResponseCookies& cookies, |
| 151 const std::string& data); | 151 const std::string& data); |
| 152 | 152 |
| 153 // Gets the URL to contact. | 153 // Gets the URL to contact. |
| 154 GURL GetURL(const std::string& server_url); | 154 GURL GetURL(const std::string& server_url); |
| 155 | 155 |
| 156 // Configures the fetcher, setting up payload and headers. | 156 // Configures the fetcher, setting up payload and headers. |
| 157 void ConfigureRequest(net::URLFetcher* fetcher); | 157 void ConfigureRequest(net::URLFetcher* fetcher); |
| 158 | 158 |
| 159 // Returns true if this job should be retried. |fetcher| has just completed, | 159 // Returns true if this job should be retried. |fetcher| has just completed, |
| 160 // and can be inspected to determine if the request failed and should be | 160 // and can be inspected to determine if the request failed and should be |
| 161 // retried. | 161 // retried. |
| 162 bool ShouldRetry(const net::URLFetcher* fetcher); | 162 bool ShouldRetry(const net::URLFetcher* fetcher); |
| 163 | 163 |
| 164 // Invoked right before retrying this job. | 164 // Invoked right before retrying this job. |
| 165 void PrepareRetry(); | 165 void PrepareRetry(); |
| 166 | 166 |
| 167 protected: | 167 protected: |
| 168 // DeviceManagementRequestJob: | 168 // DeviceManagementRequestJob: |
| 169 virtual void Run() override; | 169 void Run() override; |
| 170 | 170 |
| 171 private: | 171 private: |
| 172 // Invokes the callback with the given error code. | 172 // Invokes the callback with the given error code. |
| 173 void ReportError(DeviceManagementStatus code); | 173 void ReportError(DeviceManagementStatus code); |
| 174 | 174 |
| 175 // Pointer to the service this job is associated with. | 175 // Pointer to the service this job is associated with. |
| 176 DeviceManagementService* service_; | 176 DeviceManagementService* service_; |
| 177 | 177 |
| 178 // Whether the BYPASS_PROXY flag should be set by ConfigureRequest(). | 178 // Whether the BYPASS_PROXY flag should be set by ConfigureRequest(). |
| 179 bool bypass_proxy_; | 179 bool bypass_proxy_; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 } | 526 } |
| 527 } | 527 } |
| 528 | 528 |
| 529 const JobQueue::iterator elem = | 529 const JobQueue::iterator elem = |
| 530 std::find(queued_jobs_.begin(), queued_jobs_.end(), job); | 530 std::find(queued_jobs_.begin(), queued_jobs_.end(), job); |
| 531 if (elem != queued_jobs_.end()) | 531 if (elem != queued_jobs_.end()) |
| 532 queued_jobs_.erase(elem); | 532 queued_jobs_.erase(elem); |
| 533 } | 533 } |
| 534 | 534 |
| 535 } // namespace policy | 535 } // namespace policy |
| OLD | NEW |