diff options
author | bauerb <bauerb@chromium.org> | 2015-02-08 16:00:27 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-09 00:01:15 +0000 |
commit | 1f6657e7f1cf36e7a490c494c0794b124c86b6ec (patch) | |
tree | a7d54dc73cb55c5f5136fd6237bf7d0cb9a977cc /components/component_updater/component_updater_service.cc | |
parent | cce3cff79038a60aab74990acd2974de518d5c9f (diff) | |
download | chromium_src-1f6657e7f1cf36e7a490c494c0794b124c86b6ec.zip chromium_src-1f6657e7f1cf36e7a490c494c0794b124c86b6ec.tar.gz chromium_src-1f6657e7f1cf36e7a490c494c0794b124c86b6ec.tar.bz2 |
Add support for uninstalling components and use it in SupervisedUserWhitelistInstaller.
TBR=agl@chromium.org
BUG=436459
Review URL: https://codereview.chromium.org/879993005
Cr-Commit-Position: refs/heads/master@{#315246}
Diffstat (limited to 'components/component_updater/component_updater_service.cc')
-rw-r--r-- | components/component_updater/component_updater_service.cc | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/components/component_updater/component_updater_service.cc b/components/component_updater/component_updater_service.cc index 89195c4..4bfc2d7 100644 --- a/components/component_updater/component_updater_service.cc +++ b/components/component_updater/component_updater_service.cc @@ -100,6 +100,7 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { Status Start() override; Status Stop() override; Status RegisterComponent(const CrxComponent& component) override; + Status UnregisterComponent(const std::string& crx_id) override; std::vector<std::string> GetComponentIDs() const override; OnDemandUpdater& GetOnDemandUpdater() override; void MaybeThrottle(const std::string& crx_id, @@ -154,6 +155,9 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { void ProcessPendingItems(); + // Uninstall and remove all unregistered work items. + void UninstallUnregisteredItems(); + // Find a component that is ready to update. CrxUpdateItem* FindReadyComponent() const; @@ -432,6 +436,7 @@ ComponentUpdateService::Status CrxUpdateService::RegisterComponent( CrxUpdateItem* uit = FindUpdateItemById(id); if (uit) { uit->component = component; + uit->unregistered = false; return kReplaced; } @@ -461,6 +466,19 @@ ComponentUpdateService::Status CrxUpdateService::RegisterComponent( return kOk; } +ComponentUpdateService::Status CrxUpdateService::UnregisterComponent( + const std::string& crx_id) { + auto it = std::find_if(work_items_.begin(), work_items_.end(), + CrxUpdateItem::FindById(crx_id)); + if (it == work_items_.end()) + return kError; + + (*it)->unregistered = true; + + ScheduleNextRun(kStepDelayShort); + return kOk; +} + std::vector<std::string> CrxUpdateService::GetComponentIDs() const { DCHECK(thread_checker_.CalledOnValidThread()); std::vector<std::string> component_ids; @@ -492,7 +510,7 @@ void CrxUpdateService::MaybeThrottle(const std::string& crx_id, scoped_refptr<base::SequencedTaskRunner> CrxUpdateService::GetSequencedTaskRunner() { - return config_->GetSequencedTaskRunner(); + return blocking_task_runner_; } bool CrxUpdateService::GetComponentDetails(const std::string& component_id, @@ -524,10 +542,26 @@ void CrxUpdateService::ProcessPendingItems() { return; } + UninstallUnregisteredItems(); + if (!CheckForUpdates()) ScheduleNextRun(kStepDelayLong); } +void CrxUpdateService::UninstallUnregisteredItems() { + std::vector<CrxUpdateItem*> new_work_items; + for (CrxUpdateItem* item : work_items_) { + scoped_ptr<CrxUpdateItem> owned_item(item); + if (owned_item->unregistered) { + const bool success = owned_item->component.installer->Uninstall(); + DCHECK(success); + } else { + new_work_items.push_back(owned_item.release()); + } + } + new_work_items.swap(work_items_); +} + CrxUpdateItem* CrxUpdateService::FindReadyComponent() const { class Helper { public: @@ -781,6 +815,7 @@ void CrxUpdateService::DownloadComplete( DCHECK(thread_checker_.CalledOnValidThread()); CrxUpdateItem* crx = FindUpdateItemById(crx_context->id); + DCHECK(crx->status == CrxUpdateItem::kDownloadingDiff || crx->status == CrxUpdateItem::kDownloading); @@ -895,6 +930,7 @@ void CrxUpdateService::DoneInstalling(const std::string& component_id, const bool is_success = error == ComponentUnpacker::kNone; CrxUpdateItem* item = FindUpdateItemById(component_id); + if (item->status == CrxUpdateItem::kUpdatingDiff && !is_success) { item->diff_error_category = error_category; item->diff_error_code = error; |