| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/hash.h" | 8 #include "base/hash.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 // Update internal state. | 301 // Update internal state. |
| 302 if (invalid_) | 302 if (invalid_) |
| 303 AcknowledgeInvalidation(); | 303 AcknowledgeInvalidation(); |
| 304 is_registered_ = true; | 304 is_registered_ = true; |
| 305 object_id_ = object_id; | 305 object_id_ = object_id; |
| 306 UpdateInvalidationsEnabled(); | 306 UpdateInvalidationsEnabled(); |
| 307 | 307 |
| 308 // Update registration with the invalidation service. | 308 // Update registration with the invalidation service. |
| 309 syncer::ObjectIdSet ids; | 309 syncer::ObjectIdSet ids; |
| 310 ids.insert(object_id); | 310 ids.insert(object_id); |
| 311 invalidation_service_->UpdateRegisteredInvalidationIds(this, ids); | 311 CHECK(invalidation_service_->UpdateRegisteredInvalidationIds(this, ids)); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void CloudPolicyInvalidator::Unregister() { | 314 void CloudPolicyInvalidator::Unregister() { |
| 315 if (is_registered_) { | 315 if (is_registered_) { |
| 316 if (invalid_) | 316 if (invalid_) |
| 317 AcknowledgeInvalidation(); | 317 AcknowledgeInvalidation(); |
| 318 invalidation_service_->UpdateRegisteredInvalidationIds( | 318 CHECK(invalidation_service_->UpdateRegisteredInvalidationIds( |
| 319 this, | 319 this, syncer::ObjectIdSet())); |
| 320 syncer::ObjectIdSet()); | |
| 321 invalidation_service_->UnregisterInvalidationHandler(this); | 320 invalidation_service_->UnregisterInvalidationHandler(this); |
| 322 is_registered_ = false; | 321 is_registered_ = false; |
| 323 UpdateInvalidationsEnabled(); | 322 UpdateInvalidationsEnabled(); |
| 324 } | 323 } |
| 325 } | 324 } |
| 326 | 325 |
| 327 void CloudPolicyInvalidator::UpdateMaxFetchDelay(const PolicyMap& policy_map) { | 326 void CloudPolicyInvalidator::UpdateMaxFetchDelay(const PolicyMap& policy_map) { |
| 328 int delay; | 327 int delay; |
| 329 | 328 |
| 330 // Try reading the delay from the policy. | 329 // Try reading the delay from the policy. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 bool CloudPolicyInvalidator::GetInvalidationsEnabled() { | 437 bool CloudPolicyInvalidator::GetInvalidationsEnabled() { |
| 439 if (!invalidations_enabled_) | 438 if (!invalidations_enabled_) |
| 440 return false; | 439 return false; |
| 441 // If invalidations have been enabled for less than the grace period, then | 440 // If invalidations have been enabled for less than the grace period, then |
| 442 // consider invalidations to be disabled for metrics reporting. | 441 // consider invalidations to be disabled for metrics reporting. |
| 443 base::TimeDelta elapsed = clock_->Now() - invalidations_enabled_time_; | 442 base::TimeDelta elapsed = clock_->Now() - invalidations_enabled_time_; |
| 444 return elapsed.InSeconds() >= kInvalidationGracePeriod; | 443 return elapsed.InSeconds() >= kInvalidationGracePeriod; |
| 445 } | 444 } |
| 446 | 445 |
| 447 } // namespace policy | 446 } // namespace policy |
| OLD | NEW |