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

Unified Diff: chrome/browser/extensions/updater/extension_updater.cc

Issue 2562963003: Fix DCHECK failure in extension_updater when scheduling first check (Closed)
Patch Set: fix nits Created 4 years 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/extensions/updater/extension_updater_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/updater/extension_updater.cc
diff --git a/chrome/browser/extensions/updater/extension_updater.cc b/chrome/browser/extensions/updater/extension_updater.cc
index 16e57c6690b0a298b2a46dac283c2075bfc960d1..07503e567b6aefa7e2dc361e9f633fc2a0138982 100644
--- a/chrome/browser/extensions/updater/extension_updater.cc
+++ b/chrome/browser/extensions/updater/extension_updater.cc
@@ -54,6 +54,10 @@ namespace {
// you change this value, make sure to update comments where it is used.
const int kStartupWaitSeconds = 60;
+// The minimum number of seconds there should be for the delay passed to
+// ScheduleNextCheck.
+const int kScheduleNextCheckMinGapSecs = 1;
+
// For sanity checking on update frequency - enforced in release mode only.
#if defined(NDEBUG)
const int kMinUpdateFrequencySeconds = 30;
@@ -178,15 +182,15 @@ TimeDelta ExtensionUpdater::DetermineFirstCheckDelay() {
return TimeDelta::FromSeconds(
RandInt(kStartupWaitSeconds, frequency_seconds_));
+ // Read the persisted next check time, and use that if it isn't in the past
+ // or too far in the future (this can happen with system clock changes).
Time saved_next = Time::FromInternalValue(prefs_->GetInt64(
pref_names::kNextUpdateCheck));
-
Time now = Time::Now();
-
- // Read the persisted next check time, and use that if it isn't in the past
- // or too far in the future (this can happen with system clock changes).
- if (saved_next > now &&
- saved_next < now + TimeDelta::FromSeconds(frequency_seconds_)) {
+ base::Time earliest =
+ now + TimeDelta::FromSeconds(kScheduleNextCheckMinGapSecs);
+ base::Time latest = now + TimeDelta::FromSeconds(frequency_seconds_);
+ if (saved_next > earliest && saved_next < latest) {
return saved_next - now;
}
@@ -225,7 +229,7 @@ void ExtensionUpdater::Stop() {
void ExtensionUpdater::ScheduleNextCheck(const TimeDelta& target_delay) {
DCHECK(alive_);
DCHECK(!timer_.IsRunning());
- DCHECK(target_delay >= TimeDelta::FromSeconds(1));
+ DCHECK(target_delay >= TimeDelta::FromSeconds(kScheduleNextCheckMinGapSecs));
// Add +/- 10% random jitter.
double delay_ms = target_delay.InMillisecondsF();
« no previous file with comments | « no previous file | chrome/browser/extensions/updater/extension_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698