OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_BACKEND_IMPL_H_ | 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_IMPL_H_ |
6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_IMPL_H_ | 6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_IMPL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "chrome/browser/policy/device_management_backend.h" | 13 #include "chrome/browser/policy/device_management_backend.h" |
14 | 14 |
15 namespace policy { | 15 namespace policy { |
16 | 16 |
17 class DeviceManagementService; | 17 class DeviceManagementService; |
18 class DeviceManagementJobBase; | 18 class DeviceManagementJobBase; |
19 | 19 |
20 // Implements the actual backend interface. It creates device management jobs | 20 // Implements the actual backend interface. It creates device management jobs |
21 // and passes them on to the service for processing. | 21 // and passes them on to the service for processing. |
22 class DeviceManagementBackendImpl : public DeviceManagementBackend { | 22 class DeviceManagementBackendImpl : public DeviceManagementBackend { |
23 public: | 23 public: |
24 explicit DeviceManagementBackendImpl(DeviceManagementService* service); | 24 explicit DeviceManagementBackendImpl(DeviceManagementService* service); |
25 virtual ~DeviceManagementBackendImpl(); | 25 virtual ~DeviceManagementBackendImpl(); |
26 | 26 |
| 27 static std::string GetAgentString(); |
| 28 |
| 29 // Name constants for URL query parameters. |
| 30 static const char kParamRequest[]; |
| 31 static const char kParamDeviceType[]; |
| 32 static const char kParamAppType[]; |
| 33 static const char kParamDeviceID[]; |
| 34 static const char kParamAgent[]; |
| 35 |
| 36 // String constants for the device and app type we report to the server. |
| 37 static const char kValueRequestRegister[]; |
| 38 static const char kValueRequestUnregister[]; |
| 39 static const char kValueRequestPolicy[]; |
| 40 static const char kValueDeviceType[]; |
| 41 static const char kValueAppType[]; |
| 42 |
27 private: | 43 private: |
28 friend class DeviceManagementJobBase; | 44 friend class DeviceManagementJobBase; |
29 | 45 |
30 typedef std::set<DeviceManagementJobBase*> JobSet; | 46 typedef std::set<DeviceManagementJobBase*> JobSet; |
31 | 47 |
32 // Called by the DeviceManagementJobBase dtor so we can clean up. | 48 // Called by the DeviceManagementJobBase dtor so we can clean up. |
33 void JobDone(DeviceManagementJobBase* job); | 49 void JobDone(DeviceManagementJobBase* job); |
34 | 50 |
35 // Add a job to the pending job set and register it with the service (if | 51 // Add a job to the pending job set and register it with the service (if |
36 // available). | 52 // available). |
37 void AddJob(DeviceManagementJobBase* job); | 53 void AddJob(DeviceManagementJobBase* job); |
38 | 54 |
39 // DeviceManagementBackend overrides. | 55 // DeviceManagementBackend overrides. |
40 virtual void ProcessRegisterRequest( | 56 virtual void ProcessRegisterRequest( |
41 const std::string& auth_token, | 57 const std::string& auth_token, |
42 const std::string& device_id, | 58 const std::string& device_id, |
43 const em::DeviceRegisterRequest& request, | 59 const em::DeviceRegisterRequest& request, |
44 DeviceRegisterResponseDelegate* response_delegate); | 60 DeviceRegisterResponseDelegate* response_delegate); |
45 virtual void ProcessUnregisterRequest( | 61 virtual void ProcessUnregisterRequest( |
46 const std::string& device_management_token, | 62 const std::string& device_management_token, |
| 63 const std::string& device_id, |
47 const em::DeviceUnregisterRequest& request, | 64 const em::DeviceUnregisterRequest& request, |
48 DeviceUnregisterResponseDelegate* response_delegate); | 65 DeviceUnregisterResponseDelegate* response_delegate); |
49 virtual void ProcessPolicyRequest( | 66 virtual void ProcessPolicyRequest( |
50 const std::string& device_management_token, | 67 const std::string& device_management_token, |
| 68 const std::string& device_id, |
51 const em::DevicePolicyRequest& request, | 69 const em::DevicePolicyRequest& request, |
52 DevicePolicyResponseDelegate* response_delegate); | 70 DevicePolicyResponseDelegate* response_delegate); |
53 | 71 |
54 // Keeps track of the jobs currently in flight. | 72 // Keeps track of the jobs currently in flight. |
55 JobSet pending_jobs_; | 73 JobSet pending_jobs_; |
56 | 74 |
57 DeviceManagementService* service_; | 75 DeviceManagementService* service_; |
58 | 76 |
59 DISALLOW_COPY_AND_ASSIGN(DeviceManagementBackendImpl); | 77 DISALLOW_COPY_AND_ASSIGN(DeviceManagementBackendImpl); |
60 }; | 78 }; |
61 | 79 |
62 } // namespace policy | 80 } // namespace policy |
63 | 81 |
64 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_IMPL_H_ | 82 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_IMPL_H_ |
OLD | NEW |