Chromium Code Reviews| 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_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> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 | 63 |
| 64 // Called when a request for device robot OAuth2 authorization tokens | 64 // Called when a request for device robot OAuth2 authorization tokens |
| 65 // returns successfully. Only occurs during enrollment. Optional | 65 // returns successfully. Only occurs during enrollment. Optional |
| 66 // (default implementation is a noop). | 66 // (default implementation is a noop). |
| 67 virtual void OnRobotAuthCodesFetched(CloudPolicyClient* client); | 67 virtual void OnRobotAuthCodesFetched(CloudPolicyClient* client); |
| 68 | 68 |
| 69 // Indicates there's been an error in a previously-issued request. | 69 // Indicates there's been an error in a previously-issued request. |
| 70 virtual void OnClientError(CloudPolicyClient* client) = 0; | 70 virtual void OnClientError(CloudPolicyClient* client) = 0; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 // Delegate interface for supplying status information to upload to the server | |
| 74 // as part of the policy fetch request. | |
| 75 class POLICY_EXPORT StatusProvider { | |
| 76 public: | |
| 77 virtual ~StatusProvider(); | |
| 78 | |
| 79 // Retrieves status information to send with the next policy fetch. | |
| 80 // Implementations must return true if status information was filled in. | |
| 81 virtual bool GetDeviceStatus( | |
| 82 enterprise_management::DeviceStatusReportRequest* status) = 0; | |
| 83 virtual bool GetSessionStatus( | |
| 84 enterprise_management::SessionStatusReportRequest* status) = 0; | |
| 85 | |
| 86 // Called after the status information has successfully been submitted to | |
| 87 // the server. | |
| 88 virtual void OnSubmittedSuccessfully() = 0; | |
| 89 }; | |
| 90 | |
| 91 // |provider| and |service| are weak pointers and it's the caller's | 73 // |provider| and |service| are weak pointers and it's the caller's |
| 92 // responsibility to keep them valid for the lifetime of CloudPolicyClient. | 74 // responsibility to keep them valid for the lifetime of CloudPolicyClient. |
| 93 // |verification_key_hash| contains an identifier telling the DMServer which | 75 // |verification_key_hash| contains an identifier telling the DMServer which |
| 94 // verification key to use. | 76 // verification key to use. |
| 95 CloudPolicyClient( | 77 CloudPolicyClient( |
| 96 const std::string& machine_id, | 78 const std::string& machine_id, |
| 97 const std::string& machine_model, | 79 const std::string& machine_model, |
| 98 const std::string& verification_key_hash, | 80 const std::string& verification_key_hash, |
| 99 UserAffiliation user_affiliation, | 81 UserAffiliation user_affiliation, |
| 100 DeviceManagementService* service, | 82 DeviceManagementService* service, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 // Sends an unregistration request to the server. | 121 // Sends an unregistration request to the server. |
| 140 virtual void Unregister(); | 122 virtual void Unregister(); |
| 141 | 123 |
| 142 // Upload a device certificate to the server. Like FetchPolicy, this method | 124 // Upload a device certificate to the server. Like FetchPolicy, this method |
| 143 // requires that the client is in a registered state. |certificate_data| must | 125 // requires that the client is in a registered state. |certificate_data| must |
| 144 // hold the X.509 certificate data to be sent to the server. The |callback| | 126 // hold the X.509 certificate data to be sent to the server. The |callback| |
| 145 // will be called when the operation completes. | 127 // will be called when the operation completes. |
| 146 virtual void UploadCertificate(const std::string& certificate_data, | 128 virtual void UploadCertificate(const std::string& certificate_data, |
| 147 const StatusCallback& callback); | 129 const StatusCallback& callback); |
| 148 | 130 |
| 131 // Creates a job to upload device/session status to the server. As above, | |
| 132 // the client must be in a registered state. If non-null, |device_status| and | |
| 133 // |session_status| will be included in the upload status request. | |
| 134 virtual scoped_ptr<DeviceManagementRequestJob> CreateUploadStatusJob( | |
| 135 const enterprise_management::DeviceStatusReportRequest* device_status, | |
| 136 const enterprise_management::SessionStatusReportRequest* session_status); | |
|
Mattias Nissler (ping if slow)
2015/01/23 13:46:35
Is there a good reason to return the request job i
Andrew T Wilson (Slow)
2015/01/23 19:16:19
Because I want to be able to cancel the request jo
Mattias Nissler (ping if slow)
2015/01/26 10:37:02
What's the benefit of cancelling the job, instead
Andrew T Wilson (Slow)
2015/01/28 13:19:12
Done.
| |
| 137 | |
|
Mattias Nissler (ping if slow)
2015/01/23 13:46:35
remove extra blank line
Andrew T Wilson (Slow)
2015/01/23 19:16:19
Done.
| |
| 138 | |
| 149 // Adds an observer to be called back upon policy and state changes. | 139 // Adds an observer to be called back upon policy and state changes. |
| 150 void AddObserver(Observer* observer); | 140 void AddObserver(Observer* observer); |
| 151 | 141 |
| 152 // Removes the specified observer. | 142 // Removes the specified observer. |
| 153 void RemoveObserver(Observer* observer); | 143 void RemoveObserver(Observer* observer); |
| 154 | 144 |
| 155 // Sets the status provider for this client, or NULL if no provider. | |
| 156 // ClouldPolicyClient takes ownership of the passed |provider|. | |
| 157 void SetStatusProvider(scoped_ptr<StatusProvider> provider); | |
| 158 | |
| 159 // Returns true if this object has a StatusProvider configured. | |
| 160 bool HasStatusProviderForTest(); | |
| 161 | |
| 162 void set_submit_machine_id(bool submit_machine_id) { | 145 void set_submit_machine_id(bool submit_machine_id) { |
| 163 submit_machine_id_ = submit_machine_id; | 146 submit_machine_id_ = submit_machine_id; |
| 164 } | 147 } |
| 165 | 148 |
| 166 void set_last_policy_timestamp(const base::Time& timestamp) { | 149 void set_last_policy_timestamp(const base::Time& timestamp) { |
| 167 last_policy_timestamp_ = timestamp; | 150 last_policy_timestamp_ = timestamp; |
| 168 } | 151 } |
| 169 | 152 |
| 170 void set_public_key_version(int public_key_version) { | 153 void set_public_key_version(int public_key_version) { |
| 171 public_key_version_ = public_key_version; | 154 public_key_version_ = public_key_version; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 int64 invalidation_version_; | 280 int64 invalidation_version_; |
| 298 std::string invalidation_payload_; | 281 std::string invalidation_payload_; |
| 299 | 282 |
| 300 // The invalidation version used for the most recent fetch operation. | 283 // The invalidation version used for the most recent fetch operation. |
| 301 int64 fetched_invalidation_version_; | 284 int64 fetched_invalidation_version_; |
| 302 | 285 |
| 303 // Used for issuing requests to the cloud. | 286 // Used for issuing requests to the cloud. |
| 304 DeviceManagementService* service_; | 287 DeviceManagementService* service_; |
| 305 scoped_ptr<DeviceManagementRequestJob> request_job_; | 288 scoped_ptr<DeviceManagementRequestJob> request_job_; |
| 306 | 289 |
| 307 // Status upload data is produced by |status_provider_|. | |
| 308 scoped_ptr<StatusProvider> status_provider_; | |
| 309 | |
| 310 // The policy responses returned by the last policy fetch operation. | 290 // The policy responses returned by the last policy fetch operation. |
| 311 ResponseMap responses_; | 291 ResponseMap responses_; |
| 312 DeviceManagementStatus status_; | 292 DeviceManagementStatus status_; |
| 313 | 293 |
| 314 ObserverList<Observer, true> observers_; | 294 ObserverList<Observer, true> observers_; |
| 315 scoped_refptr<net::URLRequestContextGetter> request_context_; | 295 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 316 | 296 |
| 317 private: | 297 private: |
| 318 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); | 298 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); |
| 319 }; | 299 }; |
| 320 | 300 |
| 321 } // namespace policy | 301 } // namespace policy |
| 322 | 302 |
| 323 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ | 303 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ |
| OLD | NEW |