Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2779)

Unified Diff: chrome/browser/storage_monitor/volume_mount_watcher_win.cc

Issue 12450005: Eliminate getting disk metadata for floppy drives. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/storage_monitor/volume_mount_watcher_win.cc
diff --git a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
index cc68938cbe052080d0e16b8552ded67712ad02db..0a76d1122e4233f0787a8c67719a7f4db24d9e36 100644
--- a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
+++ b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
@@ -22,9 +22,15 @@ namespace {
const DWORD kMaxPathBufLen = MAX_PATH + 1;
-bool IsRemovable(const string16& mount_point) {
+enum DeviceType {
+ FLOPPY,
+ REMOVABLE,
+ FIXED,
+};
+
+DeviceType GetDeviceType(const string16& mount_point) {
if (GetDriveType(mount_point.c_str()) != DRIVE_REMOVABLE)
- return false;
+ return FIXED;
// We don't consider floppy disks as removable, so check for that.
string16 device = mount_point;
@@ -33,8 +39,8 @@ bool IsRemovable(const string16& mount_point) {
string16 device_path;
if (!QueryDosDevice(device.c_str(), WriteInto(&device_path, kMaxPathBufLen),
kMaxPathBufLen))
- return true;
- return device_path.find(L"Floppy") == string16::npos;
+ return REMOVABLE;
+ return device_path.find(L"Floppy") == string16::npos ? REMOVABLE : FLOPPY;
}
// Returns 0 if the devicetype is not volume.
@@ -81,12 +87,18 @@ bool GetDeviceDetails(const base::FilePath& device_path,
return false;
}
+ DeviceType device_type = GetDeviceType(mount_point);
if (removable)
- *removable = IsRemovable(mount_point);
+ *removable = (device_type == REMOVABLE);
if (device_location)
*device_location = mount_point;
+ // If we're adding a floppy drive, return without querying any more
+ // drive metadata -- it will cause the floppy drive to seek.
+ if (device_type == FLOPPY)
+ return true;
+
if (volume_size)
*volume_size = GetVolumeSize(mount_point);
@@ -140,10 +152,7 @@ std::vector<base::FilePath> GetAttachedDevices() {
if (GetVolumePathNamesForVolumeName(volume_name.c_str(),
WriteInto(&volume_path, kMaxPathBufLen),
kMaxPathBufLen, &return_count)) {
- if (IsRemovable(volume_path))
- result.push_back(base::FilePath(volume_path));
- } else {
- DPLOG(ERROR);
+ result.push_back(base::FilePath(volume_path));
}
if (!FindNextVolume(find_handle, WriteInto(&volume_name, kMaxPathBufLen),
kMaxPathBufLen)) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698