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

Side by Side Diff: components/policy/core/common/cloud/cloud_policy_client.h

Issue 879233003: Initial RemoteCommandService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remote-commands
Patch Set: WIP Created 5 years, 10 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
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 COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
18 #include "base/observer_list.h" 18 #include "base/observer_list.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 20 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
21 #include "components/policy/core/common/remote_commands/remote_command_job.h"
21 #include "components/policy/policy_export.h" 22 #include "components/policy/policy_export.h"
22 #include "policy/proto/device_management_backend.pb.h" 23 #include "policy/proto/device_management_backend.pb.h"
23 24
24 namespace net { 25 namespace net {
25 class URLRequestContextGetter; 26 class URLRequestContextGetter;
26 } 27 }
27 28
28 namespace policy { 29 namespace policy {
29 30
30 class DeviceManagementRequestJob; 31 class DeviceManagementRequestJob;
(...skipping 11 matching lines...) Expand all
42 public: 43 public:
43 // Maps a (policy type, settings entity ID) pair to its corresponding 44 // Maps a (policy type, settings entity ID) pair to its corresponding
44 // PolicyFetchResponse. 45 // PolicyFetchResponse.
45 typedef std::map<std::pair<std::string, std::string>, 46 typedef std::map<std::pair<std::string, std::string>,
46 enterprise_management::PolicyFetchResponse*> ResponseMap; 47 enterprise_management::PolicyFetchResponse*> ResponseMap;
47 48
48 // A callback which receives boolean status of an operation. If the operation 49 // A callback which receives boolean status of an operation. If the operation
49 // succeeded, |status| is true. 50 // succeeded, |status| is true.
50 typedef base::Callback<void(bool status)> StatusCallback; 51 typedef base::Callback<void(bool status)> StatusCallback;
51 52
53 typedef base::Callback<void(
bartfab (slow) 2015/02/12 14:29:19 Nit 1: Use C++ using= instead. Nit 2: Document thi
binjin 2015/02/16 22:46:23 Done.
54 const std::vector<enterprise_management::RemoteCommand>&)>
55 RemoteCommandCallback;
56
52 // Observer interface for state and policy changes. 57 // Observer interface for state and policy changes.
53 class POLICY_EXPORT Observer { 58 class POLICY_EXPORT Observer {
54 public: 59 public:
55 virtual ~Observer(); 60 virtual ~Observer();
56 61
57 // Called when a policy fetch completes successfully. If a policy fetch 62 // Called when a policy fetch completes successfully. If a policy fetch
58 // triggers an error, OnClientError() will fire. 63 // triggers an error, OnClientError() will fire.
59 virtual void OnPolicyFetched(CloudPolicyClient* client) = 0; 64 virtual void OnPolicyFetched(CloudPolicyClient* client) = 0;
60 65
61 // Called upon registration state changes. This callback is invoked for 66 // Called upon registration state changes. This callback is invoked for
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 136
132 // Uploads device/session status to the server. As above, the client must be 137 // Uploads device/session status to the server. As above, the client must be
133 // in a registered state. If non-null, |device_status| and |session_status| 138 // in a registered state. If non-null, |device_status| and |session_status|
134 // will be included in the upload status request. The |callback| will be 139 // will be included in the upload status request. The |callback| will be
135 // called when the operation completes. 140 // called when the operation completes.
136 virtual void UploadDeviceStatus( 141 virtual void UploadDeviceStatus(
137 const enterprise_management::DeviceStatusReportRequest* device_status, 142 const enterprise_management::DeviceStatusReportRequest* device_status,
138 const enterprise_management::SessionStatusReportRequest* session_status, 143 const enterprise_management::SessionStatusReportRequest* session_status,
139 const StatusCallback& callback); 144 const StatusCallback& callback);
140 145
146 // XXX
147 virtual void FetchRemoteCommands(
bartfab (slow) 2015/02/12 14:29:19 This should be covered by CloudPolicyClient's unit
binjin 2015/02/16 22:46:23 Done.
148 RemoteCommandJob::UniqueIDType last_command_id,
149 const std::vector<enterprise_management::RemoteCommandResult>&
150 command_results,
151 const RemoteCommandCallback& callback);
152
141 // Adds an observer to be called back upon policy and state changes. 153 // Adds an observer to be called back upon policy and state changes.
142 void AddObserver(Observer* observer); 154 void AddObserver(Observer* observer);
143 155
144 // Removes the specified observer. 156 // Removes the specified observer.
145 void RemoveObserver(Observer* observer); 157 void RemoveObserver(Observer* observer);
146 158
147 void set_submit_machine_id(bool submit_machine_id) { 159 void set_submit_machine_id(bool submit_machine_id) {
148 submit_machine_id_ = submit_machine_id; 160 submit_machine_id_ = submit_machine_id;
149 } 161 }
150 162
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 const enterprise_management::DeviceManagementResponse& response); 272 const enterprise_management::DeviceManagementResponse& response);
261 273
262 // Callback for status upload requests. 274 // Callback for status upload requests.
263 void OnStatusUploadCompleted( 275 void OnStatusUploadCompleted(
264 const DeviceManagementRequestJob* job, 276 const DeviceManagementRequestJob* job,
265 const StatusCallback& callback, 277 const StatusCallback& callback,
266 DeviceManagementStatus status, 278 DeviceManagementStatus status,
267 int net_error, 279 int net_error,
268 const enterprise_management::DeviceManagementResponse& response); 280 const enterprise_management::DeviceManagementResponse& response);
269 281
282 // XXX
283 void OnRemoteCommandsFetched(
284 const DeviceManagementRequestJob* job,
285 const RemoteCommandCallback& callback,
286 DeviceManagementStatus status,
287 int net_error,
288 const enterprise_management::DeviceManagementResponse& response);
289
270 // Helper to remove a job from request_jobs_. 290 // Helper to remove a job from request_jobs_.
271 void RemoveJob(const DeviceManagementRequestJob* job); 291 void RemoveJob(const DeviceManagementRequestJob* job);
272 292
273 // Observer notification helpers. 293 // Observer notification helpers.
274 void NotifyPolicyFetched(); 294 void NotifyPolicyFetched();
275 void NotifyRegistrationStateChanged(); 295 void NotifyRegistrationStateChanged();
276 void NotifyRobotAuthCodesFetched(); 296 void NotifyRobotAuthCodesFetched();
277 void NotifyClientError(); 297 void NotifyClientError();
278 298
279 // Data necessary for constructing policy requests. 299 // Data necessary for constructing policy requests.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 ObserverList<Observer, true> observers_; 338 ObserverList<Observer, true> observers_;
319 scoped_refptr<net::URLRequestContextGetter> request_context_; 339 scoped_refptr<net::URLRequestContextGetter> request_context_;
320 340
321 private: 341 private:
322 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); 342 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient);
323 }; 343 };
324 344
325 } // namespace policy 345 } // namespace policy
326 346
327 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ 347 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698