| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/hash.h" | 10 #include "base/hash.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 // the version and payload on the client immediately. Otherwise, the refresh | 259 // the version and payload on the client immediately. Otherwise, the refresh |
| 260 // must only run after at least kMissingPayloadDelay minutes. | 260 // must only run after at least kMissingPayloadDelay minutes. |
| 261 if (!payload.empty()) | 261 if (!payload.empty()) |
| 262 core_->client()->SetInvalidationInfo(version, payload); | 262 core_->client()->SetInvalidationInfo(version, payload); |
| 263 else | 263 else |
| 264 delay += base::TimeDelta::FromMinutes(kMissingPayloadDelay); | 264 delay += base::TimeDelta::FromMinutes(kMissingPayloadDelay); |
| 265 | 265 |
| 266 // Schedule the policy to be refreshed. | 266 // Schedule the policy to be refreshed. |
| 267 task_runner_->PostDelayedTask( | 267 task_runner_->PostDelayedTask( |
| 268 FROM_HERE, | 268 FROM_HERE, |
| 269 base::Bind( | 269 base::BindOnce(&CloudPolicyInvalidator::RefreshPolicy, |
| 270 &CloudPolicyInvalidator::RefreshPolicy, | 270 weak_factory_.GetWeakPtr(), |
| 271 weak_factory_.GetWeakPtr(), | 271 payload.empty() /* is_missing_payload */), |
| 272 payload.empty() /* is_missing_payload */), | |
| 273 delay); | 272 delay); |
| 274 } | 273 } |
| 275 | 274 |
| 276 void CloudPolicyInvalidator::UpdateRegistration( | 275 void CloudPolicyInvalidator::UpdateRegistration( |
| 277 const enterprise_management::PolicyData* policy) { | 276 const enterprise_management::PolicyData* policy) { |
| 278 // Create the ObjectId based on the policy data. | 277 // Create the ObjectId based on the policy data. |
| 279 // If the policy does not specify an the ObjectId, then unregister. | 278 // If the policy does not specify an the ObjectId, then unregister. |
| 280 if (!policy || | 279 if (!policy || |
| 281 !policy->has_invalidation_source() || | 280 !policy->has_invalidation_source() || |
| 282 !policy->has_invalidation_name()) { | 281 !policy->has_invalidation_name()) { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 bool CloudPolicyInvalidator::GetInvalidationsEnabled() { | 438 bool CloudPolicyInvalidator::GetInvalidationsEnabled() { |
| 440 if (!invalidations_enabled_) | 439 if (!invalidations_enabled_) |
| 441 return false; | 440 return false; |
| 442 // If invalidations have been enabled for less than the grace period, then | 441 // If invalidations have been enabled for less than the grace period, then |
| 443 // consider invalidations to be disabled for metrics reporting. | 442 // consider invalidations to be disabled for metrics reporting. |
| 444 base::TimeDelta elapsed = clock_->Now() - invalidations_enabled_time_; | 443 base::TimeDelta elapsed = clock_->Now() - invalidations_enabled_time_; |
| 445 return elapsed.InSeconds() >= kInvalidationGracePeriod; | 444 return elapsed.InSeconds() >= kInvalidationGracePeriod; |
| 446 } | 445 } |
| 447 | 446 |
| 448 } // namespace policy | 447 } // namespace policy |
| OLD | NEW |