| 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 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_ |
| 6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 virtual std::string GetServerUrl() = 0; | 117 virtual std::string GetServerUrl() = 0; |
| 118 | 118 |
| 119 // Agent reported in the "agent" query parameter. | 119 // Agent reported in the "agent" query parameter. |
| 120 virtual std::string GetAgentParameter() = 0; | 120 virtual std::string GetAgentParameter() = 0; |
| 121 | 121 |
| 122 // The platform reported in the "platform" query parameter. | 122 // The platform reported in the "platform" query parameter. |
| 123 virtual std::string GetPlatformParameter() = 0; | 123 virtual std::string GetPlatformParameter() = 0; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 explicit DeviceManagementService(scoped_ptr<Configuration> configuration); | 126 explicit DeviceManagementService(scoped_ptr<Configuration> configuration); |
| 127 virtual ~DeviceManagementService(); | 127 ~DeviceManagementService() override; |
| 128 | 128 |
| 129 // The ID of URLFetchers created by the DeviceManagementService. This can be | 129 // The ID of URLFetchers created by the DeviceManagementService. This can be |
| 130 // used by tests that use a TestURLFetcherFactory to get the pending fetchers | 130 // used by tests that use a TestURLFetcherFactory to get the pending fetchers |
| 131 // created by the DeviceManagementService. | 131 // created by the DeviceManagementService. |
| 132 static const int kURLFetcherID; | 132 static const int kURLFetcherID; |
| 133 | 133 |
| 134 // Creates a new device management request job. Ownership is transferred to | 134 // Creates a new device management request job. Ownership is transferred to |
| 135 // the caller. | 135 // the caller. |
| 136 virtual DeviceManagementRequestJob* CreateJob( | 136 virtual DeviceManagementRequestJob* CreateJob( |
| 137 DeviceManagementRequestJob::JobType type, | 137 DeviceManagementRequestJob::JobType type, |
| 138 const scoped_refptr<net::URLRequestContextGetter>& request_context); | 138 const scoped_refptr<net::URLRequestContextGetter>& request_context); |
| 139 | 139 |
| 140 // Schedules a task to run |Initialize| after |delay_milliseconds| had passed. | 140 // Schedules a task to run |Initialize| after |delay_milliseconds| had passed. |
| 141 void ScheduleInitialization(int64 delay_milliseconds); | 141 void ScheduleInitialization(int64 delay_milliseconds); |
| 142 | 142 |
| 143 // Makes the service stop all requests. | 143 // Makes the service stop all requests. |
| 144 void Shutdown(); | 144 void Shutdown(); |
| 145 | 145 |
| 146 // Gets the URL that the DMServer requests are sent to. | 146 // Gets the URL that the DMServer requests are sent to. |
| 147 std::string GetServerUrl(); | 147 std::string GetServerUrl(); |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 typedef std::map<const net::URLFetcher*, | 150 typedef std::map<const net::URLFetcher*, |
| 151 DeviceManagementRequestJobImpl*> JobFetcherMap; | 151 DeviceManagementRequestJobImpl*> JobFetcherMap; |
| 152 typedef std::deque<DeviceManagementRequestJobImpl*> JobQueue; | 152 typedef std::deque<DeviceManagementRequestJobImpl*> JobQueue; |
| 153 | 153 |
| 154 friend class DeviceManagementRequestJobImpl; | 154 friend class DeviceManagementRequestJobImpl; |
| 155 | 155 |
| 156 // net::URLFetcherDelegate override. | 156 // net::URLFetcherDelegate override. |
| 157 virtual void OnURLFetchComplete(const net::URLFetcher* source) override; | 157 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 158 | 158 |
| 159 // Starts processing any queued jobs. | 159 // Starts processing any queued jobs. |
| 160 void Initialize(); | 160 void Initialize(); |
| 161 | 161 |
| 162 // Starts a job. | 162 // Starts a job. |
| 163 void StartJob(DeviceManagementRequestJobImpl* job); | 163 void StartJob(DeviceManagementRequestJobImpl* job); |
| 164 | 164 |
| 165 // Adds a job. Caller must make sure the job pointer stays valid until the job | 165 // Adds a job. Caller must make sure the job pointer stays valid until the job |
| 166 // completes or gets canceled via RemoveJob(). | 166 // completes or gets canceled via RemoveJob(). |
| 167 void AddJob(DeviceManagementRequestJobImpl* job); | 167 void AddJob(DeviceManagementRequestJobImpl* job); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 186 | 186 |
| 187 // Used to create tasks to run |Initialize| delayed on the UI thread. | 187 // Used to create tasks to run |Initialize| delayed on the UI thread. |
| 188 base::WeakPtrFactory<DeviceManagementService> weak_ptr_factory_; | 188 base::WeakPtrFactory<DeviceManagementService> weak_ptr_factory_; |
| 189 | 189 |
| 190 DISALLOW_COPY_AND_ASSIGN(DeviceManagementService); | 190 DISALLOW_COPY_AND_ASSIGN(DeviceManagementService); |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 } // namespace policy | 193 } // namespace policy |
| 194 | 194 |
| 195 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_ | 195 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_DEVICE_MANAGEMENT_SERVICE_H_ |
| OLD | NEW |