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

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: Created 7 years, 10 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 3c7a9d3930370249c99e3de344b7a5fef0265691..95130c9e56a13e4a35899dd5675df58710a4118d 100644
--- a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
+++ b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
@@ -22,21 +22,31 @@ namespace {
const DWORD kMaxPathBufLen = MAX_PATH + 1;
-bool IsRemovable(const string16& mount_point) {
- if (GetDriveType(mount_point.c_str()) != DRIVE_REMOVABLE)
- return false;
-
- // We don't consider floppy disks as removable, so check for that.
+string16 QueryDevicePath(const string16& mount_point) {
string16 device = mount_point;
if (EndsWith(mount_point, L"\\", false))
device = mount_point.substr(0, device.length() - 1);
string16 device_path;
if (!QueryDosDevice(device.c_str(), WriteInto(&device_path, kMaxPathBufLen),
kMaxPathBufLen))
- return true;
+ return string16();
+ return device_path;
+}
+
+bool IsRemovable(const string16& mount_point) {
vandebo (ex-Chrome) 2013/03/06 00:38:26 Instead of splitting this into two functions that
Greg Billock 2013/03/06 01:40:03 I like that plan.
+ if (GetDriveType(mount_point.c_str()) != DRIVE_REMOVABLE)
+ return false;
+
+ // We don't consider floppy disks as removable, so check for that.
+ string16 device_path = QueryDevicePath(mount_point);
return device_path.find(L"Floppy") == string16::npos;
}
+bool IsFloppyDrive(const string16& mount_point) {
+ string16 device_path = QueryDevicePath(mount_point);
+ return device_path.find(L"Floppy") != string16::npos;
+}
+
// Returns 0 if the devicetype is not volume.
uint32 GetVolumeBitMaskFromBroadcastHeader(LPARAM data) {
DEV_BROADCAST_VOLUME* dev_broadcast_volume =
@@ -87,6 +97,11 @@ bool GetDeviceDetails(const base::FilePath& device_path,
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 (IsFloppyDrive(device_path))
+ return true;
+
if (volume_size)
*volume_size = GetVolumeSize(mount_point);
« 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