| 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 fa04986f6829511953201f2f4fcabcf416b4cc2b..a1598fa788d2fb690ec1ea453d40d79f834c9279 100644
|
| --- a/chrome/browser/component_updater/component_updater_service.cc
|
| +++ b/chrome/browser/component_updater/component_updater_service.cc
|
| @@ -170,6 +170,8 @@ class CrxUpdateService : public ComponentUpdateService {
|
| virtual Status OnDemandUpdate(const std::string& component_id) OVERRIDE;
|
| virtual void GetComponents(
|
| std::vector<CrxComponentInfo>* components) OVERRIDE;
|
| + virtual Status GetComponentStatus(const std::string& component_id) OVERRIDE;
|
| +
|
| virtual content::ResourceThrottle* GetOnDemandResourceThrottle(
|
| net::URLRequest* request, const std::string& crx_id) OVERRIDE;
|
|
|
| @@ -250,6 +252,8 @@ class CrxUpdateService : public ComponentUpdateService {
|
| void OnNewResourceThrottle(base::WeakPtr<CUResourceThrottle> rt,
|
| const std::string& crx_id);
|
|
|
| + Status GetServiceStatus(const CrxUpdateItem::Status status);
|
| +
|
| scoped_ptr<ComponentUpdateService::Configurator> config_;
|
|
|
| scoped_ptr<ComponentPatcher> component_patcher_;
|
| @@ -509,28 +513,16 @@ ComponentUpdateService::Status CrxUpdateService::OnDemandUpdateInternal(
|
| if (delta < base::TimeDelta::FromSeconds(config_->OnDemandDelay()))
|
| return kError;
|
|
|
| - switch (uit->status) {
|
| - // If the item is already in the process of being updated, there is
|
| - // no point in this call, so return kInProgress.
|
| - case CrxUpdateItem::kChecking:
|
| - case CrxUpdateItem::kCanUpdate:
|
| - case CrxUpdateItem::kDownloadingDiff:
|
| - case CrxUpdateItem::kDownloading:
|
| - case CrxUpdateItem::kUpdatingDiff:
|
| - case CrxUpdateItem::kUpdating:
|
| - return kInProgress;
|
| - // Otherwise the item was already checked a while back (or it is new),
|
| - // set its status to kNew to give it a slightly higher priority.
|
| - case CrxUpdateItem::kNew:
|
| - case CrxUpdateItem::kUpdated:
|
| - case CrxUpdateItem::kUpToDate:
|
| - case CrxUpdateItem::kNoUpdate:
|
| - ChangeItemState(uit, CrxUpdateItem::kNew);
|
| - uit->on_demand = true;
|
| - break;
|
| - case CrxUpdateItem::kLastStatus:
|
| - NOTREACHED() << uit->status;
|
| - }
|
| + Status service_status = GetServiceStatus(uit->status);
|
| + // If the item is already in the process of being updated, there is
|
| + // no point in this call, so return kInProgress.
|
| + if (service_status == kInProgress)
|
| + return service_status;
|
| +
|
| + // Otherwise the item was already checked a while back (or it is new),
|
| + // set its status to kNew to give it a slightly higher priority.
|
| + ChangeItemState(uit, CrxUpdateItem::kNew);
|
| + uit->on_demand = true;
|
|
|
| // In case the current delay is long, set the timer to a shorter value
|
| // to get the ball rolling.
|
| @@ -553,10 +545,20 @@ void CrxUpdateService::GetComponents(
|
| info.id = GetCrxComponentID(item->component);
|
| info.version = item->component.version.GetString();
|
| info.name = item->component.name;
|
| + info.status = GetServiceStatus(item->status);
|
| components->push_back(info);
|
| }
|
| }
|
|
|
| +ComponentUpdateService::Status CrxUpdateService::GetComponentStatus(
|
| + const std::string& component_id) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + CrxUpdateItem* crx = FindUpdateItemById(component_id);
|
| + return GetServiceStatus(crx->status);
|
| +}
|
| +
|
| +
|
| // This is the main loop of the component updater. It updates one component
|
| // at a time if updates are available. Otherwise, it does an update check or
|
| // takes a long sleep until the loop runs again.
|
| @@ -973,6 +975,28 @@ void CrxUpdateService::OnNewResourceThrottle(
|
| UnblockResourceThrottle(rt);
|
| }
|
|
|
| +ComponentUpdateService::Status CrxUpdateService::GetServiceStatus(
|
| + CrxUpdateItem::Status status) {
|
| + switch (status) {
|
| + case CrxUpdateItem::kChecking:
|
| + case CrxUpdateItem::kCanUpdate:
|
| + case CrxUpdateItem::kDownloadingDiff:
|
| + case CrxUpdateItem::kDownloading:
|
| + case CrxUpdateItem::kUpdatingDiff:
|
| + case CrxUpdateItem::kUpdating:
|
| + return kInProgress;
|
| + case CrxUpdateItem::kNew:
|
| + case CrxUpdateItem::kUpdated:
|
| + case CrxUpdateItem::kUpToDate:
|
| + case CrxUpdateItem::kNoUpdate:
|
| + return kOk;
|
| + break;
|
| + case CrxUpdateItem::kLastStatus:
|
| + NOTREACHED() << status;
|
| + }
|
| + return kError;
|
| +}
|
| +
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| CUResourceThrottle::CUResourceThrottle(const net::URLRequest* request)
|
|
|