Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chrome/browser/policy/device_management_backend_impl.h

Issue 8952027: base::Callback-ify policy::DeviceManagementService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 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/cloud_policy_constants.h"
13 #include "chrome/browser/policy/device_management_backend.h" 14 #include "chrome/browser/policy/device_management_backend.h"
14 15
15 namespace policy { 16 namespace policy {
16 17
17 class DeviceManagementJobBase; 18 class DeviceManagementRequestJob;
18 class DeviceManagementService; 19 class DeviceManagementService;
19 20
20 // Implements the actual backend interface. It creates device management jobs 21 // Implements the actual backend interface. It creates device management jobs
21 // and passes them on to the service for processing. 22 // and passes them on to the service for processing.
22 class DeviceManagementBackendImpl : public DeviceManagementBackend { 23 class DeviceManagementBackendImpl : public DeviceManagementBackend {
23 public: 24 public:
24 explicit DeviceManagementBackendImpl(DeviceManagementService* service); 25 explicit DeviceManagementBackendImpl(DeviceManagementService* service);
25 virtual ~DeviceManagementBackendImpl(); 26 virtual ~DeviceManagementBackendImpl();
26 27
27 static std::string GetAgentString();
28 static std::string GetPlatformString();
29
30 // Name constants for URL query parameters.
31 static const char kParamAgent[];
32 static const char kParamAppType[];
33 static const char kParamDeviceID[];
34 static const char kParamDeviceType[];
35 static const char kParamOAuthToken[];
36 static const char kParamPlatform[];
37 static const char kParamRequest[];
38 static const char kParamUserAffiliation[];
39
40 // String constants for the device and app type we report to the server.
41 static const char kValueAppType[];
42 static const char kValueDeviceType[];
43 static const char kValueRequestAutoEnrollment[];
44 static const char kValueRequestPolicy[];
45 static const char kValueRequestRegister[];
46 static const char kValueRequestUnregister[];
47 static const char kValueUserAffiliationManaged[];
48 static const char kValueUserAffiliationNone[];
49
50 private: 28 private:
51 friend class DeviceManagementJobBase; 29 typedef std::set<DeviceManagementRequestJob*> JobSet;
52
53 typedef std::set<DeviceManagementJobBase*> JobSet;
54
55 // Called by the DeviceManagementJobBase dtor so we can clean up.
56 void JobDone(DeviceManagementJobBase* job);
57
58 // Add a job to the pending job set and register it with the service (if
59 // available).
60 void AddJob(DeviceManagementJobBase* job);
61 30
62 // DeviceManagementBackend overrides. 31 // DeviceManagementBackend overrides.
63 virtual void ProcessRegisterRequest( 32 virtual void ProcessRegisterRequest(
64 const std::string& gaia_auth_token, 33 const std::string& gaia_auth_token,
65 const std::string& oauth_token, 34 const std::string& oauth_token,
66 const std::string& device_id, 35 const std::string& device_id,
67 const enterprise_management::DeviceRegisterRequest& request, 36 const enterprise_management::DeviceRegisterRequest& request,
68 DeviceRegisterResponseDelegate* response_delegate) OVERRIDE; 37 DeviceRegisterResponseDelegate* response_delegate) OVERRIDE;
69 virtual void ProcessUnregisterRequest( 38 virtual void ProcessUnregisterRequest(
70 const std::string& device_management_token, 39 const std::string& device_management_token,
71 const std::string& device_id, 40 const std::string& device_id,
72 const enterprise_management::DeviceUnregisterRequest& request, 41 const enterprise_management::DeviceUnregisterRequest& request,
73 DeviceUnregisterResponseDelegate* response_delegate) OVERRIDE; 42 DeviceUnregisterResponseDelegate* response_delegate) OVERRIDE;
74 virtual void ProcessPolicyRequest( 43 virtual void ProcessPolicyRequest(
75 const std::string& device_management_token, 44 const std::string& device_management_token,
76 const std::string& device_id, 45 const std::string& device_id,
77 CloudPolicyDataStore::UserAffiliation affiliation, 46 CloudPolicyDataStore::UserAffiliation affiliation,
78 const enterprise_management::DevicePolicyRequest& request, 47 const enterprise_management::DevicePolicyRequest& request,
79 const enterprise_management::DeviceStatusReportRequest* device_status, 48 const enterprise_management::DeviceStatusReportRequest* device_status,
80 DevicePolicyResponseDelegate* response_delegate) OVERRIDE; 49 DevicePolicyResponseDelegate* response_delegate) OVERRIDE;
81 virtual void ProcessAutoEnrollmentRequest( 50 virtual void ProcessAutoEnrollmentRequest(
82 const std::string& device_id, 51 const std::string& device_id,
83 const enterprise_management::DeviceAutoEnrollmentRequest& request, 52 const enterprise_management::DeviceAutoEnrollmentRequest& request,
84 DeviceAutoEnrollmentResponseDelegate* delegate) OVERRIDE; 53 DeviceAutoEnrollmentResponseDelegate* delegate) OVERRIDE;
85 54
86 // Converts a user affiliation to the appropriate query parameter value. 55 // Helpers for mapping new-style callbacks to the old delegate style.
87 static const char* UserAffiliationToString( 56 void OnRegistrationDone(
88 CloudPolicyDataStore::UserAffiliation affiliation); 57 DeviceManagementRequestJob* job,
58 DeviceRegisterResponseDelegate* delegate,
59 DeviceManagementStatus status,
60 const enterprise_management::DeviceManagementResponse& response);
61 void OnUnregistrationDone(
62 DeviceManagementRequestJob* job,
63 DeviceUnregisterResponseDelegate* delegate,
64 DeviceManagementStatus status,
65 const enterprise_management::DeviceManagementResponse& response);
66 void OnPolicyFetchDone(
67 DeviceManagementRequestJob* job,
68 DevicePolicyResponseDelegate* delegate,
69 DeviceManagementStatus status,
70 const enterprise_management::DeviceManagementResponse& response);
71 void OnAutoEnrollmentDone(
72 DeviceManagementRequestJob* job,
73 DeviceAutoEnrollmentResponseDelegate* delegate,
74 DeviceManagementStatus status,
75 const enterprise_management::DeviceManagementResponse& response);
89 76
90 // Keeps track of the jobs currently in flight. 77 // Keeps track of the jobs currently in flight.
91 JobSet pending_jobs_; 78 JobSet pending_jobs_;
92 79
93 DeviceManagementService* service_; 80 DeviceManagementService* service_;
94 81
95 DISALLOW_COPY_AND_ASSIGN(DeviceManagementBackendImpl); 82 DISALLOW_COPY_AND_ASSIGN(DeviceManagementBackendImpl);
96 }; 83 };
97 84
98 } // namespace policy 85 } // namespace policy
99 86
100 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_IMPL_H_ 87 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698