| 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 ed3d0752312512eb0ada958f1f834caa146a2ba9..555c194cf274da68520681d19405a4508209c309 100644
|
| --- a/chrome/browser/component_updater/component_updater_service.cc
|
| +++ b/chrome/browser/component_updater/component_updater_service.cc
|
| @@ -253,6 +253,7 @@ class CrxUpdateService : public ComponentUpdateService {
|
| virtual Status Start() OVERRIDE;
|
| virtual Status Stop() OVERRIDE;
|
| virtual Status RegisterComponent(const CrxComponent& component) OVERRIDE;
|
| + virtual Status PingUpdateCheck(const CrxComponent& component) OVERRIDE;
|
|
|
| // The only purpose of this class is to forward the
|
| // UtilityProcessHostClient callbacks so CrxUpdateService does
|
| @@ -323,6 +324,9 @@ class CrxUpdateService : public ComponentUpdateService {
|
|
|
| void ProcessPendingItems();
|
|
|
| + typedef std::vector<CrxUpdateItem*> UpdateItems;
|
| + void ProcessWorkItems(const UpdateItems& work_items);
|
| +
|
| void ScheduleNextRun(bool step_delay);
|
|
|
| void ParseManifest(const std::string& xml);
|
| @@ -341,7 +345,6 @@ class CrxUpdateService : public ComponentUpdateService {
|
|
|
| scoped_ptr<net::URLFetcher> url_fetcher_;
|
|
|
| - typedef std::vector<CrxUpdateItem*> UpdateItems;
|
| UpdateItems work_items_;
|
|
|
| base::OneShotTimer<CrxUpdateService> timer_;
|
| @@ -488,6 +491,31 @@ ComponentUpdateService::Status CrxUpdateService::RegisterComponent(
|
| return kOk;
|
| }
|
|
|
| +// Start the process of checking for an update, for a particular component
|
| +// that was previously registered. If the component does not exist return
|
| +// kError, otherwise kOk.
|
| +ComponentUpdateService::Status CrxUpdateService::PingUpdateCheck(
|
| + const CrxComponent& component) {
|
| + if (component.pk_hash.empty() ||
|
| + !component.version.IsValid() ||
|
| + !component.installer)
|
| + return kError;
|
| +
|
| + std::string id =
|
| + HexStringToID(StringToLowerASCII(base::HexEncode(&component.pk_hash[0],
|
| + component.pk_hash.size()/2)));
|
| + CrxUpdateItem* uit;
|
| + uit = FindUpdateItemById(id);
|
| + if (!uit)
|
| + return kError;
|
| +
|
| + UpdateItems one_item;
|
| + one_item.push_back(uit);
|
| +
|
| + ProcessWorkItems(one_item);
|
| + return kOk;
|
| +}
|
| +
|
| // Sets a component to be checked for updates.
|
| // The componet to add is |crxit| and the |query| string is modified with the
|
| // required omaha compatible query. Returns false when the query strings
|
| @@ -503,14 +531,19 @@ bool CrxUpdateService::AddItemToUpdateCheck(CrxUpdateItem* item,
|
| return true;
|
| }
|
|
|
| -// Here is where the work gets scheduled. Given that our |work_items_| list
|
| -// is expected to be ten or less items, we simply loop several times.
|
| +// Here is where the work gets scheduled.
|
| void CrxUpdateService::ProcessPendingItems() {
|
| + ProcessWorkItems(work_items_);
|
| +}
|
| +
|
| +// Here is where the work gets scheduled. Given that our |work_items| list
|
| +// is expected to be ten or less items, we simply loop several times.
|
| +void CrxUpdateService::ProcessWorkItems(const UpdateItems& work_items) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| // First check for ready upgrades and do one. The first
|
| // step is to fetch the crx package.
|
| - for (UpdateItems::const_iterator it = work_items_.begin();
|
| - it != work_items_.end(); ++it) {
|
| + for (UpdateItems::const_iterator it = work_items.begin();
|
| + it != work_items.end(); ++it) {
|
| CrxUpdateItem* item = *it;
|
| if (item->status != CrxUpdateItem::kCanUpdate)
|
| continue;
|
| @@ -533,8 +566,8 @@ void CrxUpdateService::ProcessPendingItems() {
|
| std::string query;
|
| // If no pending upgrades, we check if there are new components we have not
|
| // checked against the server. We can batch some in a single url request.
|
| - for (UpdateItems::const_iterator it = work_items_.begin();
|
| - it != work_items_.end(); ++it) {
|
| + for (UpdateItems::const_iterator it = work_items.begin();
|
| + it != work_items.end(); ++it) {
|
| CrxUpdateItem* item = *it;
|
| if (item->status != CrxUpdateItem::kNew)
|
| continue;
|
| @@ -550,8 +583,8 @@ void CrxUpdateService::ProcessPendingItems() {
|
| const base::TimeDelta min_delta_time =
|
| base::TimeDelta::FromSeconds(config_->MinimumReCheckWait());
|
|
|
| - for (UpdateItems::const_iterator it = work_items_.begin();
|
| - it != work_items_.end(); ++it) {
|
| + 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))
|
| @@ -567,8 +600,8 @@ void CrxUpdateService::ProcessPendingItems() {
|
|
|
| // Finally, we check components that we already updated as long as
|
| // we have not checked them recently.
|
| - for (UpdateItems::const_iterator it = work_items_.begin();
|
| - it != work_items_.end(); ++it) {
|
| + for (UpdateItems::const_iterator it = work_items.begin();
|
| + it != work_items.end(); ++it) {
|
| CrxUpdateItem* item = *it;
|
| if (item->status != CrxUpdateItem::kUpdated)
|
| continue;
|
| @@ -602,7 +635,7 @@ void CrxUpdateService::ProcessPendingItems() {
|
| ScheduleNextRun(false);
|
| }
|
|
|
| -// Caled when we got a response from the update server. It consists of an xml
|
| +// Called when we got a response from the update server. It consists of an xml
|
| // document following the omaha update scheme.
|
| void CrxUpdateService::OnURLFetchComplete(const net::URLFetcher* source,
|
| UpdateContext* context) {
|
|
|