Index: chrome/browser/policy/cloud_policy_refresh_scheduler.cc |
diff --git a/chrome/browser/policy/cloud_policy_refresh_scheduler.cc b/chrome/browser/policy/cloud_policy_refresh_scheduler.cc |
index 8132be5dae4cdcacf51f94614836707678e08a51..b4031837a8b653e0c93e49e741a7fedf83f46cad 100644 |
--- a/chrome/browser/policy/cloud_policy_refresh_scheduler.cc |
+++ b/chrome/browser/policy/cloud_policy_refresh_scheduler.cc |
@@ -14,6 +14,8 @@ |
namespace policy { |
+const int64 CloudPolicyRefreshScheduler::kDefaultRefreshDelayMs = |
+ 3 * 60 * 60 * 1000; // 3 hours. |
const int64 CloudPolicyRefreshScheduler::kUnmanagedRefreshDelayMs = |
24 * 60 * 60 * 1000; // 1 day. |
const int64 CloudPolicyRefreshScheduler::kInitialErrorRetryDelayMs = |
@@ -26,22 +28,16 @@ const int64 CloudPolicyRefreshScheduler::kRefreshDelayMaxMs = |
CloudPolicyRefreshScheduler::CloudPolicyRefreshScheduler( |
CloudPolicyClient* client, |
CloudPolicyStore* store, |
- PrefService* prefs, |
- const std::string& refresh_pref, |
const scoped_refptr<base::TaskRunner>& task_runner) |
: client_(client), |
store_(store), |
task_runner_(task_runner), |
- error_retry_delay_ms_(kInitialErrorRetryDelayMs) { |
+ error_retry_delay_ms_(kInitialErrorRetryDelayMs), |
+ refresh_delay_ms_(kDefaultRefreshDelayMs) { |
client_->AddObserver(this); |
store_->AddObserver(this); |
net::NetworkChangeNotifier::AddIPAddressObserver(this); |
- refresh_delay_.Init( |
- refresh_pref.c_str(), prefs, |
- base::Bind(&CloudPolicyRefreshScheduler::ScheduleRefresh, |
- base::Unretained(this))); |
- |
UpdateLastRefreshFromPolicy(); |
ScheduleRefresh(); |
} |
@@ -52,6 +48,11 @@ CloudPolicyRefreshScheduler::~CloudPolicyRefreshScheduler() { |
net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
} |
+void CloudPolicyRefreshScheduler::SetRefreshDelay(int64 refresh_delay) { |
+ refresh_delay_ms_ = refresh_delay; |
bartfab (slow)
2012/12/04 12:25:18
Why not clamp when setting the value here instead
Mattias Nissler (ping if slow)
2012/12/04 13:20:40
Doesn't matter really, but I guess what you propos
|
+ ScheduleRefresh(); |
+} |
+ |
void CloudPolicyRefreshScheduler::OnPolicyFetched(CloudPolicyClient* client) { |
error_retry_delay_ms_ = kInitialErrorRetryDelayMs; |
@@ -203,8 +204,7 @@ void CloudPolicyRefreshScheduler::RefreshAfter(int delta_ms) { |
} |
int64 CloudPolicyRefreshScheduler::GetRefreshDelay() { |
- return std::min(std::max<int64>(refresh_delay_.GetValue(), |
- kRefreshDelayMinMs), |
+ return std::min(std::max(refresh_delay_ms_, kRefreshDelayMinMs), |
kRefreshDelayMaxMs); |
} |