Commit 21a9c9ae authored by sorin@chromium.org's avatar sorin@chromium.org

Consider the last_check time when doing update checks for components.

BUG=344938
R=waffles@chromium.org

Review URL: https://codereview.chromium.org/169033004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252045 0039d316-1c4b-4281-b951-d872f2087c98
parent ef22b1d8
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment