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 268cfb242c5552b415e69a9e3d16f896193073b0..a829b0c1be7e418ab4c7707dba7a02b0e3821623 100644 |
--- a/chrome/browser/component_updater/component_updater_service.cc |
+++ b/chrome/browser/component_updater/component_updater_service.cc |
@@ -90,12 +90,6 @@ CrxComponent::CrxComponent() |
CrxComponent::~CrxComponent() { |
} |
-CrxComponentInfo::CrxComponentInfo() { |
-} |
- |
-CrxComponentInfo::~CrxComponentInfo() { |
-} |
- |
/////////////////////////////////////////////////////////////////////////////// |
// In charge of blocking url requests until the |crx_id| component has been |
// updated. This class is touched solely from the IO thread. The UI thread |
@@ -169,8 +163,11 @@ class CrxUpdateService : public ComponentUpdateService { |
virtual Status Stop() OVERRIDE; |
virtual Status RegisterComponent(const CrxComponent& component) OVERRIDE; |
virtual Status OnDemandUpdate(const std::string& component_id) OVERRIDE; |
- virtual void GetComponents( |
- std::vector<CrxComponentInfo>* components) OVERRIDE; |
+ virtual void GetComponentIDs( |
+ std::vector<std::string>* component_ids) OVERRIDE; |
+ virtual void GetComponentDetails(const std::string& component_id, |
+ CrxUpdateItem** item) OVERRIDE; |
+ |
virtual content::ResourceThrottle* GetOnDemandResourceThrottle( |
net::URLRequest* request, const std::string& crx_id) OVERRIDE; |
@@ -252,6 +249,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_; |
@@ -522,28 +521,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. |
@@ -556,20 +543,25 @@ ComponentUpdateService::Status CrxUpdateService::OnDemandUpdateInternal( |
return kOk; |
} |
-void CrxUpdateService::GetComponents( |
- std::vector<CrxComponentInfo>* components) { |
+void CrxUpdateService::GetComponentIDs( |
+ std::vector<std::string>* component_ids) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
for (UpdateItems::const_iterator it = work_items_.begin(); |
it != work_items_.end(); ++it) { |
const CrxUpdateItem* item = *it; |
- CrxComponentInfo info; |
- info.id = GetCrxComponentID(item->component); |
- info.version = item->component.version.GetString(); |
- info.name = item->component.name; |
- components->push_back(info); |
+ component_ids->push_back(GetCrxComponentID(item->component)); |
Sorin Jianu
2014/05/03 01:09:06
there is already an CrxUpdateItem::id member, we c
Shrikant Kelkar
2014/05/05 23:05:18
Done.
|
} |
} |
+void CrxUpdateService::GetComponentDetails( |
+ const std::string& component_id, CrxUpdateItem** item) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ |
+ CrxUpdateItem* crx = FindUpdateItemById(component_id); |
+ *item = crx; |
+} |
+ |
+ |
// 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. |
@@ -1013,6 +1005,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) |