| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 std::string source_path = mount_info.source_path; | 51 std::string source_path = mount_info.source_path; |
| 52 | 52 |
| 53 const disks::DiskMountManager::Disk* disk = | 53 const disks::DiskMountManager::Disk* disk = |
| 54 disks::DiskMountManager::GetInstance()->FindDiskBySourcePath(source_path); | 54 disks::DiskMountManager::GetInstance()->FindDiskBySourcePath(source_path); |
| 55 if (!disk || disk->device_type() == DEVICE_TYPE_UNKNOWN) | 55 if (!disk || disk->device_type() == DEVICE_TYPE_UNKNOWN) |
| 56 return false; | 56 return false; |
| 57 | 57 |
| 58 std::string unique_id = MakeDeviceUniqueId(*disk); | 58 std::string unique_id = MakeDeviceUniqueId(*disk); |
| 59 // Keep track of device uuid and label, to see how often we receive empty | 59 // Keep track of device uuid and label, to see how often we receive empty |
| 60 // values. | 60 // values. |
| 61 base::string16 device_label = UTF8ToUTF16(disk->device_label()); | 61 base::string16 device_label = base::UTF8ToUTF16(disk->device_label()); |
| 62 MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, device_label); | 62 MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, device_label); |
| 63 if (unique_id.empty()) | 63 if (unique_id.empty()) |
| 64 return false; | 64 return false; |
| 65 | 65 |
| 66 StorageInfo::Type type = has_dcim ? | 66 StorageInfo::Type type = has_dcim ? |
| 67 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM : | 67 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM : |
| 68 StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM; | 68 StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM; |
| 69 | 69 |
| 70 *info = StorageInfo(StorageInfo::MakeDeviceId(type, unique_id), | 70 *info = StorageInfo(StorageInfo::MakeDeviceId(type, unique_id), |
| 71 base::string16(), | 71 base::string16(), |
| 72 mount_info.mount_path, | 72 mount_info.mount_path, |
| 73 device_label, | 73 device_label, |
| 74 UTF8ToUTF16(disk->vendor_name()), | 74 base::UTF8ToUTF16(disk->vendor_name()), |
| 75 UTF8ToUTF16(disk->product_name()), | 75 base::UTF8ToUTF16(disk->product_name()), |
| 76 disk->total_size_in_bytes()); | 76 disk->total_size_in_bytes()); |
| 77 return true; | 77 return true; |
| 78 } | 78 } |
| 79 | 79 |
| 80 // Returns whether the mount point in |mount_info| is a media device or not. | 80 // Returns whether the mount point in |mount_info| is a media device or not. |
| 81 bool CheckMountedPathOnFileThread( | 81 bool CheckMountedPathOnFileThread( |
| 82 const disks::DiskMountManager::MountPointInfo& mount_info) { | 82 const disks::DiskMountManager::MountPointInfo& mount_info) { |
| 83 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 83 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 84 return MediaStorageUtil::HasDcim(base::FilePath(mount_info.mount_path)); | 84 return MediaStorageUtil::HasDcim(base::FilePath(mount_info.mount_path)); |
| 85 } | 85 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 mount_map_.insert(std::make_pair(mount_info.mount_path, info)); | 303 mount_map_.insert(std::make_pair(mount_info.mount_path, info)); |
| 304 | 304 |
| 305 receiver()->ProcessAttach(info); | 305 receiver()->ProcessAttach(info); |
| 306 } | 306 } |
| 307 | 307 |
| 308 } // namespace chromeos | 308 } // namespace chromeos |
| 309 | 309 |
| 310 StorageMonitor* StorageMonitor::Create() { | 310 StorageMonitor* StorageMonitor::Create() { |
| 311 return new chromeos::StorageMonitorCros(); | 311 return new chromeos::StorageMonitorCros(); |
| 312 } | 312 } |
| OLD | NEW |