Chromium Code Reviews| 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..4a526054e466087b2bb6792e72b99af6666148de 100644 |
| --- a/chrome/browser/component_updater/component_updater_service.cc |
| +++ b/chrome/browser/component_updater/component_updater_service.cc |
| @@ -170,6 +170,9 @@ class CrxUpdateService : public ComponentUpdateService { |
| virtual Status OnDemandUpdate(const std::string& component_id) OVERRIDE; |
| virtual void GetComponents( |
| std::vector<CrxComponentInfo>* components) OVERRIDE; |
| + virtual ComponentUpdateService::Status GetComponentStatus( |
| + const std::string& component_id) OVERRIDE; |
| + |
| virtual content::ResourceThrottle* GetOnDemandResourceThrottle( |
| net::URLRequest* request, const std::string& crx_id) OVERRIDE; |
| @@ -250,6 +253,9 @@ class CrxUpdateService : public ComponentUpdateService { |
| void OnNewResourceThrottle(base::WeakPtr<CUResourceThrottle> rt, |
| const std::string& crx_id); |
| + ComponentUpdateService::Status GetConciseStatus( |
| + const CrxUpdateItem::Status status); |
| + |
| scoped_ptr<ComponentUpdateService::Configurator> config_; |
| scoped_ptr<ComponentPatcher> component_patcher_; |
| @@ -509,28 +515,15 @@ 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 = GetConciseStatus(uit->status); |
|
Sorin Jianu
2014/03/26 20:22:36
Consider renaming GetConciseStatus to GetServiceSt
Shrikant Kelkar
2014/03/26 21:35:51
Done.
|
| + // 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); |
|
Sorin Jianu
2014/03/26 20:22:36
are we still setting uit->on_demand = true anywher
Shrikant Kelkar
2014/03/26 21:35:51
good catch, copy~paste error. Thanks.
|
| // In case the current delay is long, set the timer to a shorter value |
| // to get the ball rolling. |
| @@ -553,10 +546,25 @@ void CrxUpdateService::GetComponents( |
| info.id = GetCrxComponentID(item->component); |
| info.version = item->component.version.GetString(); |
| info.name = item->component.name; |
| + info.status = GetConciseStatus(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); |
| + DCHECK(crx != NULL); |
|
Sorin Jianu
2014/03/26 20:22:36
no need to dcheck and handle the error, see the DC
Shrikant Kelkar
2014/03/26 21:35:51
Done.
|
| + if (crx == NULL) |
| + return kError; |
| + |
| + Status service_status = GetConciseStatus(crx->status); |
| + return service_status; |
|
Sorin Jianu
2014/03/26 20:22:36
return GetConciseStatus(crx->status);
Shrikant Kelkar
2014/03/26 21:35:51
Done.
|
| +} |
| + |
| + |
| // 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 +981,32 @@ void CrxUpdateService::OnNewResourceThrottle( |
| UnblockResourceThrottle(rt); |
| } |
| +ComponentUpdateService::Status CrxUpdateService::GetConciseStatus( |
|
Sorin Jianu
2014/03/26 20:22:36
If we don't fully qualify then the param might fit
Shrikant Kelkar
2014/03/26 21:35:51
Not qualifying gives compile error + we seem to be
|
| + CrxUpdateItem::Status status) { |
| + switch (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: |
| + return kOk; |
| + break; |
| + case CrxUpdateItem::kLastStatus: |
| + NOTREACHED() << status; |
| + } |
| + return kError; |
| +} |
| + |
| /////////////////////////////////////////////////////////////////////////////// |
| CUResourceThrottle::CUResourceThrottle(const net::URLRequest* request) |