Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(780)

Unified Diff: components/component_updater/component_updater_service.cc

Issue 879993005: Add support for uninstalling components and use it in SupervisedUserWhitelistInstaller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: cleanup Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 89195c482f203701105671039219ff05c33fe8ee..81078ef89e2bba9e197285e0191d1cdeb9fb1ea0 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,
@@ -432,6 +433,7 @@ ComponentUpdateService::Status CrxUpdateService::RegisterComponent(
CrxUpdateItem* uit = FindUpdateItemById(id);
if (uit) {
uit->component = component;
+ uit->unregistered = false;
return kReplaced;
}
@@ -461,6 +463,19 @@ ComponentUpdateService::Status CrxUpdateService::RegisterComponent(
return kOk;
}
+ComponentUpdateService::Status CrxUpdateService::UnregisterComponent(
+ const std::string& crx_id) {
+ UpdateItems::iterator it = std::find_if(
Sorin Jianu 2015/02/06 19:11:58 maybe use auto?
Bernhard Bauer 2015/02/06 22:49:03 Done.
+ 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;
@@ -524,6 +539,19 @@ void CrxUpdateService::ProcessPendingItems() {
return;
}
+ // Uninstall and remove all unregistered work items.
Sorin Jianu 2015/02/06 19:11:58 Can we factor out this code as a member function?
Bernhard Bauer 2015/02/06 22:49:03 Done.
+ std::vector<CrxUpdateItem*> new_work_items;
+ for (CrxUpdateItem* item : work_items_) {
+ scoped_ptr<CrxUpdateItem> owned_item(item);
+ if (owned_item->unregistered) {
+ bool success = owned_item->component.installer->Uninstall();
Sorin Jianu 2015/02/06 19:11:58 could be const
Bernhard Bauer 2015/02/06 22:49:03 Done.
+ DCHECK(success);
+ } else {
+ new_work_items.push_back(owned_item.release());
+ }
+ }
+ new_work_items.swap(work_items_);
+
if (!CheckForUpdates())
ScheduleNextRun(kStepDelayLong);
}
@@ -781,6 +809,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 +924,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;

Powered by Google App Engine
This is Rietveld 408576698