| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/policy/device_management_backend_impl.h" | 5 #include "chrome/browser/policy/device_management_backend_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "net/base/escape.h" | 11 #include "net/base/escape.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // implementation. Subclasses provide custom code for handling actual register, | 83 // implementation. Subclasses provide custom code for handling actual register, |
| 84 // unregister, and policy jobs. | 84 // unregister, and policy jobs. |
| 85 class DeviceManagementJobBase | 85 class DeviceManagementJobBase |
| 86 : public DeviceManagementService::DeviceManagementJob { | 86 : public DeviceManagementService::DeviceManagementJob { |
| 87 public: | 87 public: |
| 88 virtual ~DeviceManagementJobBase() { | 88 virtual ~DeviceManagementJobBase() { |
| 89 backend_impl_->JobDone(this); | 89 backend_impl_->JobDone(this); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // DeviceManagementJob overrides: | 92 // DeviceManagementJob overrides: |
| 93 virtual void HandleResponse(const URLRequestStatus& status, | 93 virtual void HandleResponse(const net::URLRequestStatus& status, |
| 94 int response_code, | 94 int response_code, |
| 95 const ResponseCookies& cookies, | 95 const ResponseCookies& cookies, |
| 96 const std::string& data); | 96 const std::string& data); |
| 97 virtual GURL GetURL(const std::string& server_url); | 97 virtual GURL GetURL(const std::string& server_url); |
| 98 virtual void ConfigureRequest(URLFetcher* fetcher); | 98 virtual void ConfigureRequest(URLFetcher* fetcher); |
| 99 | 99 |
| 100 protected: | 100 protected: |
| 101 // Constructs a device management job running for the given backend. | 101 // Constructs a device management job running for the given backend. |
| 102 DeviceManagementJobBase(DeviceManagementBackendImpl* backend_impl, | 102 DeviceManagementJobBase(DeviceManagementBackendImpl* backend_impl, |
| 103 const std::string& request_type, | 103 const std::string& request_type, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 149 |
| 150 // Device management token (if applicable). | 150 // Device management token (if applicable). |
| 151 std::string device_management_token_; | 151 std::string device_management_token_; |
| 152 | 152 |
| 153 // The payload. | 153 // The payload. |
| 154 std::string payload_; | 154 std::string payload_; |
| 155 | 155 |
| 156 DISALLOW_COPY_AND_ASSIGN(DeviceManagementJobBase); | 156 DISALLOW_COPY_AND_ASSIGN(DeviceManagementJobBase); |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 void DeviceManagementJobBase::HandleResponse(const URLRequestStatus& status, | 159 void DeviceManagementJobBase::HandleResponse( |
| 160 int response_code, | 160 const net::URLRequestStatus& status, |
| 161 const ResponseCookies& cookies, | 161 int response_code, |
| 162 const std::string& data) { | 162 const ResponseCookies& cookies, |
| 163 const std::string& data) { |
| 163 // Delete ourselves when this is done. | 164 // Delete ourselves when this is done. |
| 164 scoped_ptr<DeviceManagementJob> scoped_killer(this); | 165 scoped_ptr<DeviceManagementJob> scoped_killer(this); |
| 165 | 166 |
| 166 if (status.status() != URLRequestStatus::SUCCESS) { | 167 if (status.status() != net::URLRequestStatus::SUCCESS) { |
| 167 OnError(DeviceManagementBackend::kErrorRequestFailed); | 168 OnError(DeviceManagementBackend::kErrorRequestFailed); |
| 168 return; | 169 return; |
| 169 } | 170 } |
| 170 | 171 |
| 171 if (response_code != 200) { | 172 if (response_code != 200) { |
| 172 OnError(DeviceManagementBackend::kErrorHttpStatus); | 173 OnError(DeviceManagementBackend::kErrorHttpStatus); |
| 173 return; | 174 return; |
| 174 } | 175 } |
| 175 | 176 |
| 176 em::DeviceManagementResponse response; | 177 em::DeviceManagementResponse response; |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 void DeviceManagementBackendImpl::ProcessPolicyRequest( | 403 void DeviceManagementBackendImpl::ProcessPolicyRequest( |
| 403 const std::string& device_management_token, | 404 const std::string& device_management_token, |
| 404 const std::string& device_id, | 405 const std::string& device_id, |
| 405 const em::DevicePolicyRequest& request, | 406 const em::DevicePolicyRequest& request, |
| 406 DevicePolicyResponseDelegate* delegate) { | 407 DevicePolicyResponseDelegate* delegate) { |
| 407 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id, | 408 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id, |
| 408 request, delegate)); | 409 request, delegate)); |
| 409 } | 410 } |
| 410 | 411 |
| 411 } // namespace policy | 412 } // namespace policy |
| OLD | NEW |