| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // The max tolerated discrepancy, in seconds, between policy timestamps and | 57 // The max tolerated discrepancy, in seconds, between policy timestamps and |
| 58 // invalidation timestamps when determining if an invalidation is expired. | 58 // invalidation timestamps when determining if an invalidation is expired. |
| 59 static const int kMaxInvalidationTimeDelta; | 59 static const int kMaxInvalidationTimeDelta; |
| 60 | 60 |
| 61 // |type| indicates the policy type that this invalidator is responsible for. | 61 // |type| indicates the policy type that this invalidator is responsible for. |
| 62 // |core| is the cloud policy core which connects the various policy objects. | 62 // |core| is the cloud policy core which connects the various policy objects. |
| 63 // It must remain valid until Shutdown is called. | 63 // It must remain valid until Shutdown is called. |
| 64 // |task_runner| is used for scheduling delayed tasks. It must post tasks to | 64 // |task_runner| is used for scheduling delayed tasks. It must post tasks to |
| 65 // the main policy thread. | 65 // the main policy thread. |
| 66 // |clock| is used to get the current time. | 66 // |clock| is used to get the current time. |
| 67 // |highest_handled_invalidation_version| is the highest invalidation version |
| 68 // that was handled already before this invalidator was created. |
| 67 CloudPolicyInvalidator( | 69 CloudPolicyInvalidator( |
| 68 enterprise_management::DeviceRegisterRequest::Type type, | 70 enterprise_management::DeviceRegisterRequest::Type type, |
| 69 CloudPolicyCore* core, | 71 CloudPolicyCore* core, |
| 70 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 72 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 71 scoped_ptr<base::Clock> clock); | 73 scoped_ptr<base::Clock> clock, |
| 74 int64 highest_handled_invalidation_version); |
| 72 virtual ~CloudPolicyInvalidator(); | 75 virtual ~CloudPolicyInvalidator(); |
| 73 | 76 |
| 74 // Initializes the invalidator. No invalidations will be generated before this | 77 // Initializes the invalidator. No invalidations will be generated before this |
| 75 // method is called. This method must only be called once. | 78 // method is called. This method must only be called once. |
| 76 // |invalidation_service| is the invalidation service to use and must remain | 79 // |invalidation_service| is the invalidation service to use and must remain |
| 77 // valid until Shutdown is called. | 80 // valid until Shutdown is called. |
| 78 void Initialize(invalidation::InvalidationService* invalidation_service); | 81 void Initialize(invalidation::InvalidationService* invalidation_service); |
| 79 | 82 |
| 80 // Shuts down and disables invalidations. It must be called before the object | 83 // Shuts down and disables invalidations. It must be called before the object |
| 81 // is destroyed. | 84 // is destroyed. |
| 82 void Shutdown(); | 85 void Shutdown(); |
| 83 | 86 |
| 84 // Whether the invalidator currently has the ability to receive invalidations. | 87 // Whether the invalidator currently has the ability to receive invalidations. |
| 85 bool invalidations_enabled() { | 88 bool invalidations_enabled() { |
| 86 return invalidations_enabled_; | 89 return invalidations_enabled_; |
| 87 } | 90 } |
| 88 | 91 |
| 92 // The highest invalidation version that was handled already. |
| 93 int64 highest_handled_invalidation_version() const { |
| 94 return highest_handled_invalidation_version_; |
| 95 } |
| 96 |
| 89 // syncer::InvalidationHandler: | 97 // syncer::InvalidationHandler: |
| 90 virtual void OnInvalidatorStateChange( | 98 virtual void OnInvalidatorStateChange( |
| 91 syncer::InvalidatorState state) OVERRIDE; | 99 syncer::InvalidatorState state) OVERRIDE; |
| 92 virtual void OnIncomingInvalidation( | 100 virtual void OnIncomingInvalidation( |
| 93 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | 101 const syncer::ObjectIdInvalidationMap& invalidation_map) OVERRIDE; |
| 94 virtual std::string GetOwnerName() const OVERRIDE; | 102 virtual std::string GetOwnerName() const OVERRIDE; |
| 95 | 103 |
| 96 // CloudPolicyCore::Observer: | 104 // CloudPolicyCore::Observer: |
| 97 virtual void OnCoreConnected(CloudPolicyCore* core) OVERRIDE; | 105 virtual void OnCoreConnected(CloudPolicyCore* core) OVERRIDE; |
| 98 virtual void OnRefreshSchedulerStarted(CloudPolicyCore* core) OVERRIDE; | 106 virtual void OnRefreshSchedulerStarted(CloudPolicyCore* core) OVERRIDE; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // The version of the latest invalidation received. This is compared to | 208 // The version of the latest invalidation received. This is compared to |
| 201 // the invalidation version of policy stored to determine when the | 209 // the invalidation version of policy stored to determine when the |
| 202 // invalidated policy is up-to-date. | 210 // invalidated policy is up-to-date. |
| 203 int64 invalidation_version_; | 211 int64 invalidation_version_; |
| 204 | 212 |
| 205 // The number of invalidations with unknown version received. Since such | 213 // The number of invalidations with unknown version received. Since such |
| 206 // invalidations do not provide a version number, this count is used to set | 214 // invalidations do not provide a version number, this count is used to set |
| 207 // invalidation_version_ when such invalidations occur. | 215 // invalidation_version_ when such invalidations occur. |
| 208 int unknown_version_invalidation_count_; | 216 int unknown_version_invalidation_count_; |
| 209 | 217 |
| 218 // The highest invalidation version that was handled already. |
| 219 int64 highest_handled_invalidation_version_; |
| 220 |
| 210 // The most up to date invalidation. | 221 // The most up to date invalidation. |
| 211 scoped_ptr<syncer::Invalidation> invalidation_; | 222 scoped_ptr<syncer::Invalidation> invalidation_; |
| 212 | 223 |
| 213 // WeakPtrFactory used to create callbacks to this object. | 224 // WeakPtrFactory used to create callbacks to this object. |
| 214 base::WeakPtrFactory<CloudPolicyInvalidator> weak_factory_; | 225 base::WeakPtrFactory<CloudPolicyInvalidator> weak_factory_; |
| 215 | 226 |
| 216 // The maximum random delay, in ms, between receiving an invalidation and | 227 // The maximum random delay, in ms, between receiving an invalidation and |
| 217 // fetching the new policy. | 228 // fetching the new policy. |
| 218 int max_fetch_delay_; | 229 int max_fetch_delay_; |
| 219 | 230 |
| 220 // The hash value of the current policy. This is used to determine if a new | 231 // The hash value of the current policy. This is used to determine if a new |
| 221 // policy is different from the current one. | 232 // policy is different from the current one. |
| 222 uint32 policy_hash_value_; | 233 uint32 policy_hash_value_; |
| 223 | 234 |
| 224 // A thread checker to make sure that callbacks are invoked on the correct | 235 // A thread checker to make sure that callbacks are invoked on the correct |
| 225 // thread. | 236 // thread. |
| 226 base::ThreadChecker thread_checker_; | 237 base::ThreadChecker thread_checker_; |
| 227 | 238 |
| 228 DISALLOW_COPY_AND_ASSIGN(CloudPolicyInvalidator); | 239 DISALLOW_COPY_AND_ASSIGN(CloudPolicyInvalidator); |
| 229 }; | 240 }; |
| 230 | 241 |
| 231 } // namespace policy | 242 } // namespace policy |
| 232 | 243 |
| 233 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ | 244 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ |
| OLD | NEW |