diff options
author | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 01:18:34 +0000 |
---|---|---|
committer | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 01:18:34 +0000 |
commit | 7138c05155b6be2d15d7875fa44d4709d097a18b (patch) | |
tree | 82eed5ed46e9273c171029eaeda7e13d58a7a692 /chrome/browser/storage_monitor | |
parent | bf6b978941c5e7d59731c384e9c1a4da8f3b1f6d (diff) | |
download | chromium_src-7138c05155b6be2d15d7875fa44d4709d097a18b.zip chromium_src-7138c05155b6be2d15d7875fa44d4709d097a18b.tar.gz chromium_src-7138c05155b6be2d15d7875fa44d4709d097a18b.tar.bz2 |
[StorageMonitor] Use StorageInfo in ChromeOS storage monitor internals.
R=vandebo@chromium.org
BUG=None
Review URL: https://chromiumcodereview.appspot.com/14715021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199883 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/storage_monitor')
-rw-r--r-- | chrome/browser/storage_monitor/storage_monitor_chromeos.cc | 80 |
1 files changed, 30 insertions, 50 deletions
diff --git a/chrome/browser/storage_monitor/storage_monitor_chromeos.cc b/chrome/browser/storage_monitor/storage_monitor_chromeos.cc index dbec839..726d7ef 100644 --- a/chrome/browser/storage_monitor/storage_monitor_chromeos.cc +++ b/chrome/browser/storage_monitor/storage_monitor_chromeos.cc @@ -45,30 +45,37 @@ std::string MakeDeviceUniqueId(const disks::DiskMountManager::Disk& disk) { } // Returns true if the requested device is valid, else false. On success, fills -// in |unique_id|, and |storage_size_in_bytes|. -bool GetDeviceInfo(const std::string& source_path, - std::string* unique_id, - uint64* storage_size_in_bytes, - string16* storage_label, - string16* vendor_name, - string16* model_name) { +// in |info|. +bool GetDeviceInfo(const disks::DiskMountManager::MountPointInfo& mount_info, + bool has_dcim, + chrome::StorageInfo* info) { + std::string source_path = mount_info.source_path; + const disks::DiskMountManager::Disk* disk = disks::DiskMountManager::GetInstance()->FindDiskBySourcePath(source_path); if (!disk || disk->device_type() == DEVICE_TYPE_UNKNOWN) return false; - if (unique_id) - *unique_id = MakeDeviceUniqueId(*disk); - - if (storage_size_in_bytes) - *storage_size_in_bytes = disk->total_size_in_bytes(); + std::string unique_id = MakeDeviceUniqueId(*disk); + // Keep track of device uuid and label, to see how often we receive empty + // values. + chrome::MediaStorageUtil::RecordDeviceInfoHistogram( + true, unique_id, UTF8ToUTF16(disk->device_label())); + if (unique_id.empty()) + return false; - if (vendor_name) - *vendor_name = UTF8ToUTF16(disk->vendor_name()); - if (model_name) - *model_name = UTF8ToUTF16(disk->product_name()); - if (storage_label) - *storage_label = UTF8ToUTF16(disk->device_label()); + if (info) { + chrome::MediaStorageUtil::Type type = has_dcim ? + chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM : + chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM; + + info->device_id = chrome::MediaStorageUtil::MakeDeviceId(type, unique_id); + info->location = mount_info.mount_path, + info->vendor_name = UTF8ToUTF16(disk->vendor_name()); + info->model_name = UTF8ToUTF16(disk->product_name()); + info->storage_label = UTF8ToUTF16(disk->device_label()); + info->total_size_in_bytes = disk->total_size_in_bytes(); + } return true; } @@ -284,43 +291,16 @@ void StorageMonitorCros::AddMountedPath( } // Get the media device uuid and label if exists. - std::string unique_id; - string16 storage_label; - string16 vendor_name; - string16 model_name; - uint64 storage_size_in_bytes; - if (!GetDeviceInfo(mount_info.source_path, &unique_id, - &storage_size_in_bytes, &storage_label, - &vendor_name, &model_name)) { + chrome::StorageInfo info; + if (!GetDeviceInfo(mount_info, has_dcim, &info)) return; - } - // Keep track of device uuid and label, to see how often we receive empty - // values. - chrome::MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, - storage_label); - if (unique_id.empty()) + if (info.device_id.empty()) return; - chrome::MediaStorageUtil::Type type = has_dcim ? - chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM : - chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM; - - std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(type, - unique_id); - - chrome::StorageInfo object_info( - device_id, - string16(), - mount_info.mount_path, - storage_label, - vendor_name, - model_name, - storage_size_in_bytes); - - mount_map_.insert(std::make_pair(mount_info.mount_path, object_info)); + mount_map_.insert(std::make_pair(mount_info.mount_path, info)); - receiver()->ProcessAttach(object_info); + receiver()->ProcessAttach(info); } } // namespace chromeos |