Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1339)

Unified Diff: chrome/browser/policy/cloud_policy_refresh_scheduler.cc

Issue 10913118: Don't refresh policy immediately when fetched already. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/policy/cloud_policy_refresh_scheduler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dc19b5dd1deac61c591610e934174b38b039965f..da011dfaf33218e603ada371fc0cb8721734df55 100644
--- a/chrome/browser/policy/cloud_policy_refresh_scheduler.cc
+++ b/chrome/browser/policy/cloud_policy_refresh_scheduler.cc
@@ -116,8 +116,21 @@ void CloudPolicyRefreshScheduler::OnIPAddressChanged() {
}
void CloudPolicyRefreshScheduler::UpdateLastRefreshFromPolicy() {
- if (store_->has_policy() && !store_->is_managed() &&
- last_refresh_.is_null()) {
+ if (!last_refresh_.is_null())
+ return;
+
+ // If the client has already fetched policy, assume that happened recently. If
+ // that assumption ever breaks, the proper thing to do probably is to move the
+ // |last_refresh_| bookkeeping to CloudPolicyClient.
+ if (client_->policy()) {
+ last_refresh_ = base::Time::NowFromSystemTime();
+ return;
+ }
+
+ // If there is a cached non-managed response, make sure to only re-query the
+ // server after kUnmanagedRefreshDelayMs. NB: For existing policy, an
+ // immediate refresh is intentional.
+ if (store_->has_policy() && !store_->is_managed()) {
last_refresh_ =
base::Time::UnixEpoch() +
base::TimeDelta::FromMilliseconds(store_->policy()->timestamp());
« no previous file with comments | « no previous file | chrome/browser/policy/cloud_policy_refresh_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698