Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_refresh_scheduler.h" | 5 #include "chrome/browser/policy/cloud/cloud_policy_refresh_scheduler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 } | 84 } |
| 85 | 85 |
| 86 void CloudPolicyRefreshScheduler::OnRegistrationStateChanged( | 86 void CloudPolicyRefreshScheduler::OnRegistrationStateChanged( |
| 87 CloudPolicyClient* client) { | 87 CloudPolicyClient* client) { |
| 88 error_retry_delay_ms_ = kInitialErrorRetryDelayMs; | 88 error_retry_delay_ms_ = kInitialErrorRetryDelayMs; |
| 89 | 89 |
| 90 // The client might have registered, so trigger an immediate refresh. | 90 // The client might have registered, so trigger an immediate refresh. |
| 91 RefreshNow(); | 91 RefreshNow(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void CloudPolicyRefreshScheduler::OnRobotAuthCodesFetched( | |
|
Mattias Nissler (ping if slow)
2013/04/02 14:16:46
How about we make this an optional override by pro
David Roche
2013/04/04 01:39:53
Done.
| |
| 95 CloudPolicyClient* client) { | |
| 96 // This only happens at registration, which is handled by | |
| 97 // OnRobotAuthCodesFetched above, so no need to fetch policy again. | |
| 98 } | |
| 99 | |
| 94 void CloudPolicyRefreshScheduler::OnClientError(CloudPolicyClient* client) { | 100 void CloudPolicyRefreshScheduler::OnClientError(CloudPolicyClient* client) { |
| 95 // Save the status for below. | 101 // Save the status for below. |
| 96 DeviceManagementStatus status = client_->status(); | 102 DeviceManagementStatus status = client_->status(); |
| 97 | 103 |
| 98 // Schedule an error retry if applicable. | 104 // Schedule an error retry if applicable. |
| 99 last_refresh_ = base::Time::NowFromSystemTime(); | 105 last_refresh_ = base::Time::NowFromSystemTime(); |
| 100 ScheduleRefresh(); | 106 ScheduleRefresh(); |
| 101 | 107 |
| 102 // Update the retry delay. | 108 // Update the retry delay. |
| 103 if (client->is_registered() && | 109 if (client->is_registered() && |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 base::TimeDelta delay = | 229 base::TimeDelta delay = |
| 224 std::max((last_refresh_ + delta) - base::Time::NowFromSystemTime(), | 230 std::max((last_refresh_ + delta) - base::Time::NowFromSystemTime(), |
| 225 base::TimeDelta()); | 231 base::TimeDelta()); |
| 226 refresh_callback_.Reset( | 232 refresh_callback_.Reset( |
| 227 base::Bind(&CloudPolicyRefreshScheduler::PerformRefresh, | 233 base::Bind(&CloudPolicyRefreshScheduler::PerformRefresh, |
| 228 base::Unretained(this))); | 234 base::Unretained(this))); |
| 229 task_runner_->PostDelayedTask(FROM_HERE, refresh_callback_.callback(), delay); | 235 task_runner_->PostDelayedTask(FROM_HERE, refresh_callback_.callback(), delay); |
| 230 } | 236 } |
| 231 | 237 |
| 232 } // namespace policy | 238 } // namespace policy |
| OLD | NEW |