| 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 60740e678b3186233d24ba31382d2f8659d537a3..5a4ca5713671f903b22409a19e658b2ffb801416 100644
|
| --- a/chrome/browser/component_updater/component_updater_service.cc
|
| +++ b/chrome/browser/component_updater/component_updater_service.cc
|
| @@ -88,12 +88,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
|
| @@ -161,8 +155,10 @@ 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 std::vector<std::string> GetComponentIDs() const OVERRIDE;
|
| + virtual CrxUpdateItem* GetComponentDetails(
|
| + const std::string& component_id) const OVERRIDE;
|
| +
|
| virtual content::ResourceThrottle* GetOnDemandResourceThrottle(
|
| net::URLRequest* request,
|
| const std::string& crx_id) OVERRIDE;
|
| @@ -235,7 +231,7 @@ class CrxUpdateService : public ComponentUpdateService {
|
|
|
| size_t ChangeItemStatus(CrxUpdateItem::Status from, CrxUpdateItem::Status to);
|
|
|
| - CrxUpdateItem* FindUpdateItemById(const std::string& id);
|
| + CrxUpdateItem* FindUpdateItemById(const std::string& id) const;
|
|
|
| void NotifyObservers(Observer::Events event, const std::string& id);
|
|
|
| @@ -244,6 +240,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_;
|
| @@ -396,10 +394,11 @@ void CrxUpdateService::ScheduleNextRun(StepDelayInterval step_delay) {
|
| }
|
|
|
| // Given a extension-like component id, find the associated component.
|
| -CrxUpdateItem* CrxUpdateService::FindUpdateItemById(const std::string& id) {
|
| +CrxUpdateItem* CrxUpdateService::FindUpdateItemById(
|
| + const std::string& id) const {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| CrxUpdateItem::FindById finder(id);
|
| - UpdateItems::iterator it =
|
| + UpdateItems::const_iterator it =
|
| std::find_if(work_items_.begin(), work_items_.end(), finder);
|
| return it != work_items_.end() ? *it : NULL;
|
| }
|
| @@ -514,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.
|
| @@ -550,19 +537,22 @@ ComponentUpdateService::Status CrxUpdateService::OnDemandUpdateInternal(
|
| return kOk;
|
| }
|
|
|
| -void CrxUpdateService::GetComponents(
|
| - std::vector<CrxComponentInfo>* components) {
|
| +std::vector<std::string> CrxUpdateService::GetComponentIDs() const {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + std::vector<std::string> component_ids;
|
| 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(item->id);
|
| }
|
| + return component_ids;
|
| +}
|
| +
|
| +CrxUpdateItem* CrxUpdateService::GetComponentDetails(
|
| + const std::string& component_id) const {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + return FindUpdateItemById(component_id);
|
| }
|
|
|
| // This is the main loop of the component updater. It updates one component
|
| @@ -1010,6 +1000,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)
|
|
|