Chromium Code Reviews| Index: chrome/browser/policy/cloud/cloud_policy_invalidator.h |
| diff --git a/chrome/browser/policy/cloud/cloud_policy_invalidator.h b/chrome/browser/policy/cloud/cloud_policy_invalidator.h |
| index 5192277eedaaa530403c5599a54e23f81f1b0e91..164c24555860fbc1334c4ede05ac2a34785b5e56 100644 |
| --- a/chrome/browser/policy/cloud/cloud_policy_invalidator.h |
| +++ b/chrome/browser/policy/cloud/cloud_policy_invalidator.h |
| @@ -20,6 +20,7 @@ |
| #include "sync/notifier/invalidation_handler.h" |
| namespace base { |
| +class Clock; |
| class SequencedTaskRunner; |
| } |
| @@ -43,13 +44,20 @@ class CloudPolicyInvalidator : public syncer::InvalidationHandler, |
| static const int kMaxFetchDelayMin; |
| static const int kMaxFetchDelayMax; |
| + // The grace period, in seconds, to allow for invalidations to be received |
| + // once the invalidation service starts up. |
| + static const int kInvalidationGracePeriod; |
| + |
| // |core| is the cloud policy core which connects the various policy objects. |
| // It must remain valid until Shutdown is called. |
| // |task_runner| is used for scheduling delayed tasks. It must post tasks to |
| // the main policy thread. |
| + // |clock| is used to get the current time. This object takes ownership of the |
| + // clock. |
| CloudPolicyInvalidator( |
| CloudPolicyCore* core, |
| - const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| + const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| + base::Clock* clock); |
|
Joao da Silva
2014/04/02 07:16:01
Pass this in a scoped_ptr to make the ownership se
Steve Condie
2014/04/02 18:48:15
Done.
|
| virtual ~CloudPolicyInvalidator(); |
| // Initializes the invalidator. No invalidations will be generated before this |
| @@ -92,7 +100,7 @@ class CloudPolicyInvalidator : public syncer::InvalidationHandler, |
| void UpdateRegistration(const enterprise_management::PolicyData* policy); |
| // Registers the given object with the invalidation service. |
| - void Register(int64 timestamp, const invalidation::ObjectId& object_id); |
| + void Register(const invalidation::ObjectId& object_id); |
| // Unregisters the current object with the invalidation service. |
| void Unregister(); |
| @@ -121,6 +129,9 @@ class CloudPolicyInvalidator : public syncer::InvalidationHandler, |
| // when a policy is stored. |
| int GetPolicyRefreshMetric(bool policy_changed); |
| + // Determine if invalidations have been enabled longer than the grace period. |
| + bool GetInvalidationsEnabled(); |
| + |
| // The state of the object. |
| enum State { |
| UNINITIALIZED, |
| @@ -136,6 +147,9 @@ class CloudPolicyInvalidator : public syncer::InvalidationHandler, |
| // Schedules delayed tasks. |
| const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| + // The clock. |
| + scoped_ptr<base::Clock> clock_; |
| + |
| // The invalidation service. |
| invalidation::InvalidationService* invalidation_service_; |
| @@ -144,12 +158,14 @@ class CloudPolicyInvalidator : public syncer::InvalidationHandler, |
| // has registered for a policy object. |
| bool invalidations_enabled_; |
| + // The time that invalidations became enabled. |
| + base::Time invalidations_enabled_time_; |
| + |
| // Whether the invalidation service is currently enabled. |
| bool invalidation_service_enabled_; |
| - // The timestamp of the PolicyData at which this object registered for policy |
| - // invalidations. Set to zero if the object has not registered yet. |
| - int64 registered_timestamp_; |
| + // Whether this object has registered for policy invalidations. |
| + bool is_registered_; |
| // The object id representing the policy in the invalidation service. |
| invalidation::ObjectId object_id_; |