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

Side by Side Diff: chrome/browser/extensions/updater/extension_updater.cc

Issue 2562963003: Fix DCHECK failure in extension_updater when scheduling first check (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
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/extensions/updater/extension_updater.h" 5 #include "chrome/browser/extensions/updater/extension_updater.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // If someone's testing with a quick frequency, just allow it. 171 // If someone's testing with a quick frequency, just allow it.
172 if (frequency_seconds_ < kStartupWaitSeconds) 172 if (frequency_seconds_ < kStartupWaitSeconds)
173 return TimeDelta::FromSeconds(frequency_seconds_); 173 return TimeDelta::FromSeconds(frequency_seconds_);
174 174
175 // If we've never scheduled a check before, start at a random time up to 175 // If we've never scheduled a check before, start at a random time up to
176 // frequency_seconds_ away. 176 // frequency_seconds_ away.
177 if (!prefs_->HasPrefPath(pref_names::kNextUpdateCheck)) 177 if (!prefs_->HasPrefPath(pref_names::kNextUpdateCheck))
178 return TimeDelta::FromSeconds( 178 return TimeDelta::FromSeconds(
179 RandInt(kStartupWaitSeconds, frequency_seconds_)); 179 RandInt(kStartupWaitSeconds, frequency_seconds_));
180 180
181 // Read the persisted next check time, and use that if it isn't in the past
182 // or too far in the future (this can happen with system clock changes).
181 Time saved_next = Time::FromInternalValue(prefs_->GetInt64( 183 Time saved_next = Time::FromInternalValue(prefs_->GetInt64(
182 pref_names::kNextUpdateCheck)); 184 pref_names::kNextUpdateCheck));
183
184 Time now = Time::Now(); 185 Time now = Time::Now();
185 186 base::Time earliest = now + TimeDelta::FromSeconds(1);
lazyboy 2016/12/10 00:10:15 The value 1 is coming from ExtensionUpdater::Sche
asargent_no_longer_on_chrome 2016/12/14 23:01:19 Done.
186 // Read the persisted next check time, and use that if it isn't in the past 187 base::Time latest = now + TimeDelta::FromSeconds(frequency_seconds_);
187 // or too far in the future (this can happen with system clock changes). 188 if (saved_next > earliest && saved_next < latest) {
188 if (saved_next > now &&
189 saved_next < now + TimeDelta::FromSeconds(frequency_seconds_)) {
190 return saved_next - now; 189 return saved_next - now;
191 } 190 }
192 191
193 // In most cases we'll get here because the persisted next check time passed 192 // In most cases we'll get here because the persisted next check time passed
194 // while we weren't running, so pick something soon. 193 // while we weren't running, so pick something soon.
195 return TimeDelta::FromSeconds( 194 return TimeDelta::FromSeconds(
196 RandInt(kStartupWaitSeconds, kStartupWaitSeconds * 5)); 195 RandInt(kStartupWaitSeconds, kStartupWaitSeconds * 5));
197 } 196 }
198 197
199 void ExtensionUpdater::Start() { 198 void ExtensionUpdater::Start() {
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 const InProgressCheck& request = requests_in_progress_[request_id]; 597 const InProgressCheck& request = requests_in_progress_[request_id];
599 if (request.in_progress_ids_.empty()) { 598 if (request.in_progress_ids_.empty()) {
600 VLOG(2) << "Finished update check " << request_id; 599 VLOG(2) << "Finished update check " << request_id;
601 if (!request.callback.is_null()) 600 if (!request.callback.is_null())
602 request.callback.Run(); 601 request.callback.Run();
603 requests_in_progress_.erase(request_id); 602 requests_in_progress_.erase(request_id);
604 } 603 }
605 } 604 }
606 605
607 } // namespace extensions 606 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698