| Index: components/component_updater/component_updater_service.cc
|
| diff --git a/components/component_updater/component_updater_service.cc b/components/component_updater/component_updater_service.cc
|
| index 4b97baeb31c81a2eedbf39ce8ede6ab7466056d7..bcd324a4ca87468775359fe1555efc38585de23a 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,
|
| @@ -108,7 +109,7 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater {
|
|
|
| // Context for a crx download url request.
|
| struct CRXContext {
|
| - ComponentInstaller* installer;
|
| + scoped_refptr<ComponentInstaller> installer;
|
| std::vector<uint8_t> pk_hash;
|
| std::string id;
|
| std::string fingerprint;
|
| @@ -461,6 +462,27 @@ ComponentUpdateService::Status CrxUpdateService::RegisterComponent(
|
| return kOk;
|
| }
|
|
|
| +ComponentUpdateService::Status CrxUpdateService::UnregisterComponent(
|
| + const std::string& crx_id) {
|
| + UpdateItems::iterator it = std::find_if(
|
| + work_items_.begin(), work_items_.end(), CrxUpdateItem::FindById(crx_id));
|
| + if (it == work_items_.end())
|
| + return kError;
|
| +
|
| + CrxUpdateItem* item = *it;
|
| + CrxUpdateItem::Status status = item->status;
|
| + if (status == CrxUpdateItem::kDownloading ||
|
| + status == CrxUpdateItem::kDownloadingDiff ||
|
| + status == CrxUpdateItem::kUpdating ||
|
| + status == CrxUpdateItem::kUpdatingDiff) {
|
| + ChangeItemState(item, CrxUpdateItem::kNoUpdate);
|
| + ping_manager_->OnUpdateComplete(item);
|
| + }
|
| +
|
| + work_items_.erase(it);
|
| + return kOk;
|
| +}
|
| +
|
| std::vector<std::string> CrxUpdateService::GetComponentIDs() const {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| std::vector<std::string> component_ids;
|
| @@ -781,6 +803,23 @@ void CrxUpdateService::DownloadComplete(
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
|
|
| CrxUpdateItem* crx = FindUpdateItemById(crx_context->id);
|
| +
|
| + // If the item has been removed in the mean time, clean up and return.
|
| + if (!crx) {
|
| + crx_downloader_.reset();
|
| + base::FilePath crx_path = download_result.response;
|
| + if (!crx_path.empty()) {
|
| + blocking_task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(base::IgnoreResult(
|
| + &update_client::DeleteFileAndEmptyParentDirectory),
|
| + crx_path));
|
| + }
|
| + // Move on to the next update, if there is one available.
|
| + ScheduleNextRun(kStepDelayMedium);
|
| + return;
|
| + }
|
| +
|
| DCHECK(crx->status == CrxUpdateItem::kDownloadingDiff ||
|
| crx->status == CrxUpdateItem::kDownloading);
|
|
|
| @@ -895,6 +934,13 @@ void CrxUpdateService::DoneInstalling(const std::string& component_id,
|
| const bool is_success = error == ComponentUnpacker::kNone;
|
|
|
| CrxUpdateItem* item = FindUpdateItemById(component_id);
|
| +
|
| + // If the item has been removed in the mean time, return.
|
| + if (!item) {
|
| + ScheduleNextRun(kStepDelayMedium);
|
| + return;
|
| + }
|
| +
|
| if (item->status == CrxUpdateItem::kUpdatingDiff && !is_success) {
|
| item->diff_error_category = error_category;
|
| item->diff_error_code = error;
|
|
|