Chromium Code Reviews| Index: chrome/browser/component_updater/component_updater_service.cc |
| =================================================================== |
| --- chrome/browser/component_updater/component_updater_service.cc (revision 177059) |
| +++ chrome/browser/component_updater/component_updater_service.cc (working copy) |
| @@ -45,6 +45,13 @@ |
| // base::Bind() calls are not refcounted. |
| namespace { |
| +// Manifest sources, from most important to least important. |
| +const CrxComponent::UrlSource kManifestSources[] = { |
| + CrxComponent::BANDAID, |
| + CrxComponent::CWS_PUBLIC, |
| + CrxComponent::CWS_SANDBOX |
| +}; |
| + |
| // Extends an omaha compatible update check url |query| string. Does |
| // not mutate the string if it would be longer than |limit| chars. |
| bool AddQueryString(const std::string& id, |
| @@ -215,9 +222,14 @@ |
| typedef ComponentUpdateService::Configurator Config; |
| -CrxComponent::CrxComponent() : installer(NULL) {} |
| -CrxComponent::~CrxComponent() {} |
| +CrxComponent::CrxComponent() |
| + : installer(NULL), |
| + source(BANDAID) { |
|
cpu_(ooo_6.6-7.5)
2013/01/21 02:47:19
the default source is the current one so I don't h
|
| +} |
| +CrxComponent::~CrxComponent() { |
| +} |
| + |
| ////////////////////////////////////////////////////////////////////////////// |
| // The one and only implementation of the ComponentUpdateService interface. In |
| // charge of running the show. The main method is ProcessPendingItems() which |
| @@ -515,64 +527,80 @@ |
| return; |
| } |
|
cpu_(ooo_6.6-7.5)
2013/01/21 02:47:19
this new for loop is the meat of the change. Basic
|
| - std::string query; |
| - // If no pending upgrades, we check the if there are new |
| - // components we have not checked against the server. We |
| - // can batch a bunch in a single url request. |
| - for (UpdateItems::const_iterator it = work_items_.begin(); |
| - it != work_items_.end(); ++it) { |
| - CrxUpdateItem* item = *it; |
| - if (item->status != CrxUpdateItem::kNew) |
| - continue; |
| - if (!AddItemToUpdateCheck(item, &query)) |
| - break; |
| - } |
| + for (size_t ix = 0; ix != arraysize(kManifestSources); ++ix) { |
| + const CrxComponent::UrlSource manifest_source = kManifestSources[ix]; |
| - // Next we can go back to components we already checked, here |
| - // we can also batch them in a single url request, as long as |
| - // we have not checked them recently. |
| - const base::TimeDelta min_delta_time = |
| - base::TimeDelta::FromSeconds(config_->MinimumReCheckWait()); |
| + std::string query; |
| + // If no pending upgrades, we check the if there are new |
|
asargent_no_longer_on_chrome
2013/01/23 17:58:32
typo: "we check the if there"
cpu_(ooo_6.6-7.5)
2013/01/23 18:56:06
Done.
|
| + // components we have not checked against the server. We |
| + // can batch a bunch in a single url request. |
| + for (UpdateItems::const_iterator it = work_items_.begin(); |
| + it != work_items_.end(); ++it) { |
| + CrxUpdateItem* item = *it; |
| + if (item->status != CrxUpdateItem::kNew) |
| + continue; |
| + if (item->component.source != manifest_source) |
| + continue; |
| + if (!AddItemToUpdateCheck(item, &query)) |
| + break; |
| + } |
| - for (UpdateItems::const_iterator it = work_items_.begin(); |
| - it != work_items_.end(); ++it) { |
| - CrxUpdateItem* item = *it; |
| - if ((item->status != CrxUpdateItem::kNoUpdate) && |
| - (item->status != CrxUpdateItem::kUpToDate)) |
| + // Next we can go back to components we already checked, here |
| + // we can also batch them in a single url request, as long as |
| + // we have not checked them recently. |
| + const base::TimeDelta min_delta_time = |
| + base::TimeDelta::FromSeconds(config_->MinimumReCheckWait()); |
| + |
| + for (UpdateItems::const_iterator it = work_items_.begin(); |
| + it != work_items_.end(); ++it) { |
| + CrxUpdateItem* item = *it; |
| + if ((item->status != CrxUpdateItem::kNoUpdate) && |
| + (item->status != CrxUpdateItem::kUpToDate)) |
| + continue; |
| + if (item->component.source != manifest_source) |
| + continue; |
| + base::TimeDelta delta = base::Time::Now() - item->last_check; |
| + if (delta < min_delta_time) |
| + continue; |
| + if (!AddItemToUpdateCheck(item, &query)) |
| + break; |
| + } |
| + |
| + // Finally, we check components that we already updated as long |
| + // we have not checked them recently. |
|
asargent_no_longer_on_chrome
2013/01/23 17:58:32
typo: comment should say "..updated as long as we
cpu_(ooo_6.6-7.5)
2013/01/23 18:56:06
Done.
|
| + for (UpdateItems::const_iterator it = work_items_.begin(); |
| + it != work_items_.end(); ++it) { |
| + CrxUpdateItem* item = *it; |
| + if (item->status != CrxUpdateItem::kUpdated) |
| + continue; |
| + if (item->component.source != manifest_source) |
| + continue; |
| + base::TimeDelta delta = base::Time::Now() - item->last_check; |
| + if (delta < min_delta_time) |
| + continue; |
| + if (!AddItemToUpdateCheck(item, &query)) |
| + break; |
| + } |
|
asargent_no_longer_on_chrome
2013/01/23 17:58:32
I assume that work_items_ will always be very shor
cpu_(ooo_6.6-7.5)
2013/01/23 18:56:06
Yep, currently at 4 items.
On 2013/01/23 17:58:32
|
| + |
| + // If no components to update we move down to the next source. |
| + if (query.empty()) |
| continue; |
| - base::TimeDelta delta = base::Time::Now() - item->last_check; |
| - if (delta < min_delta_time) |
| - continue; |
| - if (!AddItemToUpdateCheck(item, &query)) |
| - break; |
| - } |
| - // Finally, we check components that we already updated. |
| - for (UpdateItems::const_iterator it = work_items_.begin(); |
| - it != work_items_.end(); ++it) { |
| - CrxUpdateItem* item = *it; |
| - if (item->status != CrxUpdateItem::kUpdated) |
| - continue; |
| - base::TimeDelta delta = base::Time::Now() - item->last_check; |
| - if (delta < min_delta_time) |
| - continue; |
| - if (!AddItemToUpdateCheck(item, &query)) |
| - break; |
| - } |
| - if (query.empty()) { |
| - // Next check after the long sleep. |
| - ScheduleNextRun(false); |
| + // We got components to check. Start the url request and exit. |
| + const std::string full_query = |
| + MakeFinalQuery(config_->UpdateUrl(manifest_source).spec(), |
| + query, |
| + config_->ExtraRequestParams()); |
| + |
| + url_fetcher_.reset(net::URLFetcher::Create( |
| + 0, GURL(full_query), net::URLFetcher::GET, |
| + MakeContextDelegate(this, new UpdateContext()))); |
| + StartFetch(url_fetcher_.get(), config_->RequestContext(), false); |
| return; |
| } |
| - // We got components to check. Start the url request. |
| - const std::string full_query = MakeFinalQuery(config_->UpdateUrl().spec(), |
| - query, |
| - config_->ExtraRequestParams()); |
| - url_fetcher_.reset(net::URLFetcher::Create( |
| - 0, GURL(full_query), net::URLFetcher::GET, |
| - MakeContextDelegate(this, new UpdateContext()))); |
| - StartFetch(url_fetcher_.get(), config_->RequestContext(), false); |
| + // No components to update. Next check after the long sleep. |
| + ScheduleNextRun(false); |
| } |
| // Caled when we got a response from the update server. It consists of an xml |