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

Unified Diff: components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h

Issue 2638923002: Device policy refresh fixed when the device is woken up. (Closed)
Patch Set: Fixed the tests Created 3 years, 10 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 | components/policy/core/common/cloud/cloud_policy_refresh_scheduler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h
diff --git a/components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h b/components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h
index f82052e1c7418b12b1682215c558d1c638db8d03..7110c94aaf76f32d30f8cea120fca6934b4dc4e2 100644
--- a/components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h
+++ b/components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h
@@ -83,6 +83,7 @@ class POLICY_EXPORT CloudPolicyRefreshScheduler
void OnStoreError(CloudPolicyStore* store) override;
// net::NetworkChangeNotifier::IPAddressObserver:
+ // Triggered also when the device wakes up.
void OnIPAddressChanged() override;
private:
@@ -101,12 +102,15 @@ class POLICY_EXPORT CloudPolicyRefreshScheduler
void PerformRefresh();
// Schedules a policy refresh to happen no later than |delta_ms| msecs after
- // |last_refresh_|.
+ // |last_refresh_| or |last_refresh_ticks_| whichever is sooner.
void RefreshAfter(int delta_ms);
// Cancels the scheduled policy refresh.
void CancelRefresh();
+ // Sets the |last_refresh_| and |last_refresh_ticks_| to current time.
+ void UpdateLastRefresh();
+
CloudPolicyClient* client_;
CloudPolicyStore* store_;
@@ -120,9 +124,15 @@ class POLICY_EXPORT CloudPolicyRefreshScheduler
// |RefreshNow|).
bool is_scheduled_for_soon_ = false;
- // The last time a refresh callback completed.
+ // The last time a refresh callback completed. Is null in case the client is
+ // not registered.
base::Time last_refresh_;
+ // The same |last_refresh_|, but based on TimeTicks. This allows to schedule
+ // the refresh times based on both, system time and TimeTicks, providing a
+ // protection against changes in system time.
+ base::TimeTicks last_refresh_ticks_;
+
// Error retry delay in milliseconds.
int64_t error_retry_delay_ms_;
« no previous file with comments | « no previous file | components/policy/core/common/cloud/cloud_policy_refresh_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698