| 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 // StorageMonitorLinux implementation. | 5 // StorageMonitorLinux implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" | 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" |
| 8 | 8 |
| 9 #include <mntent.h> | 9 #include <mntent.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 void StorageMonitorLinux::SetMediaTransferProtocolManagerForTest( | 328 void StorageMonitorLinux::SetMediaTransferProtocolManagerForTest( |
| 329 device::MediaTransferProtocolManager* test_manager) { | 329 device::MediaTransferProtocolManager* test_manager) { |
| 330 DCHECK(!media_transfer_protocol_manager_); | 330 DCHECK(!media_transfer_protocol_manager_); |
| 331 media_transfer_protocol_manager_.reset(test_manager); | 331 media_transfer_protocol_manager_.reset(test_manager); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void StorageMonitorLinux::EjectDevice( | 334 void StorageMonitorLinux::EjectDevice( |
| 335 const std::string& device_id, | 335 const std::string& device_id, |
| 336 base::Callback<void(EjectStatus)> callback) { | 336 base::Callback<void(EjectStatus)> callback) { |
| 337 StorageInfo::Type type; |
| 338 if (!StorageInfo::CrackDeviceId(device_id, &type, NULL)) { |
| 339 callback.Run(EJECT_FAILURE); |
| 340 return; |
| 341 } |
| 342 |
| 343 if (type == StorageInfo::MTP_OR_PTP) { |
| 344 media_transfer_protocol_device_observer_->EjectDevice(device_id, callback); |
| 345 return; |
| 346 } |
| 347 |
| 337 // Find the mount point for the given device ID. | 348 // Find the mount point for the given device ID. |
| 338 base::FilePath path; | 349 base::FilePath path; |
| 339 base::FilePath device; | 350 base::FilePath device; |
| 340 for (MountMap::iterator mount_info = mount_info_map_.begin(); | 351 for (MountMap::iterator mount_info = mount_info_map_.begin(); |
| 341 mount_info != mount_info_map_.end(); ++mount_info) { | 352 mount_info != mount_info_map_.end(); ++mount_info) { |
| 342 if (mount_info->second.storage_info.device_id() == device_id) { | 353 if (mount_info->second.storage_info.device_id() == device_id) { |
| 343 path = mount_info->first; | 354 path = mount_info->first; |
| 344 device = mount_info->second.mount_device; | 355 device = mount_info->second.mount_device; |
| 345 mount_info_map_.erase(mount_info); | 356 mount_info_map_.erase(mount_info); |
| 346 break; | 357 break; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 mount_priority_map_[mount_device][mount_point] = removable; | 514 mount_priority_map_[mount_device][mount_point] = removable; |
| 504 receiver()->ProcessAttach(*storage_info); | 515 receiver()->ProcessAttach(*storage_info); |
| 505 } | 516 } |
| 506 | 517 |
| 507 StorageMonitor* StorageMonitor::Create() { | 518 StorageMonitor* StorageMonitor::Create() { |
| 508 const base::FilePath kDefaultMtabPath("/etc/mtab"); | 519 const base::FilePath kDefaultMtabPath("/etc/mtab"); |
| 509 return new StorageMonitorLinux(kDefaultMtabPath); | 520 return new StorageMonitorLinux(kDefaultMtabPath); |
| 510 } | 521 } |
| 511 | 522 |
| 512 } // namespace chrome | 523 } // namespace chrome |
| OLD | NEW |