| OLD | NEW |
| 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_SERVICE_H_ |
| 6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_SERVICE_H_ | 6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <deque> | 9 #include <deque> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 16 #include "content/common/net/url_fetcher.h" | 17 #include "content/public/common/url_fetcher_delegate.h" |
| 17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 class URLRequestContextGetter; | 21 class URLRequestContextGetter; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace policy { | 24 namespace policy { |
| 24 | 25 |
| 25 class DeviceManagementBackend; | 26 class DeviceManagementBackend; |
| 26 | 27 |
| 27 // The device management service is responsible for everything related to | 28 // The device management service is responsible for everything related to |
| 28 // communication with the device management server. It creates the backends | 29 // communication with the device management server. It creates the backends |
| 29 // objects that the device management policy provider and friends use to issue | 30 // objects that the device management policy provider and friends use to issue |
| 30 // requests. | 31 // requests. |
| 31 class DeviceManagementService : public URLFetcher::Delegate { | 32 class DeviceManagementService : public content::URLFetcherDelegate { |
| 32 public: | 33 public: |
| 33 // Describes a device management job handled by the service. | 34 // Describes a device management job handled by the service. |
| 34 class DeviceManagementJob { | 35 class DeviceManagementJob { |
| 35 public: | 36 public: |
| 36 virtual ~DeviceManagementJob() {} | 37 virtual ~DeviceManagementJob() {} |
| 37 | 38 |
| 38 // Handles the URL request response. | 39 // Handles the URL request response. |
| 39 virtual void HandleResponse(const net::URLRequestStatus& status, | 40 virtual void HandleResponse(const net::URLRequestStatus& status, |
| 40 int response_code, | 41 int response_code, |
| 41 const net::ResponseCookies& cookies, | 42 const net::ResponseCookies& cookies, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 72 void RemoveJob(DeviceManagementJob* job); | 73 void RemoveJob(DeviceManagementJob* job); |
| 73 | 74 |
| 74 protected: | 75 protected: |
| 75 // Starts the given job. | 76 // Starts the given job. |
| 76 virtual void StartJob(DeviceManagementJob* job, bool bypass_proxy); | 77 virtual void StartJob(DeviceManagementJob* job, bool bypass_proxy); |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 typedef std::map<const URLFetcher*, DeviceManagementJob*> JobFetcherMap; | 80 typedef std::map<const URLFetcher*, DeviceManagementJob*> JobFetcherMap; |
| 80 typedef std::deque<DeviceManagementJob*> JobQueue; | 81 typedef std::deque<DeviceManagementJob*> JobQueue; |
| 81 | 82 |
| 82 // URLFetcher::Delegate override. | 83 // content::URLFetcherDelegate override. |
| 83 virtual void OnURLFetchComplete(const URLFetcher* source, | 84 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; |
| 84 const GURL& url, | |
| 85 const net::URLRequestStatus& status, | |
| 86 int response_code, | |
| 87 const net::ResponseCookies& cookies, | |
| 88 const std::string& data) OVERRIDE; | |
| 89 | 85 |
| 90 // Does the actual initialization using the request context specified for | 86 // Does the actual initialization using the request context specified for |
| 91 // |PrepareInitialization|. This will also fire any pending network requests. | 87 // |PrepareInitialization|. This will also fire any pending network requests. |
| 92 void Initialize(); | 88 void Initialize(); |
| 93 | 89 |
| 94 // Server at which to contact the service. | 90 // Server at which to contact the service. |
| 95 const std::string server_url_; | 91 const std::string server_url_; |
| 96 | 92 |
| 97 // The request context we use. | 93 // The request context we use. |
| 98 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 94 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 109 | 105 |
| 110 // Used to create tasks to run |Initialize| delayed on the UI thread. | 106 // Used to create tasks to run |Initialize| delayed on the UI thread. |
| 111 base::WeakPtrFactory<DeviceManagementService> weak_ptr_factory_; | 107 base::WeakPtrFactory<DeviceManagementService> weak_ptr_factory_; |
| 112 | 108 |
| 113 DISALLOW_COPY_AND_ASSIGN(DeviceManagementService); | 109 DISALLOW_COPY_AND_ASSIGN(DeviceManagementService); |
| 114 }; | 110 }; |
| 115 | 111 |
| 116 } // namespace policy | 112 } // namespace policy |
| 117 | 113 |
| 118 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_SERVICE_H_ | 114 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_SERVICE_H_ |
| OLD | NEW |