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 2a8d14fc728b3205127feafc817ac850b2da40dd..94d181869e6e647b5fb7b8193ffcc58a276deb62 100644 |
--- a/chrome/browser/component_updater/component_updater_service.cc |
+++ b/chrome/browser/component_updater/component_updater_service.cc |
@@ -171,6 +171,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<UpdateChecker> update_checker_; |
@@ -515,28 +519,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); |
Sorin Jianu
2014/04/28 22:46:11
const?
|
+ // 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. |
@@ -559,10 +551,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); |
Sorin Jianu
2014/04/28 22:46:11
const ?
|
+ return GetServiceStatus(crx->status); |
+} |
+ |
+ |
Sorin Jianu
2014/04/28 22:46:11
extra line.
|
// 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. |
@@ -976,6 +978,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) |