Chromium Code Reviews| 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..9eae3c8eb570f8c088f616696f4bc70081964bb6 100644 |
| --- a/chrome/browser/chromeos/file_manager/volume_manager.cc |
| +++ b/chrome/browser/chromeos/file_manager/volume_manager.cc |
| @@ -682,6 +682,21 @@ void VolumeManager::OnProvidedFileSystemUnmount( |
| DoUnmountEvent(mount_error, volume); |
| } |
| +void VolumeManager::OnExternalStorageDisabledChangedUnmountCallback( |
| + chromeos::MountError error_code) { |
| + if (disk_mount_manager_->mount_points().empty()) { |
|
fukino
2016/09/16 07:31:35
We usually omit {} for single-line if statements.
yamaguchi
2016/09/26 02:25:28
Done.
|
| + return; |
| + } |
| + // Repeat until unmount all paths |
| + std::string mount_path = |
|
hidehiko
2016/09/16 08:14:33
nit: const &. Ditto for below.
yamaguchi
2016/09/26 02:25:28
Done.
|
| + 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 +705,16 @@ 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()) { |
|
fukino
2016/09/16 07:31:35
ditto.
yamaguchi
2016/09/26 02:25:28
Done.
|
| + return; |
| } |
| + 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())); |
| } |
| } |