OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } else if (days >= 14) { | 186 } else if (days >= 14) { |
187 // Wait 10-20 minutes. | 187 // Wait 10-20 minutes. |
188 return TimeDelta::FromSeconds(RandInt(kStartupWaitSeconds * 2, | 188 return TimeDelta::FromSeconds(RandInt(kStartupWaitSeconds * 2, |
189 kStartupWaitSeconds * 4)); | 189 kStartupWaitSeconds * 4)); |
190 } else if (days >= 3) { | 190 } else if (days >= 3) { |
191 // Wait 20-40 minutes. | 191 // Wait 20-40 minutes. |
192 return TimeDelta::FromSeconds(RandInt(kStartupWaitSeconds * 4, | 192 return TimeDelta::FromSeconds(RandInt(kStartupWaitSeconds * 4, |
193 kStartupWaitSeconds * 8)); | 193 kStartupWaitSeconds * 8)); |
194 } | 194 } |
195 | 195 |
196 // Read the persisted next check time, and use that if it isn't too soon. | 196 // Read the persisted next check time, and use that if it isn't too soon |
197 // Otherwise pick something random. | 197 // or too late. Otherwise pick something random. |
198 Time saved_next = Time::FromInternalValue(prefs_->GetInt64( | 198 Time saved_next = Time::FromInternalValue(prefs_->GetInt64( |
199 pref_names::kNextUpdateCheck)); | 199 pref_names::kNextUpdateCheck)); |
200 Time earliest = now + TimeDelta::FromSeconds(kStartupWaitSeconds); | 200 Time earliest = now + TimeDelta::FromSeconds(kStartupWaitSeconds); |
201 if (saved_next >= earliest) { | 201 Time latest = now + TimeDelta::FromSeconds(frequency_seconds_); |
| 202 if (saved_next >= earliest && saved_next <= latest) { |
202 return saved_next - now; | 203 return saved_next - now; |
203 } else { | 204 } else { |
204 return TimeDelta::FromSeconds(RandInt(kStartupWaitSeconds, | 205 return TimeDelta::FromSeconds(RandInt(kStartupWaitSeconds, |
205 frequency_seconds_)); | 206 frequency_seconds_)); |
206 } | 207 } |
207 } | 208 } |
208 | 209 |
209 void ExtensionUpdater::Start() { | 210 void ExtensionUpdater::Start() { |
210 DCHECK(!alive_); | 211 DCHECK(!alive_); |
211 // If these are NULL, then that means we've been called after Stop() | 212 // If these are NULL, then that means we've been called after Stop() |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 const InProgressCheck& request = requests_in_progress_[request_id]; | 644 const InProgressCheck& request = requests_in_progress_[request_id]; |
644 if (request.in_progress_ids_.empty()) { | 645 if (request.in_progress_ids_.empty()) { |
645 VLOG(2) << "Finished update check " << request_id; | 646 VLOG(2) << "Finished update check " << request_id; |
646 if (!request.callback.is_null()) | 647 if (!request.callback.is_null()) |
647 request.callback.Run(); | 648 request.callback.Run(); |
648 requests_in_progress_.erase(request_id); | 649 requests_in_progress_.erase(request_id); |
649 } | 650 } |
650 } | 651 } |
651 | 652 |
652 } // namespace extensions | 653 } // namespace extensions |
OLD | NEW |