OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // chromeos::StorageMonitorCros implementation. | 5 // chromeos::StorageMonitorCros implementation. |
6 | 6 |
7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h" | 7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h" |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 chromeos::MountError error_code) { | 240 chromeos::MountError error_code) { |
241 if (error_code == MOUNT_ERROR_NONE) | 241 if (error_code == MOUNT_ERROR_NONE) |
242 callback.Run(chrome::StorageMonitor::EJECT_OK); | 242 callback.Run(chrome::StorageMonitor::EJECT_OK); |
243 else | 243 else |
244 callback.Run(chrome::StorageMonitor::EJECT_FAILURE); | 244 callback.Run(chrome::StorageMonitor::EJECT_FAILURE); |
245 } | 245 } |
246 | 246 |
247 void StorageMonitorCros::EjectDevice( | 247 void StorageMonitorCros::EjectDevice( |
248 const std::string& device_id, | 248 const std::string& device_id, |
249 base::Callback<void(EjectStatus)> callback) { | 249 base::Callback<void(EjectStatus)> callback) { |
| 250 StorageInfo::Type type; |
| 251 if (!StorageInfo::CrackDeviceId(device_id, &type, NULL)) { |
| 252 callback.Run(EJECT_FAILURE); |
| 253 return; |
| 254 } |
| 255 |
| 256 if (type == StorageInfo::MTP_OR_PTP) { |
| 257 media_transfer_protocol_device_observer_->EjectDevice(device_id, callback); |
| 258 return; |
| 259 } |
| 260 |
250 std::string mount_path; | 261 std::string mount_path; |
251 for (MountMap::const_iterator info_it = mount_map_.begin(); | 262 for (MountMap::const_iterator info_it = mount_map_.begin(); |
252 info_it != mount_map_.end(); ++info_it) { | 263 info_it != mount_map_.end(); ++info_it) { |
253 if (info_it->second.device_id() == device_id) | 264 if (info_it->second.device_id() == device_id) |
254 mount_path = info_it->first; | 265 mount_path = info_it->first; |
255 } | 266 } |
256 | 267 |
257 if (mount_path.empty()) { | 268 if (mount_path.empty()) { |
258 callback.Run(EJECT_NO_SUCH_DEVICE); | 269 callback.Run(EJECT_NO_SUCH_DEVICE); |
259 return; | 270 return; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 311 |
301 } // namespace chromeos | 312 } // namespace chromeos |
302 | 313 |
303 namespace chrome { | 314 namespace chrome { |
304 | 315 |
305 StorageMonitor* StorageMonitor::Create() { | 316 StorageMonitor* StorageMonitor::Create() { |
306 return new chromeos::StorageMonitorCros(); | 317 return new chromeos::StorageMonitorCros(); |
307 } | 318 } |
308 | 319 |
309 } // namespace chrome | 320 } // namespace chrome |
OLD | NEW |