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

Unified Diff: chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc

Issue 23383009: [StorageMonitor] Handle EjectDevice call for MTP devices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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/storage_monitor/media_transfer_protocol_device_observer_linux.cc
diff --git a/chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc b/chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc
index f84ace5779efafa7b5b900ade4a026b3574dfab5..0c9ce3e50b4e537f96d0d053281c36fa221f1348 100644
--- a/chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc
+++ b/chrome/browser/storage_monitor/media_transfer_protocol_device_observer_linux.cc
@@ -165,6 +165,19 @@ bool MediaTransferProtocolDeviceObserverLinux::GetStorageInfoForPath(
return true;
}
+void MediaTransferProtocolDeviceObserverLinux::EjectDevice(
+ const std::string& device_id,
+ base::Callback<void(StorageMonitor::EjectStatus)> callback) {
+ std::string location;
+ if (!GetLocationForDeviceId(device_id, &location)) {
+ callback.Run(StorageMonitor::EJECT_NO_SUCH_DEVICE);
+ return;
+ }
+
+ StorageChanged(false, location);
Lei Zhang 2013/08/21 21:37:53 We may be able to do more here, and communicate wi
Greg Billock 2013/08/23 20:17:14 Done.
+ callback.Run(StorageMonitor::EJECT_OK);
+}
+
// device::MediaTransferProtocolManager::Observer override.
void MediaTransferProtocolDeviceObserverLinux::StorageChanged(
bool is_attached,
@@ -211,4 +224,17 @@ void MediaTransferProtocolDeviceObserverLinux::EnumerateStorages() {
}
}
+bool MediaTransferProtocolDeviceObserverLinux::GetLocationForDeviceId(
Lei Zhang 2013/08/21 21:37:53 Can't you just return a std::string, with an empty
Lei Zhang 2013/08/21 21:37:53 nit: const method
Greg Billock 2013/08/23 20:17:14 I actually had that. :-) Switched to this as I thi
Greg Billock 2013/08/23 20:17:14 Done.
+ const std::string& device_id, std::string* location) {
+ for (StorageLocationToInfoMap::iterator it = storage_map_.begin();
+ it != storage_map_.end(); ++it) {
+ if (it->second.device_id() == device_id) {
+ *location = it->first;
+ return true;
+ }
+ }
+
+ return false;
+}
+
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698