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 #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> |
(...skipping 15 matching lines...) Expand all Loading... |
27 // objects that the device management policy provider and friends use to issue | 27 // objects that the device management policy provider and friends use to issue |
28 // requests. | 28 // requests. |
29 class DeviceManagementService : public URLFetcher::Delegate { | 29 class DeviceManagementService : public URLFetcher::Delegate { |
30 public: | 30 public: |
31 // Describes a device management job handled by the service. | 31 // Describes a device management job handled by the service. |
32 class DeviceManagementJob { | 32 class DeviceManagementJob { |
33 public: | 33 public: |
34 virtual ~DeviceManagementJob() {} | 34 virtual ~DeviceManagementJob() {} |
35 | 35 |
36 // Handles the URL request response. | 36 // Handles the URL request response. |
37 virtual void HandleResponse(const URLRequestStatus& status, | 37 virtual void HandleResponse(const net::URLRequestStatus& status, |
38 int response_code, | 38 int response_code, |
39 const ResponseCookies& cookies, | 39 const ResponseCookies& cookies, |
40 const std::string& data) = 0; | 40 const std::string& data) = 0; |
41 | 41 |
42 // Gets the URL to contact. | 42 // Gets the URL to contact. |
43 virtual GURL GetURL(const std::string& server_url) = 0; | 43 virtual GURL GetURL(const std::string& server_url) = 0; |
44 | 44 |
45 // Configures the fetcher, setting up payload and headers. | 45 // Configures the fetcher, setting up payload and headers. |
46 virtual void ConfigureRequest(URLFetcher* fetcher) = 0; | 46 virtual void ConfigureRequest(URLFetcher* fetcher) = 0; |
47 }; | 47 }; |
48 | 48 |
49 explicit DeviceManagementService(const std::string& server_url); | 49 explicit DeviceManagementService(const std::string& server_url); |
50 virtual ~DeviceManagementService(); | 50 virtual ~DeviceManagementService(); |
(...skipping 21 matching lines...) Expand all Loading... |
72 private: | 72 private: |
73 typedef std::map<const URLFetcher*, DeviceManagementJob*> JobFetcherMap; | 73 typedef std::map<const URLFetcher*, DeviceManagementJob*> JobFetcherMap; |
74 typedef std::deque<DeviceManagementJob*> JobQueue; | 74 typedef std::deque<DeviceManagementJob*> JobQueue; |
75 | 75 |
76 // Starts the given job. | 76 // Starts the given job. |
77 void StartJob(DeviceManagementJob* job); | 77 void StartJob(DeviceManagementJob* job); |
78 | 78 |
79 // URLFetcher::Delegate override. | 79 // URLFetcher::Delegate override. |
80 virtual void OnURLFetchComplete(const URLFetcher* source, | 80 virtual void OnURLFetchComplete(const URLFetcher* source, |
81 const GURL& url, | 81 const GURL& url, |
82 const URLRequestStatus& status, | 82 const net::URLRequestStatus& status, |
83 int response_code, | 83 int response_code, |
84 const ResponseCookies& cookies, | 84 const ResponseCookies& cookies, |
85 const std::string& data); | 85 const std::string& data); |
86 | 86 |
87 // Server at which to contact the service. | 87 // Server at which to contact the service. |
88 const std::string server_url_; | 88 const std::string server_url_; |
89 | 89 |
90 // The request context we use. | 90 // The request context we use. |
91 scoped_refptr<URLRequestContextGetter> request_context_getter_; | 91 scoped_refptr<URLRequestContextGetter> request_context_getter_; |
92 | 92 |
93 // The jobs we currently have in flight. | 93 // The jobs we currently have in flight. |
94 JobFetcherMap pending_jobs_; | 94 JobFetcherMap pending_jobs_; |
95 | 95 |
96 // Jobs that are registered, but not started yet. | 96 // Jobs that are registered, but not started yet. |
97 JobQueue queued_jobs_; | 97 JobQueue queued_jobs_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(DeviceManagementService); | 99 DISALLOW_COPY_AND_ASSIGN(DeviceManagementService); |
100 }; | 100 }; |
101 | 101 |
102 } // namespace policy | 102 } // namespace policy |
103 | 103 |
104 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_SERVICE_H_ | 104 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_SERVICE_H_ |
OLD | NEW |