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 #include "chrome/browser/policy/cloud/cloud_policy_invalidator.h" | 5 #include "chrome/browser/policy/cloud/cloud_policy_invalidator.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/hash.h" | 10 #include "base/hash.h" |
9 #include "base/location.h" | 11 #include "base/location.h" |
10 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
11 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
12 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
13 #include "base/time/clock.h" | 15 #include "base/time/clock.h" |
14 #include "base/time/time.h" | 16 #include "base/time/time.h" |
15 #include "base/values.h" | 17 #include "base/values.h" |
16 #include "components/invalidation/public/invalidation_service.h" | 18 #include "components/invalidation/public/invalidation_service.h" |
(...skipping 16 matching lines...) Expand all Loading... |
33 CloudPolicyInvalidator::CloudPolicyInvalidator( | 35 CloudPolicyInvalidator::CloudPolicyInvalidator( |
34 enterprise_management::DeviceRegisterRequest::Type type, | 36 enterprise_management::DeviceRegisterRequest::Type type, |
35 CloudPolicyCore* core, | 37 CloudPolicyCore* core, |
36 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 38 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
37 scoped_ptr<base::Clock> clock, | 39 scoped_ptr<base::Clock> clock, |
38 int64_t highest_handled_invalidation_version) | 40 int64_t highest_handled_invalidation_version) |
39 : state_(UNINITIALIZED), | 41 : state_(UNINITIALIZED), |
40 type_(type), | 42 type_(type), |
41 core_(core), | 43 core_(core), |
42 task_runner_(task_runner), | 44 task_runner_(task_runner), |
43 clock_(clock.Pass()), | 45 clock_(std::move(clock)), |
44 invalidation_service_(NULL), | 46 invalidation_service_(NULL), |
45 invalidations_enabled_(false), | 47 invalidations_enabled_(false), |
46 invalidation_service_enabled_(false), | 48 invalidation_service_enabled_(false), |
47 is_registered_(false), | 49 is_registered_(false), |
48 invalid_(false), | 50 invalid_(false), |
49 invalidation_version_(0), | 51 invalidation_version_(0), |
50 unknown_version_invalidation_count_(0), | 52 unknown_version_invalidation_count_(0), |
51 highest_handled_invalidation_version_( | 53 highest_handled_invalidation_version_( |
52 highest_handled_invalidation_version), | 54 highest_handled_invalidation_version), |
53 max_fetch_delay_(kMaxFetchDelayDefault), | 55 max_fetch_delay_(kMaxFetchDelayDefault), |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 bool CloudPolicyInvalidator::GetInvalidationsEnabled() { | 439 bool CloudPolicyInvalidator::GetInvalidationsEnabled() { |
438 if (!invalidations_enabled_) | 440 if (!invalidations_enabled_) |
439 return false; | 441 return false; |
440 // If invalidations have been enabled for less than the grace period, then | 442 // If invalidations have been enabled for less than the grace period, then |
441 // consider invalidations to be disabled for metrics reporting. | 443 // consider invalidations to be disabled for metrics reporting. |
442 base::TimeDelta elapsed = clock_->Now() - invalidations_enabled_time_; | 444 base::TimeDelta elapsed = clock_->Now() - invalidations_enabled_time_; |
443 return elapsed.InSeconds() >= kInvalidationGracePeriod; | 445 return elapsed.InSeconds() >= kInvalidationGracePeriod; |
444 } | 446 } |
445 | 447 |
446 } // namespace policy | 448 } // namespace policy |
OLD | NEW |