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

Unified Diff: chrome/browser/component_updater/component_updater_service.cc

Issue 169033004: Consider the last_check time when doing update checks for components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/component_updater/component_updater_service.cc
diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc
index 2095c0593a6ac4a2a91f7b5795a35a61249f920a..fa04986f6829511953201f2f4fcabcf416b4cc2b 100644
--- a/chrome/browser/component_updater/component_updater_service.cc
+++ b/chrome/browser/component_updater/component_updater_service.cc
@@ -595,10 +595,13 @@ CrxUpdateItem* CrxUpdateService::FindReadyComponent() const {
}
// Prepares the components for an update check and initiates the request.
+// On demand components are always included in the update check request.
+// Otherwise, only include components that have not been checked recently.
bool CrxUpdateService::CheckForUpdates() {
- // All components are selected for the update check, regardless of when they
- // were last checked. More selective algorithms could be implemented in the
- // future.
+ const base::TimeDelta minimum_recheck_wait_time =
+ base::TimeDelta::FromSeconds(config_->MinimumReCheckWait());
+ const base::Time now(base::Time::Now());
+
std::vector<CrxUpdateItem*> items_to_check;
for (size_t i = 0; i != work_items_.size(); ++i) {
CrxUpdateItem* item = work_items_[i];
@@ -607,9 +610,16 @@ bool CrxUpdateService::CheckForUpdates() {
item->status == CrxUpdateItem::kUpToDate ||
item->status == CrxUpdateItem::kUpdated);
+ const base::TimeDelta time_since_last_checked(now - item->last_check);
+
+ if (!item->on_demand &&
+ time_since_last_checked < minimum_recheck_wait_time) {
+ continue;
+ }
+
ChangeItemState(item, CrxUpdateItem::kChecking);
- item->last_check = base::Time::Now();
+ item->last_check = now;
item->crx_urls.clear();
item->crx_diffurls.clear();
item->previous_version = item->component.version;
@@ -761,7 +771,7 @@ void CrxUpdateService::OnUpdateCheckSucceeded(
// If there are updates pending we do a short wait, otherwise we take
// a longer delay until we check the components again.
- ScheduleNextRun(num_updates_pending > 0 ? kStepDelayShort : kStepDelayMedium);
+ ScheduleNextRun(num_updates_pending > 0 ? kStepDelayShort : kStepDelayLong);
}
// TODO: record UMA stats.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698