summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-22 18:10:29 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-22 18:10:29 +0000
commitfb7bc5c917c063ec1a035a218a8596b6c6a88092 (patch)
treeb96172823d76f719f8572e620a65ca21d4b75aa2
parent8893b8be2230d8a18e1d726321a96851c82d4c81 (diff)
downloadchromium_src-fb7bc5c917c063ec1a035a218a8596b6c6a88092.zip
chromium_src-fb7bc5c917c063ec1a035a218a8596b6c6a88092.tar.gz
chromium_src-fb7bc5c917c063ec1a035a218a8596b6c6a88092.tar.bz2
StorageMonitor: Remove more conditionals that are always true.
Review URL: https://chromiumcodereview.appspot.com/15535009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201576 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/storage_monitor/storage_monitor_chromeos.cc23
-rw-r--r--chrome/browser/storage_monitor/test_volume_mount_watcher_win.cc31
-rw-r--r--chrome/browser/storage_monitor/volume_mount_watcher_win.cc33
3 files changed, 39 insertions, 48 deletions
diff --git a/chrome/browser/storage_monitor/storage_monitor_chromeos.cc b/chrome/browser/storage_monitor/storage_monitor_chromeos.cc
index 8b26742..64341ad 100644
--- a/chrome/browser/storage_monitor/storage_monitor_chromeos.cc
+++ b/chrome/browser/storage_monitor/storage_monitor_chromeos.cc
@@ -50,6 +50,7 @@ std::string MakeDeviceUniqueId(const disks::DiskMountManager::Disk& disk) {
bool GetDeviceInfo(const disks::DiskMountManager::MountPointInfo& mount_info,
bool has_dcim,
chrome::StorageInfo* info) {
+ DCHECK(info);
std::string source_path = mount_info.source_path;
const disks::DiskMountManager::Disk* disk =
@@ -66,19 +67,15 @@ bool GetDeviceInfo(const disks::DiskMountManager::MountPointInfo& mount_info,
if (unique_id.empty())
return false;
- if (info) {
- chrome::StorageInfo::Type type = has_dcim ?
- chrome::StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM :
- chrome::StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM;
-
- info->device_id = chrome::StorageInfo::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 = device_label;
- info->total_size_in_bytes = disk->total_size_in_bytes();
- }
-
+ chrome::StorageInfo::Type type = has_dcim ?
+ chrome::StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM :
+ chrome::StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM;
+ info->device_id = chrome::StorageInfo::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 = device_label;
+ info->total_size_in_bytes = disk->total_size_in_bytes();
return true;
}
diff --git a/chrome/browser/storage_monitor/test_volume_mount_watcher_win.cc b/chrome/browser/storage_monitor/test_volume_mount_watcher_win.cc
index 3dc2952..eac7710 100644
--- a/chrome/browser/storage_monitor/test_volume_mount_watcher_win.cc
+++ b/chrome/browser/storage_monitor/test_volume_mount_watcher_win.cc
@@ -40,6 +40,8 @@ std::vector<base::FilePath> FakeGetAttachedDevices() {
// 'C:\' is not removable (so that auto-added paths are correctly handled).
bool GetMassStorageDeviceDetails(const base::FilePath& device_path,
StorageInfo* info) {
+ DCHECK(info);
+
// Truncate to root path.
base::FilePath path(device_path);
if (device_path.value().length() > 3) {
@@ -49,26 +51,23 @@ bool GetMassStorageDeviceDetails(const base::FilePath& device_path,
return false;
}
- if (info) {
- info->location = path.value();
- info->total_size_in_bytes = 1000000;
-
- std::string unique_id =
- "\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\";
- unique_id[11] = device_path.value()[0];
- chrome::StorageInfo::Type type = chrome::StorageInfo::FIXED_MASS_STORAGE;
- if (path.value() != ASCIIToUTF16("N:\\") &&
- path.value() != ASCIIToUTF16("C:\\")) {
- type = chrome::StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM;
- }
- info->device_id = chrome::StorageInfo::MakeDeviceId(type, unique_id);
- info->storage_label = path.Append(L" Drive").LossyDisplayName();
- }
+ info->location = path.value();
+ info->total_size_in_bytes = 1000000;
+ std::string unique_id =
+ "\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\";
+ unique_id[11] = device_path.value()[0];
+ chrome::StorageInfo::Type type = chrome::StorageInfo::FIXED_MASS_STORAGE;
+ if (path.value() != ASCIIToUTF16("N:\\") &&
+ path.value() != ASCIIToUTF16("C:\\")) {
+ type = chrome::StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM;
+ }
+ info->device_id = chrome::StorageInfo::MakeDeviceId(type, unique_id);
+ info->storage_label = path.Append(L" Drive").LossyDisplayName();
return true;
}
-} // namespace
+} // namespace
// TestVolumeMountWatcherWin ---------------------------------------------------
diff --git a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
index ec1c7d7..aa2d033 100644
--- a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
+++ b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
@@ -118,6 +118,8 @@ uint64 GetVolumeSize(const string16& mount_point) {
// http://blogs.msdn.com/b/adioltean/archive/2005/04/16/408947.aspx.
bool GetDeviceDetails(const base::FilePath& device_path,
chrome::StorageInfo* info) {
+ DCHECK(info);
+
string16 mount_point;
if (!GetVolumePathName(device_path.value().c_str(),
WriteInto(&mount_point, kMaxPathBufLen),
@@ -129,18 +131,16 @@ bool GetDeviceDetails(const base::FilePath& device_path,
// Note: experimentally this code does not spin a floppy drive. It
// returns a GUID associated with the device, not the volume.
string16 guid;
- if (info) {
- if (!GetVolumeNameForVolumeMountPoint(mount_point.c_str(),
- WriteInto(&guid, kMaxPathBufLen),
- kMaxPathBufLen)) {
- return false;
- }
- // In case it has two GUID's (see above mentioned blog), do it again.
- if (!GetVolumeNameForVolumeMountPoint(guid.c_str(),
- WriteInto(&guid, kMaxPathBufLen),
- kMaxPathBufLen)) {
- return false;
- }
+ if (!GetVolumeNameForVolumeMountPoint(mount_point.c_str(),
+ WriteInto(&guid, kMaxPathBufLen),
+ kMaxPathBufLen)) {
+ return false;
+ }
+ // In case it has two GUID's (see above mentioned blog), do it again.
+ if (!GetVolumeNameForVolumeMountPoint(guid.c_str(),
+ WriteInto(&guid, kMaxPathBufLen),
+ kMaxPathBufLen)) {
+ return false;
}
// If we're adding a floppy drive, return without querying any more
@@ -148,16 +148,11 @@ bool GetDeviceDetails(const base::FilePath& device_path,
// Note: treats FLOPPY as FIXED_MASS_STORAGE. This is intentional.
DeviceType device_type = GetDeviceType(mount_point);
if (device_type == FLOPPY) {
- if (info) {
- info->device_id = chrome::StorageInfo::MakeDeviceId(
- chrome::StorageInfo::FIXED_MASS_STORAGE, UTF16ToUTF8(guid));
- }
+ info->device_id = chrome::StorageInfo::MakeDeviceId(
+ chrome::StorageInfo::FIXED_MASS_STORAGE, UTF16ToUTF8(guid));
return true;
}
- if (!info)
- return true;
-
chrome::StorageInfo::Type type =
chrome::StorageInfo::FIXED_MASS_STORAGE;
if (device_type == REMOVABLE) {