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> |
| 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/observer_list.h" | 18 #include "base/observer_list.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 20 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 20 #include "components/policy/policy_export.h" | 21 #include "components/policy/policy_export.h" |
| 21 #include "policy/proto/device_management_backend.pb.h" | 22 #include "policy/proto/device_management_backend.pb.h" |
| 22 | 23 |
| 23 namespace net { | 24 namespace net { |
| 24 class URLRequestContextGetter; | 25 class URLRequestContextGetter; |
| 25 } | 26 } |
| 26 | 27 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 | 210 |
| 210 // Returns the invalidation version that was used for the last FetchPolicy. | 211 // Returns the invalidation version that was used for the last FetchPolicy. |
| 211 // Observers can call this method from their OnPolicyFetched method to | 212 // Observers can call this method from their OnPolicyFetched method to |
| 212 // determine which at which invalidation version the policy was fetched. | 213 // determine which at which invalidation version the policy was fetched. |
| 213 int64 fetched_invalidation_version() const { | 214 int64 fetched_invalidation_version() const { |
| 214 return fetched_invalidation_version_; | 215 return fetched_invalidation_version_; |
| 215 } | 216 } |
| 216 | 217 |
| 217 scoped_refptr<net::URLRequestContextGetter> GetRequestContext(); | 218 scoped_refptr<net::URLRequestContextGetter> GetRequestContext(); |
| 218 | 219 |
| 220 // Returns the number of active requests. | |
| 221 int GetActiveRequestCountForTest(); | |
|
bartfab (slow)
2015/02/06 14:41:01
Nit: Mark this method const.
Andrew T Wilson (Slow)
2015/02/06 18:23:30
Done.
| |
| 222 | |
| 219 protected: | 223 protected: |
| 220 // A set of (policy type, settings entity ID) pairs to fetch. | 224 // A set of (policy type, settings entity ID) pairs to fetch. |
| 221 typedef std::set<std::pair<std::string, std::string>> PolicyTypeSet; | 225 typedef std::set<std::pair<std::string, std::string>> PolicyTypeSet; |
| 222 | 226 |
| 223 // Callback for retries of registration requests. | 227 // Callback for retries of registration requests. |
| 224 void OnRetryRegister(DeviceManagementRequestJob* job); | 228 void OnRetryRegister(DeviceManagementRequestJob* job); |
| 225 | 229 |
| 226 // Callback for registration requests. | 230 // Callback for registration requests. |
| 227 void OnRegisterCompleted( | 231 void OnRegisterCompleted( |
| 228 DeviceManagementStatus status, | 232 DeviceManagementStatus status, |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 242 const enterprise_management::DeviceManagementResponse& response); | 246 const enterprise_management::DeviceManagementResponse& response); |
| 243 | 247 |
| 244 // Callback for unregistration requests. | 248 // Callback for unregistration requests. |
| 245 void OnUnregisterCompleted( | 249 void OnUnregisterCompleted( |
| 246 DeviceManagementStatus status, | 250 DeviceManagementStatus status, |
| 247 int net_error, | 251 int net_error, |
| 248 const enterprise_management::DeviceManagementResponse& response); | 252 const enterprise_management::DeviceManagementResponse& response); |
| 249 | 253 |
| 250 // Callback for certificate upload requests. | 254 // Callback for certificate upload requests. |
| 251 void OnCertificateUploadCompleted( | 255 void OnCertificateUploadCompleted( |
| 256 const DeviceManagementRequestJob* job, | |
| 252 const StatusCallback& callback, | 257 const StatusCallback& callback, |
| 253 DeviceManagementStatus status, | 258 DeviceManagementStatus status, |
| 254 int net_error, | 259 int net_error, |
| 255 const enterprise_management::DeviceManagementResponse& response); | 260 const enterprise_management::DeviceManagementResponse& response); |
| 256 | 261 |
| 257 // Callback for status upload requests. | 262 // Callback for status upload requests. |
| 258 void OnStatusUploadCompleted( | 263 void OnStatusUploadCompleted( |
| 264 const DeviceManagementRequestJob* job, | |
| 259 const StatusCallback& callback, | 265 const StatusCallback& callback, |
| 260 DeviceManagementStatus status, | 266 DeviceManagementStatus status, |
| 261 int net_error, | 267 int net_error, |
| 262 const enterprise_management::DeviceManagementResponse& response); | 268 const enterprise_management::DeviceManagementResponse& response); |
| 263 | 269 |
| 270 // Helper to remove a job from request_jobs_. | |
| 271 void RemoveJob(const DeviceManagementRequestJob* job); | |
| 272 | |
| 264 // Observer notification helpers. | 273 // Observer notification helpers. |
| 265 void NotifyPolicyFetched(); | 274 void NotifyPolicyFetched(); |
| 266 void NotifyRegistrationStateChanged(); | 275 void NotifyRegistrationStateChanged(); |
| 267 void NotifyRobotAuthCodesFetched(); | 276 void NotifyRobotAuthCodesFetched(); |
| 268 void NotifyClientError(); | 277 void NotifyClientError(); |
| 269 | 278 |
| 270 // Data necessary for constructing policy requests. | 279 // Data necessary for constructing policy requests. |
| 271 const std::string machine_id_; | 280 const std::string machine_id_; |
| 272 const std::string machine_model_; | 281 const std::string machine_model_; |
| 273 const std::string verification_key_hash_; | 282 const std::string verification_key_hash_; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 286 | 295 |
| 287 // Information for the latest policy invalidation received. | 296 // Information for the latest policy invalidation received. |
| 288 int64 invalidation_version_; | 297 int64 invalidation_version_; |
| 289 std::string invalidation_payload_; | 298 std::string invalidation_payload_; |
| 290 | 299 |
| 291 // The invalidation version used for the most recent fetch operation. | 300 // The invalidation version used for the most recent fetch operation. |
| 292 int64 fetched_invalidation_version_; | 301 int64 fetched_invalidation_version_; |
| 293 | 302 |
| 294 // Used for issuing requests to the cloud. | 303 // Used for issuing requests to the cloud. |
| 295 DeviceManagementService* service_; | 304 DeviceManagementService* service_; |
| 296 scoped_ptr<DeviceManagementRequestJob> request_job_; | 305 |
| 306 // Only one outstanding policy fetch is allowed, so this is tracked in | |
| 307 // its own member variable. | |
| 308 scoped_ptr<DeviceManagementRequestJob> policy_fetch_request_job_; | |
| 309 | |
| 310 // All of the outstanding non-policy-fetch request jobs. These jobs are | |
| 311 // silently cancelled if Unregister() is called. | |
| 312 ScopedVector<DeviceManagementRequestJob> request_jobs_; | |
| 297 | 313 |
| 298 // The policy responses returned by the last policy fetch operation. | 314 // The policy responses returned by the last policy fetch operation. |
| 299 ResponseMap responses_; | 315 ResponseMap responses_; |
| 300 DeviceManagementStatus status_; | 316 DeviceManagementStatus status_; |
| 301 | 317 |
| 302 ObserverList<Observer, true> observers_; | 318 ObserverList<Observer, true> observers_; |
| 303 scoped_refptr<net::URLRequestContextGetter> request_context_; | 319 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 304 | 320 |
| 305 private: | 321 private: |
| 306 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); | 322 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); |
| 307 }; | 323 }; |
| 308 | 324 |
| 309 } // namespace policy | 325 } // namespace policy |
| 310 | 326 |
| 311 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ | 327 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ |
| OLD | NEW |