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

Unified Diff: chrome/browser/chromeos/file_manager/volume_manager.cc

Issue 2348813002: Fix a bug that unmounting devices on the policy update can be a busy loop. (Closed)
Patch Set: Format fix, use reference where copy isn't needed. Created 4 years, 3 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: chrome/browser/chromeos/file_manager/volume_manager.cc
diff --git a/chrome/browser/chromeos/file_manager/volume_manager.cc b/chrome/browser/chromeos/file_manager/volume_manager.cc
index 54583629614f0bf5538caeb0c5c19a4220382097..86b788ff4f338e4753d20ce56da0361d25823f4e 100644
--- a/chrome/browser/chromeos/file_manager/volume_manager.cc
+++ b/chrome/browser/chromeos/file_manager/volume_manager.cc
@@ -682,6 +682,20 @@ void VolumeManager::OnProvidedFileSystemUnmount(
DoUnmountEvent(mount_error, volume);
}
+void VolumeManager::OnExternalStorageDisabledChangedUnmountCallback(
+ chromeos::MountError error_code) {
+ if (disk_mount_manager_->mount_points().empty())
+ return;
+ // Repeat until unmount all paths
+ const std::string& mount_path =
+ disk_mount_manager_->mount_points().begin()->second.mount_path;
+ disk_mount_manager_->UnmountPath(
+ mount_path, chromeos::UNMOUNT_OPTIONS_NONE,
+ base::Bind(
+ &VolumeManager::OnExternalStorageDisabledChangedUnmountCallback,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
void VolumeManager::OnExternalStorageDisabledChanged() {
// If the policy just got disabled we have to unmount every device currently
// mounted. The opposite is fine - we can let the user re-plug their device to
@@ -690,14 +704,15 @@ void VolumeManager::OnExternalStorageDisabledChanged() {
// We do not iterate on mount_points directly, because mount_points can
// be changed by UnmountPath().
// TODO(hidehiko): Is it necessary to unmount mounted archives, too, here?
- while (!disk_mount_manager_->mount_points().empty()) {
- std::string mount_path =
- disk_mount_manager_->mount_points().begin()->second.mount_path;
- disk_mount_manager_->UnmountPath(
- mount_path,
- chromeos::UNMOUNT_OPTIONS_NONE,
- chromeos::disks::DiskMountManager::UnmountPathCallback());
- }
+ if (disk_mount_manager_->mount_points().empty())
+ return;
+ const std::string& mount_path =
+ disk_mount_manager_->mount_points().begin()->second.mount_path;
+ disk_mount_manager_->UnmountPath(
+ mount_path, chromeos::UNMOUNT_OPTIONS_NONE,
+ base::Bind(
+ &VolumeManager::OnExternalStorageDisabledChangedUnmountCallback,
+ weak_ptr_factory_.GetWeakPtr()));
}
}

Powered by Google App Engine
This is Rietveld 408576698