Index: chrome/browser/storage_monitor/storage_monitor_chromeos.cc |
diff --git a/chrome/browser/storage_monitor/storage_monitor_chromeos.cc b/chrome/browser/storage_monitor/storage_monitor_chromeos.cc |
index f07a0cf7914fbf6cb260c3ae684c20fcbe4bfda6..e2d12a80af41be3451b47f1657323130293119cd 100644 |
--- a/chrome/browser/storage_monitor/storage_monitor_chromeos.cc |
+++ b/chrome/browser/storage_monitor/storage_monitor_chromeos.cc |
@@ -212,6 +212,42 @@ uint64 StorageMonitorCros::GetStorageSize( |
info_it->second.total_size_in_bytes : 0; |
} |
+// Callback executed when the unmount call is run by DiskMountManager. |
+// Forwards result to |EjectDevice| caller. |
+void NotifyEjectSuccess( |
+ base::Callback<void(chrome::StorageMonitor::EjectStatus)> callback, |
+ chromeos::MountError error_code) { |
+ if (error_code == MOUNT_ERROR_NONE) |
+ callback.Run(chrome::StorageMonitor::EJECT_OK); |
+ else |
+ callback.Run(chrome::StorageMonitor::EJECT_FAILURE); |
+} |
+ |
+void StorageMonitorCros::EjectDevice( |
+ const std::string& device_id, |
+ base::Callback<void(EjectStatus)> callback) { |
+ std::string mount_path; |
+ for (MountMap::const_iterator info_it = mount_map_.begin(); |
+ info_it != mount_map_.end(); ++info_it) { |
+ if (info_it->second.device_id == device_id) |
+ mount_path = info_it->first; |
+ } |
+ |
+ if (mount_path.empty()) { |
+ callback.Run(EJECT_NO_SUCH_DEVICE); |
+ return; |
+ } |
+ |
+ disks::DiskMountManager* manager = disks::DiskMountManager::GetInstance(); |
+ if (!manager) { |
+ callback.Run(EJECT_FAILURE); |
+ return; |
+ } |
+ |
+ manager->UnmountPath(mount_path, chromeos::UNMOUNT_OPTIONS_NONE, |
+ base::Bind(NotifyEjectSuccess, callback)); |
tbarzic
2013/03/18 19:48:26
nit: how about NotifyEjectResult
Greg Billock
2013/03/18 21:44:44
Good point. Changed to NotifyUnmountResult.
|
+} |
+ |
void StorageMonitorCros::CheckMountedPathOnFileThread( |
const disks::DiskMountManager::MountPointInfo& mount_info) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |