diff options
author | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-09 20:24:39 +0000 |
---|---|---|
committer | gbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-09 20:24:39 +0000 |
commit | 9be403c00f9b452c28b80fbed036c833c3373fc8 (patch) | |
tree | f33fbc591716d9c158f13f6fea4d8b42ad059371 /chrome/browser/storage_monitor | |
parent | a8fd80a5e16af6d08c919507a47bef683ccfbbb1 (diff) | |
download | chromium_src-9be403c00f9b452c28b80fbed036c833c3373fc8.zip chromium_src-9be403c00f9b452c28b80fbed036c833c3373fc8.tar.gz chromium_src-9be403c00f9b452c28b80fbed036c833c3373fc8.tar.bz2 |
[StorageMonitor] Stop setting 'name' in StorageInfo.
This name will be built later on, by consumers.
BUG=None
Review URL: https://chromiumcodereview.appspot.com/14785004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199264 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/storage_monitor')
9 files changed, 71 insertions, 173 deletions
diff --git a/chrome/browser/storage_monitor/media_storage_util.cc b/chrome/browser/storage_monitor/media_storage_util.cc index 2f71805..ba64bcf 100644 --- a/chrome/browser/storage_monitor/media_storage_util.cc +++ b/chrome/browser/storage_monitor/media_storage_util.cc @@ -383,12 +383,12 @@ base::FilePath MediaStorageUtil::FindDevicePathById( // static void MediaStorageUtil::RecordDeviceInfoHistogram(bool mass_storage, const std::string& device_uuid, - const string16& device_name) { + const string16& device_label) { unsigned int event_number = 0; if (!mass_storage) event_number = 4; - if (device_name.empty()) + if (device_label.empty()) event_number += 2; if (device_uuid.empty()) diff --git a/chrome/browser/storage_monitor/media_storage_util.h b/chrome/browser/storage_monitor/media_storage_util.h index 4dca346..0d34373 100644 --- a/chrome/browser/storage_monitor/media_storage_util.h +++ b/chrome/browser/storage_monitor/media_storage_util.h @@ -102,11 +102,11 @@ class MediaStorageUtil { static base::FilePath FindDevicePathById(const std::string& device_id); // Record device information histogram for the given |device_uuid| and - // |device_name|. |mass_storage| indicates whether the current device is a + // |device_label|. |mass_storage| indicates whether the current device is a // mass storage device, as defined by IsMassStorageDevice(). static void RecordDeviceInfoHistogram(bool mass_storage, const std::string& device_uuid, - const string16& device_name); + const string16& device_label); private: DISALLOW_IMPLICIT_CONSTRUCTORS(MediaStorageUtil); diff --git a/chrome/browser/storage_monitor/storage_monitor_chromeos.cc b/chrome/browser/storage_monitor/storage_monitor_chromeos.cc index 7046eb8..dbec839 100644 --- a/chrome/browser/storage_monitor/storage_monitor_chromeos.cc +++ b/chrome/browser/storage_monitor/storage_monitor_chromeos.cc @@ -25,39 +25,6 @@ namespace chromeos { namespace { -// Constructs a device name using label or manufacturer (vendor and product) -// name details. -string16 GetDeviceName(const disks::DiskMountManager::Disk& disk, - string16* storage_label, - string16* vendor_name, - string16* model_name) { - if (disk.device_type() == DEVICE_TYPE_SD) { - // Mount path of an SD card will be one of the following: - // (1) /media/removable/<volume_label> - // (2) /media/removable/SD Card - // If the volume label is available, mount path will be (1) else (2). - base::FilePath mount_point(disk.mount_path()); - const string16 display_name(mount_point.BaseName().LossyDisplayName()); - if (!display_name.empty()) - return display_name; - } - - const std::string& device_label = disk.device_label(); - - if (storage_label) - *storage_label = UTF8ToUTF16(device_label); - if (vendor_name) - *vendor_name = UTF8ToUTF16(disk.vendor_name()); - if (model_name) - *model_name = UTF8ToUTF16(disk.product_name()); - - if (!device_label.empty() && IsStringUTF8(device_label)) - return UTF8ToUTF16(device_label); - - return chrome::MediaStorageUtil::GetFullProductName(disk.vendor_name(), - disk.product_name()); -} - // Constructs a device id using uuid or manufacturer (vendor and product) id // details. std::string MakeDeviceUniqueId(const disks::DiskMountManager::Disk& disk) { @@ -78,10 +45,9 @@ std::string MakeDeviceUniqueId(const disks::DiskMountManager::Disk& disk) { } // Returns true if the requested device is valid, else false. On success, fills -// in |unique_id|, |device_label| and |storage_size_in_bytes|. +// in |unique_id|, and |storage_size_in_bytes|. bool GetDeviceInfo(const std::string& source_path, std::string* unique_id, - string16* device_label, uint64* storage_size_in_bytes, string16* storage_label, string16* vendor_name, @@ -94,12 +60,16 @@ bool GetDeviceInfo(const std::string& source_path, if (unique_id) *unique_id = MakeDeviceUniqueId(*disk); - if (device_label) - *device_label = GetDeviceName(*disk, storage_label, - vendor_name, model_name); - if (storage_size_in_bytes) *storage_size_in_bytes = disk->total_size_in_bytes(); + + 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()); + return true; } @@ -315,21 +285,21 @@ void StorageMonitorCros::AddMountedPath( // Get the media device uuid and label if exists. std::string unique_id; - string16 device_label; string16 storage_label; string16 vendor_name; string16 model_name; uint64 storage_size_in_bytes; - if (!GetDeviceInfo(mount_info.source_path, &unique_id, &device_label, + if (!GetDeviceInfo(mount_info.source_path, &unique_id, &storage_size_in_bytes, &storage_label, - &vendor_name, &model_name)) + &vendor_name, &model_name)) { return; + } // Keep track of device uuid and label, to see how often we receive empty // values. chrome::MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, - device_label); - if (unique_id.empty() || device_label.empty()) + storage_label); + if (unique_id.empty()) return; chrome::MediaStorageUtil::Type type = has_dcim ? @@ -341,8 +311,7 @@ void StorageMonitorCros::AddMountedPath( chrome::StorageInfo object_info( device_id, - chrome::MediaStorageUtil::GetDisplayNameForDevice(storage_size_in_bytes, - device_label), + string16(), mount_info.mount_path, storage_label, vendor_name, diff --git a/chrome/browser/storage_monitor/storage_monitor_chromeos_unittest.cc b/chrome/browser/storage_monitor/storage_monitor_chromeos_unittest.cc index f999ad7..6ea68a1 100644 --- a/chrome/browser/storage_monitor/storage_monitor_chromeos_unittest.cc +++ b/chrome/browser/storage_monitor/storage_monitor_chromeos_unittest.cc @@ -272,8 +272,7 @@ TEST_F(StorageMonitorCrosTest, BasicAttachDetach) { EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id); - EXPECT_EQ(ASCIIToUTF16(kDevice1NameWithSizeInfo), - observer().last_attached().name); + EXPECT_EQ(string16(), observer().last_attached().name); EXPECT_EQ(mount_path1.value(), observer().last_attached().location); UnmountDevice(MOUNT_ERROR_NONE, mount_info); @@ -292,8 +291,7 @@ TEST_F(StorageMonitorCrosTest, BasicAttachDetach) { EXPECT_EQ(2, observer().attach_calls()); EXPECT_EQ(1, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_attached().device_id); - EXPECT_EQ(ASCIIToUTF16(kDevice2NameWithSizeInfo), - observer().last_attached().name); + EXPECT_EQ(string16(), observer().last_attached().name); EXPECT_EQ(mount_path2.value(), observer().last_attached().location); UnmountDevice(MOUNT_ERROR_NONE, mount_info2); @@ -320,8 +318,7 @@ TEST_F(StorageMonitorCrosTest, NoDCIM) { EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(device_id, observer().last_attached().device_id); - EXPECT_EQ(ASCIIToUTF16(kDevice1NameWithSizeInfo), - observer().last_attached().name); + EXPECT_EQ(string16(), observer().last_attached().name); EXPECT_EQ(mount_path.value(), observer().last_attached().location); } @@ -370,8 +367,7 @@ TEST_F(StorageMonitorCrosTest, SDCardAttachDetach) { EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_attached().device_id); - EXPECT_EQ(ASCIIToUTF16(kSDCardDeviceName1), - observer().last_attached().name); + EXPECT_EQ(string16(), observer().last_attached().name); EXPECT_EQ(mount_path1.value(), observer().last_attached().location); UnmountDevice(MOUNT_ERROR_NONE, mount_info1); @@ -390,8 +386,7 @@ TEST_F(StorageMonitorCrosTest, SDCardAttachDetach) { EXPECT_EQ(2, observer().attach_calls()); EXPECT_EQ(1, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_attached().device_id); - EXPECT_EQ(ASCIIToUTF16(kSDCardDeviceName2), - observer().last_attached().name); + EXPECT_EQ(string16(), observer().last_attached().name); EXPECT_EQ(mount_path2.value(), observer().last_attached().location); UnmountDevice(MOUNT_ERROR_NONE, mount_info2); @@ -412,8 +407,7 @@ TEST_F(StorageMonitorCrosTest, AttachDeviceWithEmptyLabel) { EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id); - EXPECT_EQ(ASCIIToUTF16(kDeviceNameWithManufacturerDetails), - observer().last_attached().name); + EXPECT_EQ(string16(), observer().last_attached().name); EXPECT_EQ(mount_path1.value(), observer().last_attached().location); UnmountDevice(MOUNT_ERROR_NONE, mount_info); @@ -434,8 +428,7 @@ TEST_F(StorageMonitorCrosTest, GetStorageSize) { EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id); - EXPECT_EQ(ASCIIToUTF16(kDeviceNameWithManufacturerDetails), - observer().last_attached().name); + EXPECT_EQ(string16(), observer().last_attached().name); EXPECT_EQ(mount_path1.value(), observer().last_attached().location); EXPECT_EQ(kDevice1SizeInBytes, GetDeviceStorageSize(mount_path1.value())); diff --git a/chrome/browser/storage_monitor/storage_monitor_linux.cc b/chrome/browser/storage_monitor/storage_monitor_linux.cc index c3ae977..1b73d49 100644 --- a/chrome/browser/storage_monitor/storage_monitor_linux.cc +++ b/chrome/browser/storage_monitor/storage_monitor_linux.cc @@ -52,6 +52,11 @@ const char kVendorID[] = "ID_VENDOR_ID"; // Construct a device id using label or manufacturer (vendor and model) details. std::string MakeDeviceUniqueId(struct udev_device* device) { std::string uuid = GetUdevDevicePropertyValue(device, kFsUUID); + // Keep track of device uuid, to see how often we receive empty uuid values. + UMA_HISTOGRAM_BOOLEAN( + "RemovableDeviceNotificationsLinux.device_file_system_uuid_available", + !uuid.empty()); + if (!uuid.empty()) return kFSUniqueIdPrefix + uuid; @@ -112,10 +117,10 @@ uint64 GetDeviceStorageSize(const base::FilePath& device_path, // Constructs the device name from the device properties. If the device details // are unavailable, returns an empty string. -string16 GetDeviceName(struct udev_device* device, - string16* out_volume_label, - string16* out_vendor_name, - string16* out_model_name) { +void GetDeviceName(struct udev_device* device, + string16* out_volume_label, + string16* out_vendor_name, + string16* out_model_name) { std::string device_label = GetUdevDevicePropertyValue(device, kLabel); std::string vendor_name = GetUdevDevicePropertyValue(device, kVendor); std::string model_name = GetUdevDevicePropertyValue(device, kModel); @@ -125,25 +130,6 @@ string16 GetDeviceName(struct udev_device* device, *out_vendor_name = UTF8ToUTF16(vendor_name); if (out_model_name) *out_model_name = UTF8ToUTF16(model_name); - - if (!device_label.empty() && IsStringUTF8(device_label)) - return UTF8ToUTF16(device_label); - - device_label = GetUdevDevicePropertyValue(device, kFsUUID); - // Keep track of device uuid, to see how often we receive empty uuid values. - UMA_HISTOGRAM_BOOLEAN( - "RemovableDeviceNotificationsLinux.device_file_system_uuid_available", - !device_label.empty()); - - const string16 name = MediaStorageUtil::GetFullProductName(vendor_name, - model_name); - - const string16 device_label_utf16 = - (!device_label.empty() && IsStringUTF8(device_label)) ? - UTF8ToUTF16(device_label) : string16(); - if (!name.empty() && !device_label_utf16.empty()) - return device_label_utf16 + ASCIIToUTF16(" ") + name; - return name.empty() ? device_label_utf16 : name; } // Gets the device information using udev library. @@ -177,15 +163,16 @@ scoped_ptr<StorageInfo> GetDeviceInfo(const base::FilePath& device_path, if (!device.get()) return storage_info.Pass(); - string16 volume_label; - string16 vendor_name; - string16 model_name; - string16 device_name = GetDeviceName(device, &volume_label, - &vendor_name, &model_name); + string16 volume_label = UTF8ToUTF16(GetUdevDevicePropertyValue(device, + kLabel)); + string16 vendor_name = UTF8ToUTF16(GetUdevDevicePropertyValue(device, + kVendor)); + string16 model_name = UTF8ToUTF16(GetUdevDevicePropertyValue(device, kModel)); + std::string unique_id = MakeDeviceUniqueId(device); // Keep track of device info details to see how often we get invalid values. - MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, device_name); + MediaStorageUtil::RecordDeviceInfoHistogram(true, unique_id, volume_label); const char* value = udev_device_get_sysattr_value(device, kRemovableSysAttr); if (!value) { @@ -211,7 +198,7 @@ scoped_ptr<StorageInfo> GetDeviceInfo(const base::FilePath& device_path, storage_info.reset(new StorageInfo( MediaStorageUtil::MakeDeviceId(type, unique_id), - device_name, + string16(), mount_point.value(), volume_label, vendor_name, @@ -510,7 +497,6 @@ void StorageMonitorLinux::AddNewMount(const base::FilePath& mount_device, return; DCHECK(!storage_info->device_id.empty()); - DCHECK(!storage_info->name.empty()); bool removable = MediaStorageUtil::IsRemovableDevice(storage_info->device_id); const base::FilePath mount_point(storage_info->location); @@ -520,13 +506,8 @@ void StorageMonitorLinux::AddNewMount(const base::FilePath& mount_device, mount_point_info.storage_info = *storage_info; mount_info_map_[mount_point] = mount_point_info; mount_priority_map_[mount_device][mount_point] = removable; - - if (removable) { - // TODO(gbillock) Do this in a higher level instead of here. - storage_info->name = MediaStorageUtil::GetDisplayNameForDevice( - storage_info->total_size_in_bytes, storage_info->name); + if (removable) receiver()->ProcessAttach(*storage_info); - } } } // namespace chrome diff --git a/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc b/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc index af5aaca..e2e441b 100644 --- a/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc +++ b/chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc @@ -89,7 +89,7 @@ scoped_ptr<StorageInfo> GetDeviceInfo(const base::FilePath& device_path, MediaStorageUtil::Type type = kTestDeviceData[i].type; storage_info.reset(new StorageInfo( MediaStorageUtil::MakeDeviceId(type, kTestDeviceData[i].unique_id), - ASCIIToUTF16(kTestDeviceData[i].device_name), + string16(), mount_point.value(), ASCIIToUTF16("volume label"), ASCIIToUTF16("vendor name"), @@ -120,25 +120,6 @@ std::string GetDeviceId(const std::string& device) { return std::string(); } -string16 GetDeviceNameWithSizeDetails(const std::string& device) { - for (size_t i = 0; i < arraysize(kTestDeviceData); ++i) { - if (device == kTestDeviceData[i].device_path) { - return MediaStorageUtil::GetDisplayNameForDevice( - kTestDeviceData[i].partition_size_in_bytes, - ASCIIToUTF16(kTestDeviceData[i].device_name)); - } - } - return string16(); -} - -string16 GetDeviceName(const std::string& device) { - for (size_t i = 0; i < arraysize(kTestDeviceData); i++) { - if (device == kTestDeviceData[i].device_path) - return ASCIIToUTF16(kTestDeviceData[i].device_name); - } - return string16(); -} - class TestStorageMonitorLinux : public StorageMonitorLinux { public: TestStorageMonitorLinux(const base::FilePath& path, MessageLoop* message_loop) @@ -354,8 +335,7 @@ TEST_F(StorageMonitorLinuxTest, BasicAttachDetach) { EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(GetDeviceId(kDeviceDCIM2), observer().last_attached().device_id); - EXPECT_EQ(GetDeviceNameWithSizeDetails(kDeviceDCIM2), - observer().last_attached().name); + EXPECT_EQ(string16(), observer().last_attached().name); EXPECT_EQ(test_path.value(), observer().last_attached().location); @@ -379,8 +359,7 @@ TEST_F(StorageMonitorLinuxTest, Removable) { EXPECT_EQ(1, observer().attach_calls()); EXPECT_EQ(0, observer().detach_calls()); EXPECT_EQ(GetDeviceId(kDeviceDCIM1), observer().last_attached().device_id); - EXPECT_EQ(GetDeviceNameWithSizeDetails(kDeviceDCIM1), - observer().last_attached().name); + EXPECT_EQ(string16(), observer().last_attached().name); EXPECT_EQ(test_path_a.value(), observer().last_attached().location); @@ -408,8 +387,7 @@ TEST_F(StorageMonitorLinuxTest, Removable) { EXPECT_EQ(2, observer().attach_calls()); EXPECT_EQ(1, observer().detach_calls()); EXPECT_EQ(GetDeviceId(kDeviceNoDCIM), observer().last_attached().device_id); - EXPECT_EQ(GetDeviceNameWithSizeDetails(kDeviceNoDCIM), - observer().last_attached().name); + EXPECT_EQ(string16(), observer().last_attached().name); EXPECT_EQ(test_path_b.value(), observer().last_attached().location); @@ -637,7 +615,7 @@ TEST_F(StorageMonitorLinuxTest, DeviceLookUp) { EXPECT_TRUE(notifier()->GetStorageInfoForPath(test_path_a, &device_info)); EXPECT_EQ(GetDeviceId(kDeviceDCIM1), device_info.device_id); EXPECT_EQ(test_path_a.value(), device_info.location); - EXPECT_EQ(GetDeviceName(kDeviceDCIM1), device_info.name); + EXPECT_EQ(string16(), device_info.name); EXPECT_EQ(88788ULL, device_info.total_size_in_bytes); EXPECT_EQ(ASCIIToUTF16("volume label"), device_info.storage_label); EXPECT_EQ(ASCIIToUTF16("vendor name"), device_info.vendor_name); @@ -646,12 +624,12 @@ TEST_F(StorageMonitorLinuxTest, DeviceLookUp) { EXPECT_TRUE(notifier()->GetStorageInfoForPath(test_path_b, &device_info)); EXPECT_EQ(GetDeviceId(kDeviceNoDCIM), device_info.device_id); EXPECT_EQ(test_path_b.value(), device_info.location); - EXPECT_EQ(GetDeviceName(kDeviceNoDCIM), device_info.name); + EXPECT_EQ(string16(), device_info.name); EXPECT_TRUE(notifier()->GetStorageInfoForPath(test_path_c, &device_info)); EXPECT_EQ(GetDeviceId(kDeviceFixed), device_info.device_id); EXPECT_EQ(test_path_c.value(), device_info.location); - EXPECT_EQ(GetDeviceName(kDeviceFixed), device_info.name); + EXPECT_EQ(string16(), device_info.name); // An invalid path. EXPECT_FALSE( @@ -663,7 +641,7 @@ TEST_F(StorageMonitorLinuxTest, DeviceLookUp) { &device_info)); EXPECT_EQ(GetDeviceId(kDeviceDCIM1), device_info.device_id); EXPECT_EQ(test_path_a.value(), device_info.location); - EXPECT_EQ(GetDeviceName(kDeviceDCIM1), device_info.name); + EXPECT_EQ(string16(), device_info.name); // One device attached at multiple points. // kDeviceDCIM1 -> kMountPointA * diff --git a/chrome/browser/storage_monitor/storage_monitor_mac.mm b/chrome/browser/storage_monitor/storage_monitor_mac.mm index e6d130a..24af706 100644 --- a/chrome/browser/storage_monitor/storage_monitor_mac.mm +++ b/chrome/browser/storage_monitor/storage_monitor_mac.mm @@ -72,13 +72,6 @@ StorageInfo BuildStorageInfo( info.storage_label = GetUTF16FromDictionary( dict, kDADiskDescriptionVolumeNameKey); - if (!info.storage_label.empty()) { - info.name = info.storage_label; - } else { - info.name = MediaStorageUtil::GetFullProductName( - UTF16ToUTF8(info.vendor_name), UTF16ToUTF8(info.model_name)); - } - CFUUIDRef uuid = base::mac::GetValueFromDictionary<CFUUIDRef>( dict, kDADiskDescriptionVolumeUUIDKey); std::string unique_id; @@ -240,21 +233,15 @@ void StorageMonitorMac::UpdateDisk( } } - StorageInfo storage_info(info); - if (ShouldPostNotificationForDisk(storage_info)) { - storage_info.name = MediaStorageUtil::GetDisplayNameForDevice( - storage_info.total_size_in_bytes, storage_info.name); - } - if (update_type == UPDATE_DEVICE_REMOVED) { if (it != disk_info_map_.end()) disk_info_map_.erase(it); } else { - disk_info_map_[bsd_name] = storage_info; - MediaStorageUtil::RecordDeviceInfoHistogram(true, storage_info.device_id, - storage_info.name); - if (ShouldPostNotificationForDisk(storage_info)) - receiver()->ProcessAttach(storage_info); + disk_info_map_[bsd_name] = info; + MediaStorageUtil::RecordDeviceInfoHistogram(true, info.device_id, + info.storage_label); + if (ShouldPostNotificationForDisk(info)) + receiver()->ProcessAttach(info); } // We're not really honestly sure we're done, but this looks the best we @@ -364,7 +351,6 @@ bool StorageMonitorMac::ShouldPostNotificationForDisk( // Only post notifications about disks that have no empty fields and // are removable. Also exclude disk images (DMGs). return !info.device_id.empty() && - !info.name.empty() && !info.location.empty() && info.model_name != ASCIIToUTF16(kDiskImageModelName) && MediaStorageUtil::IsRemovableDevice(info.device_id) && diff --git a/chrome/browser/storage_monitor/storage_monitor_mac_unittest.mm b/chrome/browser/storage_monitor/storage_monitor_mac_unittest.mm index 6a890e8..655f8138 100644 --- a/chrome/browser/storage_monitor/storage_monitor_mac_unittest.mm +++ b/chrome/browser/storage_monitor/storage_monitor_mac_unittest.mm @@ -26,11 +26,10 @@ namespace { StorageInfo CreateStorageInfo( const std::string& device_id, const std::string& model_name, - const string16& display_name, const base::FilePath& mount_point, uint64 size_bytes) { return StorageInfo( - device_id, display_name, mount_point.value(), + device_id, string16(), mount_point.value(), string16(), string16(), UTF8ToUTF16(model_name), size_bytes); } @@ -51,12 +50,10 @@ class StorageMonitorMacTest : public testing::Test { monitor_->AddObserver(mock_storage_observer_.get()); unique_id_ = "test_id"; - display_name_ = ASCIIToUTF16("977 KB Test Display Name"); mount_point_ = base::FilePath("/unused_test_directory"); device_id_ = MediaStorageUtil::MakeDeviceId( MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM, unique_id_); disk_info_ = CreateStorageInfo(device_id_, "", - ASCIIToUTF16("Test Display Name"), mount_point_, kTestSize); } @@ -78,7 +75,6 @@ class StorageMonitorMacTest : public testing::Test { // Information about the disk. std::string unique_id_; - string16 display_name_; base::FilePath mount_point_; std::string device_id_; StorageInfo disk_info_; @@ -92,7 +88,7 @@ TEST_F(StorageMonitorMacTest, AddRemove) { EXPECT_EQ(1, mock_storage_observer_->attach_calls()); EXPECT_EQ(0, mock_storage_observer_->detach_calls()); EXPECT_EQ(device_id_, mock_storage_observer_->last_attached().device_id); - EXPECT_EQ(display_name_, mock_storage_observer_->last_attached().name); + EXPECT_EQ(string16(), mock_storage_observer_->last_attached().name); EXPECT_EQ(mount_point_.value(), mock_storage_observer_->last_attached().location); @@ -109,14 +105,14 @@ TEST_F(StorageMonitorMacTest, UpdateVolumeName) { EXPECT_EQ(1, mock_storage_observer_->attach_calls()); EXPECT_EQ(0, mock_storage_observer_->detach_calls()); EXPECT_EQ(device_id_, mock_storage_observer_->last_attached().device_id); - EXPECT_EQ(display_name_, mock_storage_observer_->last_attached().name); + EXPECT_EQ(string16(), mock_storage_observer_->last_attached().name); + EXPECT_EQ(kTestSize, + mock_storage_observer_->last_attached().total_size_in_bytes); EXPECT_EQ(mount_point_.value(), mock_storage_observer_->last_attached().location); - string16 new_display_name(ASCIIToUTF16("977 KB Test Display Name")); StorageInfo info2 = CreateStorageInfo( - device_id_, "", ASCIIToUTF16("Test Display Name"), mount_point_, - kTestSize); + device_id_, "", mount_point_, kTestSize * 2); UpdateDisk(info2, StorageMonitorMac::UPDATE_DEVICE_CHANGED); message_loop_.RunUntilIdle(); @@ -124,7 +120,9 @@ TEST_F(StorageMonitorMacTest, UpdateVolumeName) { EXPECT_EQ(device_id_, mock_storage_observer_->last_detached().device_id); EXPECT_EQ(2, mock_storage_observer_->attach_calls()); EXPECT_EQ(device_id_, mock_storage_observer_->last_attached().device_id); - EXPECT_EQ(new_display_name, mock_storage_observer_->last_attached().name); + EXPECT_EQ(string16(), mock_storage_observer_->last_attached().name); + EXPECT_EQ(kTestSize * 2, + mock_storage_observer_->last_attached().total_size_in_bytes); EXPECT_EQ(mount_point_.value(), mock_storage_observer_->last_attached().location); } @@ -138,16 +136,14 @@ TEST_F(StorageMonitorMacTest, DCIM) { base::FilePath mount_point = temp_dir.path(); std::string device_id = MediaStorageUtil::MakeDeviceId( MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM, unique_id_); - StorageInfo info = CreateStorageInfo( - device_id, "", ASCIIToUTF16("Test Display Name"), mount_point, - kTestSize); + StorageInfo info = CreateStorageInfo(device_id, "", mount_point, kTestSize); UpdateDisk(info, StorageMonitorMac::UPDATE_DEVICE_ADDED); EXPECT_EQ(1, mock_storage_observer_->attach_calls()); EXPECT_EQ(0, mock_storage_observer_->detach_calls()); EXPECT_EQ(device_id, mock_storage_observer_->last_attached().device_id); - EXPECT_EQ(display_name_, mock_storage_observer_->last_attached().name); + EXPECT_EQ(string16(), mock_storage_observer_->last_attached().name); EXPECT_EQ(mount_point.value(), mock_storage_observer_->last_attached().location); } @@ -158,7 +154,7 @@ TEST_F(StorageMonitorMacTest, GetStorageInfo) { EXPECT_EQ(1, mock_storage_observer_->attach_calls()); EXPECT_EQ(0, mock_storage_observer_->detach_calls()); EXPECT_EQ(device_id_, mock_storage_observer_->last_attached().device_id); - EXPECT_EQ(display_name_, mock_storage_observer_->last_attached().name); + EXPECT_EQ(string16(), mock_storage_observer_->last_attached().name); EXPECT_EQ(mount_point_.value(), mock_storage_observer_->last_attached().location); @@ -166,7 +162,7 @@ TEST_F(StorageMonitorMacTest, GetStorageInfo) { EXPECT_TRUE(monitor_->GetStorageInfoForPath(mount_point_.AppendASCII("foo"), &info)); EXPECT_EQ(device_id_, info.device_id); - EXPECT_EQ(ASCIIToUTF16("977 KB Test Display Name"), info.name); + EXPECT_EQ(string16(), info.name); EXPECT_EQ(mount_point_.value(), info.location); EXPECT_EQ(kTestSize, info.total_size_in_bytes); @@ -177,7 +173,7 @@ TEST_F(StorageMonitorMacTest, GetStorageInfo) { // Test that mounting a DMG doesn't send a notification. TEST_F(StorageMonitorMacTest, DMG) { StorageInfo info = CreateStorageInfo( - device_id_, "Disk Image", display_name_, mount_point_, kTestSize); + device_id_, "Disk Image", mount_point_, kTestSize); UpdateDisk(info, StorageMonitorMac::UPDATE_DEVICE_ADDED); EXPECT_EQ(0, mock_storage_observer_->attach_calls()); } diff --git a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc index 3a20797..7e627b5 100644 --- a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc +++ b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc @@ -154,11 +154,6 @@ bool GetDeviceDetails(const base::FilePath& device_path, // for the volume. info->vendor_name = string16(); info->model_name = string16(); - - string16 name = !volume_label.empty() ? volume_label - : device_path.LossyDisplayName(); - info->name = chrome::MediaStorageUtil::GetDisplayNameForDevice( - info->total_size_in_bytes, name); info->storage_label = volume_label; return true; |