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