diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-19 04:37:04 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-19 04:37:04 +0000 |
commit | f6249cbcd3c24602533d882cff8cf4e5532628ab (patch) | |
tree | 039e25ec08001321f093f9dff576d7c9c58d1eb5 /chrome | |
parent | 4385014499032789eb4db19a4ce3d34403dca62e (diff) | |
download | chromium_src-f6249cbcd3c24602533d882cff8cf4e5532628ab.zip chromium_src-f6249cbcd3c24602533d882cff8cf4e5532628ab.tar.gz chromium_src-f6249cbcd3c24602533d882cff8cf4e5532628ab.tar.bz2 |
Media Galleries: Fix DCHECK failure in MediaStorageUtil::GetDeviceInfoFromPath().
BUG=170839
Review URL: https://chromiumcodereview.appspot.com/12017009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/system_monitor/media_storage_util.cc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/chrome/browser/system_monitor/media_storage_util.cc b/chrome/browser/system_monitor/media_storage_util.cc index bf7d7e5..4bc50cb 100644 --- a/chrome/browser/system_monitor/media_storage_util.cc +++ b/chrome/browser/system_monitor/media_storage_util.cc @@ -121,6 +121,19 @@ void FilterAttachedDevicesOnFileThread(MediaStorageUtil::DeviceIdSet* devices) { } } +#if defined(OS_MACOSX) || defined(OS_LINUX) // Implies OS_CHROMEOS +// For a device with |device_name| and a relative path |sub_folder|, construct +// a display name. If |sub_folder| is empty, then just return |device_name|. +string16 GetDisplayNameForSubFolder(const string16& device_name, + const FilePath& sub_folder) { + if (sub_folder.empty()) + return device_name; + return (sub_folder.BaseName().LossyDisplayName() + + ASCIIToUTF16(" - ") + + device_name); +} +#endif + } // namespace // static @@ -249,6 +262,7 @@ void MediaStorageUtil::FilterAttachedDevices(DeviceIdSet* devices, done); } +// TODO(kmadhusu) Write unit tests for GetDeviceInfoFromPath(). bool MediaStorageUtil::GetDeviceInfoFromPath(const FilePath& path, std::string* device_id, string16* device_name, @@ -283,9 +297,10 @@ bool MediaStorageUtil::GetDeviceInfoFromPath(const FilePath& path, *device_id = device_info.device_id; FilePath sub_folder_path; - if (device_name || relative_path) { - bool success = FilePath(device_info.location) - .AppendRelativePath(path, &sub_folder_path); + if ((device_name || relative_path) && + (path.value() != device_info.location)) { + FilePath device_path(device_info.location); + bool success = device_path.AppendRelativePath(path, &sub_folder_path); DCHECK(success); } @@ -293,10 +308,7 @@ bool MediaStorageUtil::GetDeviceInfoFromPath(const FilePath& path, #if defined(OS_MACOSX) || defined(OS_LINUX) // Implies OS_CHROMEOS *device_name = GetDisplayNameForDevice( notifier->GetStorageSize(device_info.location), - sub_folder_path.value().empty() ? - device_info.name : - sub_folder_path.BaseName().LossyDisplayName() + - ASCIIToUTF16(" - ") + device_info.name); + GetDisplayNameForSubFolder(device_info.name, sub_folder_path)); #else *device_name = device_info.name; #endif |