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 <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <set> | 11 #include <set> |
10 #include <string> | 12 #include <string> |
11 #include <utility> | 13 #include <utility> |
12 #include <vector> | 14 #include <vector> |
13 | 15 |
14 #include "base/basictypes.h" | |
15 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/macros.h" |
16 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/scoped_vector.h" | 19 #include "base/memory/scoped_vector.h" |
18 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
19 #include "base/time/time.h" | 21 #include "base/time/time.h" |
20 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 22 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
21 #include "components/policy/core/common/remote_commands/remote_command_job.h" | 23 #include "components/policy/core/common/remote_commands/remote_command_job.h" |
22 #include "components/policy/policy_export.h" | 24 #include "components/policy/policy_export.h" |
23 #include "policy/proto/device_management_backend.pb.h" | 25 #include "policy/proto/device_management_backend.pb.h" |
24 | 26 |
25 namespace net { | 27 namespace net { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 enterprise_management::DeviceRegisterRequest::Type registration_type, | 103 enterprise_management::DeviceRegisterRequest::Type registration_type, |
102 enterprise_management::DeviceRegisterRequest::Flavor flavor, | 104 enterprise_management::DeviceRegisterRequest::Flavor flavor, |
103 const std::string& auth_token, | 105 const std::string& auth_token, |
104 const std::string& client_id, | 106 const std::string& client_id, |
105 const std::string& requisition, | 107 const std::string& requisition, |
106 const std::string& current_state_key); | 108 const std::string& current_state_key); |
107 | 109 |
108 // Sets information about a policy invalidation. Subsequent fetch operations | 110 // Sets information about a policy invalidation. Subsequent fetch operations |
109 // will use the given info, and callers can use fetched_invalidation_version | 111 // will use the given info, and callers can use fetched_invalidation_version |
110 // to determine which version of policy was fetched. | 112 // to determine which version of policy was fetched. |
111 void SetInvalidationInfo(int64 version, const std::string& payload); | 113 void SetInvalidationInfo(int64_t version, const std::string& payload); |
112 | 114 |
113 // Requests a policy fetch. The client being registered is a prerequisite to | 115 // Requests a policy fetch. The client being registered is a prerequisite to |
114 // this operation and this call will CHECK if the client is not in registered | 116 // this operation and this call will CHECK if the client is not in registered |
115 // state. FetchPolicy() triggers a policy fetch from the cloud. A policy | 117 // state. FetchPolicy() triggers a policy fetch from the cloud. A policy |
116 // change notification is reported to the observers and the new policy blob | 118 // change notification is reported to the observers and the new policy blob |
117 // can be retrieved once the policy fetch operation completes. In case of | 119 // can be retrieved once the policy fetch operation completes. In case of |
118 // multiple requests to fetch policy, new requests will cancel any pending | 120 // multiple requests to fetch policy, new requests will cancel any pending |
119 // requests and the latest request will eventually trigger notifications. | 121 // requests and the latest request will eventually trigger notifications. |
120 virtual void FetchPolicy(); | 122 virtual void FetchPolicy(); |
121 | 123 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 return status_; | 246 return status_; |
245 } | 247 } |
246 | 248 |
247 const std::string& robot_api_auth_code() const { | 249 const std::string& robot_api_auth_code() const { |
248 return robot_api_auth_code_; | 250 return robot_api_auth_code_; |
249 } | 251 } |
250 | 252 |
251 // Returns the invalidation version that was used for the last FetchPolicy. | 253 // Returns the invalidation version that was used for the last FetchPolicy. |
252 // Observers can call this method from their OnPolicyFetched method to | 254 // Observers can call this method from their OnPolicyFetched method to |
253 // determine which at which invalidation version the policy was fetched. | 255 // determine which at which invalidation version the policy was fetched. |
254 int64 fetched_invalidation_version() const { | 256 int64_t fetched_invalidation_version() const { |
255 return fetched_invalidation_version_; | 257 return fetched_invalidation_version_; |
256 } | 258 } |
257 | 259 |
258 scoped_refptr<net::URLRequestContextGetter> GetRequestContext(); | 260 scoped_refptr<net::URLRequestContextGetter> GetRequestContext(); |
259 | 261 |
260 // Returns the number of active requests. | 262 // Returns the number of active requests. |
261 int GetActiveRequestCountForTest() const; | 263 int GetActiveRequestCountForTest() const; |
262 | 264 |
263 protected: | 265 protected: |
264 // A set of (policy type, settings entity ID) pairs to fetch. | 266 // A set of (policy type, settings entity ID) pairs to fetch. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 std::string dm_token_; | 360 std::string dm_token_; |
359 DeviceMode device_mode_; | 361 DeviceMode device_mode_; |
360 std::string client_id_; | 362 std::string client_id_; |
361 bool submit_machine_id_; | 363 bool submit_machine_id_; |
362 base::Time last_policy_timestamp_; | 364 base::Time last_policy_timestamp_; |
363 int public_key_version_; | 365 int public_key_version_; |
364 bool public_key_version_valid_; | 366 bool public_key_version_valid_; |
365 std::string robot_api_auth_code_; | 367 std::string robot_api_auth_code_; |
366 | 368 |
367 // Information for the latest policy invalidation received. | 369 // Information for the latest policy invalidation received. |
368 int64 invalidation_version_; | 370 int64_t invalidation_version_; |
369 std::string invalidation_payload_; | 371 std::string invalidation_payload_; |
370 | 372 |
371 // The invalidation version used for the most recent fetch operation. | 373 // The invalidation version used for the most recent fetch operation. |
372 int64 fetched_invalidation_version_; | 374 int64_t fetched_invalidation_version_; |
373 | 375 |
374 // Used for issuing requests to the cloud. | 376 // Used for issuing requests to the cloud. |
375 DeviceManagementService* service_; | 377 DeviceManagementService* service_; |
376 | 378 |
377 // Only one outstanding policy fetch is allowed, so this is tracked in | 379 // Only one outstanding policy fetch is allowed, so this is tracked in |
378 // its own member variable. | 380 // its own member variable. |
379 scoped_ptr<DeviceManagementRequestJob> policy_fetch_request_job_; | 381 scoped_ptr<DeviceManagementRequestJob> policy_fetch_request_job_; |
380 | 382 |
381 // All of the outstanding non-policy-fetch request jobs. These jobs are | 383 // All of the outstanding non-policy-fetch request jobs. These jobs are |
382 // silently cancelled if Unregister() is called. | 384 // silently cancelled if Unregister() is called. |
383 ScopedVector<DeviceManagementRequestJob> request_jobs_; | 385 ScopedVector<DeviceManagementRequestJob> request_jobs_; |
384 | 386 |
385 // The policy responses returned by the last policy fetch operation. | 387 // The policy responses returned by the last policy fetch operation. |
386 ResponseMap responses_; | 388 ResponseMap responses_; |
387 DeviceManagementStatus status_; | 389 DeviceManagementStatus status_; |
388 | 390 |
389 base::ObserverList<Observer, true> observers_; | 391 base::ObserverList<Observer, true> observers_; |
390 scoped_refptr<net::URLRequestContextGetter> request_context_; | 392 scoped_refptr<net::URLRequestContextGetter> request_context_; |
391 | 393 |
392 private: | 394 private: |
393 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); | 395 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); |
394 }; | 396 }; |
395 | 397 |
396 } // namespace policy | 398 } // namespace policy |
397 | 399 |
398 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ | 400 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_CLOUD_POLICY_CLIENT_H_ |
OLD | NEW |