Chromium Code Reviews| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 15 #include "base/threading/thread_checker.h" | 16 #include "base/threading/thread_checker.h" |
| 16 #include "components/invalidation/invalidation.h" | 17 #include "components/invalidation/invalidation.h" |
| 17 #include "components/invalidation/invalidation_handler.h" | 18 #include "components/invalidation/invalidation_handler.h" |
| 18 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 19 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 19 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 20 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 20 #include "google/cacheinvalidation/include/types.h" | 21 #include "google/cacheinvalidation/include/types.h" |
| 21 | 22 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 49 static const int kInvalidationGracePeriod; | 50 static const int kInvalidationGracePeriod; |
| 50 | 51 |
| 51 // Time, in seconds, for which unknown version invalidations are ignored after | 52 // Time, in seconds, for which unknown version invalidations are ignored after |
| 52 // fetching a policy. | 53 // fetching a policy. |
| 53 static const int kUnknownVersionIgnorePeriod; | 54 static const int kUnknownVersionIgnorePeriod; |
| 54 | 55 |
| 55 // The max tolerated discrepancy, in seconds, between policy timestamps and | 56 // The max tolerated discrepancy, in seconds, between policy timestamps and |
| 56 // invalidation timestamps when determining if an invalidation is expired. | 57 // invalidation timestamps when determining if an invalidation is expired. |
| 57 static const int kMaxInvalidationTimeDelta; | 58 static const int kMaxInvalidationTimeDelta; |
| 58 | 59 |
| 60 // |handling_user_policy| indicates whether this invalidator is responsible | |
| 61 // for user policy (as opposed to device policy). | |
| 59 // |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. |
| 60 // It must remain valid until Shutdown is called. | 63 // It must remain valid until Shutdown is called. |
| 61 // |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 |
| 62 // the main policy thread. | 65 // the main policy thread. |
| 63 // |clock| is used to get the current time. | 66 // |clock| is used to get the current time. |
| 64 CloudPolicyInvalidator( | 67 CloudPolicyInvalidator( |
| 68 bool handling_user_policy, | |
|
Joao da Silva
2014/08/11 13:21:27
WDYT of using enterprise_management::DeviceRegiste
bartfab (slow)
2014/08/11 14:01:59
Done.
| |
| 65 CloudPolicyCore* core, | 69 CloudPolicyCore* core, |
| 66 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 70 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 67 scoped_ptr<base::Clock> clock); | 71 scoped_ptr<base::Clock> clock); |
| 68 virtual ~CloudPolicyInvalidator(); | 72 virtual ~CloudPolicyInvalidator(); |
| 69 | 73 |
| 70 // Initializes the invalidator. No invalidations will be generated before this | 74 // Initializes the invalidator. No invalidations will be generated before this |
| 71 // method is called. This method must only be called once. | 75 // method is called. This method must only be called once. |
| 72 // |invalidation_service| is the invalidation service to use and must remain | 76 // |invalidation_service| is the invalidation service to use and must remain |
| 73 // valid until Shutdown is called. | 77 // valid until Shutdown is called. |
| 74 void Initialize(invalidation::InvalidationService* invalidation_service); | 78 void Initialize(invalidation::InvalidationService* invalidation_service); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 | 153 |
| 150 // The state of the object. | 154 // The state of the object. |
| 151 enum State { | 155 enum State { |
| 152 UNINITIALIZED, | 156 UNINITIALIZED, |
| 153 STOPPED, | 157 STOPPED, |
| 154 STARTED, | 158 STARTED, |
| 155 SHUT_DOWN | 159 SHUT_DOWN |
| 156 }; | 160 }; |
| 157 State state_; | 161 State state_; |
| 158 | 162 |
| 163 // Whether this invalidator is responsible for user policy. | |
| 164 const bool handling_user_policy_; | |
| 165 | |
| 159 // The cloud policy core. | 166 // The cloud policy core. |
| 160 CloudPolicyCore* core_; | 167 CloudPolicyCore* core_; |
| 161 | 168 |
| 162 // Schedules delayed tasks. | 169 // Schedules delayed tasks. |
| 163 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | 170 const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 164 | 171 |
| 165 // The clock. | 172 // The clock. |
| 166 scoped_ptr<base::Clock> clock_; | 173 scoped_ptr<base::Clock> clock_; |
| 167 | 174 |
| 168 // The invalidation service. | 175 // The invalidation service. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 // A thread checker to make sure that callbacks are invoked on the correct | 224 // A thread checker to make sure that callbacks are invoked on the correct |
| 218 // thread. | 225 // thread. |
| 219 base::ThreadChecker thread_checker_; | 226 base::ThreadChecker thread_checker_; |
| 220 | 227 |
| 221 DISALLOW_COPY_AND_ASSIGN(CloudPolicyInvalidator); | 228 DISALLOW_COPY_AND_ASSIGN(CloudPolicyInvalidator); |
| 222 }; | 229 }; |
| 223 | 230 |
| 224 } // namespace policy | 231 } // namespace policy |
| 225 | 232 |
| 226 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ | 233 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_INVALIDATOR_H_ |
| OLD | NEW |