Commit ce11a3d2 authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

cros: Fix crostini uninstall calling dbus on wrong thread

Bug: 962884
Change-Id: Ia6ce88211926c4ccb6726f3aab9e8677e196d6f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1612851Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarXiaochu Liu <xiaochu@chromium.org>
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659979}
parent aafdc77d
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "chromeos/dbus/image_loader_client.h" #include "chromeos/dbus/image_loader_client.h"
#include "components/component_updater/component_updater_paths.h" #include "components/component_updater/component_updater_paths.h"
#include "components/crx_file/id_util.h" #include "components/crx_file/id_util.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "crypto/sha2.h" #include "crypto/sha2.h"
...@@ -61,6 +62,13 @@ const ComponentConfig* FindConfig(const std::string& name) { ...@@ -61,6 +62,13 @@ const ComponentConfig* FindConfig(const std::string& name) {
// TODO(xiaochu): add metrics for component usage (https://crbug.com/793052). // TODO(xiaochu): add metrics for component usage (https://crbug.com/793052).
void LogCustomUninstall(base::Optional<bool> result) {} void LogCustomUninstall(base::Optional<bool> result) {}
void FinishCustomUninstallOnUIThread(const std::string& name) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
chromeos::DBusThreadManager::Get()->GetImageLoaderClient()->UnmountComponent(
name, base::BindOnce(&LogCustomUninstall));
}
std::string GenerateId(const std::string& sha2hashstr) { std::string GenerateId(const std::string& sha2hashstr) {
// kIdSize is the count of a pair of hex in the sha2hash array. // kIdSize is the count of a pair of hex in the sha2hash array.
// In string representation of sha2hash, size is doubled since each hex is // In string representation of sha2hash, size is doubled since each hex is
...@@ -144,8 +152,9 @@ CrOSComponentInstallerPolicy::OnCustomInstall( ...@@ -144,8 +152,9 @@ CrOSComponentInstallerPolicy::OnCustomInstall(
void CrOSComponentInstallerPolicy::OnCustomUninstall() { void CrOSComponentInstallerPolicy::OnCustomUninstall() {
cros_component_installer_->UnregisterCompatiblePath(name_); cros_component_installer_->UnregisterCompatiblePath(name_);
chromeos::DBusThreadManager::Get()->GetImageLoaderClient()->UnmountComponent( base::PostTaskWithTraits(
name_, base::BindOnce(&LogCustomUninstall)); FROM_HERE, {content::BrowserThread::UI},
base::BindOnce(&FinishCustomUninstallOnUIThread, name_));
} }
void CrOSComponentInstallerPolicy::ComponentReady( void CrOSComponentInstallerPolicy::ComponentReady(
......
...@@ -65,6 +65,7 @@ class ComponentInstallerPolicy { ...@@ -65,6 +65,7 @@ class ComponentInstallerPolicy {
// OnCustomUninstall is called during the unregister (uninstall) process. // OnCustomUninstall is called during the unregister (uninstall) process.
// Components that require custom uninstallation operations should implement // Components that require custom uninstallation operations should implement
// them here. // them here.
// Called only from a thread belonging to a blocking thread pool.
virtual void OnCustomUninstall() = 0; virtual void OnCustomUninstall() = 0;
// ComponentReady is called in two cases: // ComponentReady is called in two cases:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment