OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/storage_monitor/volume_mount_watcher_win.h" | 5 #include "components/storage_monitor/volume_mount_watcher_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include <dbt.h> | 9 #include <dbt.h> |
10 #include <fileapi.h> | 10 #include <fileapi.h> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (drive_type == DRIVE_FIXED || drive_type == DRIVE_REMOTE || | 63 if (drive_type == DRIVE_FIXED || drive_type == DRIVE_REMOTE || |
64 drive_type == DRIVE_RAMDISK) { | 64 drive_type == DRIVE_RAMDISK) { |
65 return FIXED; | 65 return FIXED; |
66 } | 66 } |
67 if (drive_type != DRIVE_REMOVABLE) | 67 if (drive_type != DRIVE_REMOVABLE) |
68 return FLOPPY; | 68 return FLOPPY; |
69 | 69 |
70 // Check device strings of the form "X:" and "\\.\X:" | 70 // Check device strings of the form "X:" and "\\.\X:" |
71 // For floppy drives, these will return strings like "/Device/Floppy0" | 71 // For floppy drives, these will return strings like "/Device/Floppy0" |
72 base::string16 device = mount_point; | 72 base::string16 device = mount_point; |
73 if (EndsWith(mount_point, L"\\", false)) | 73 if (base::EndsWith(mount_point, L"\\", false)) |
74 device = mount_point.substr(0, mount_point.length() - 1); | 74 device = mount_point.substr(0, mount_point.length() - 1); |
75 base::string16 device_path; | 75 base::string16 device_path; |
76 base::string16 device_path_slash; | 76 base::string16 device_path_slash; |
77 DWORD dos_device = QueryDosDevice( | 77 DWORD dos_device = QueryDosDevice( |
78 device.c_str(), WriteInto(&device_path, kMaxPathBufLen), kMaxPathBufLen); | 78 device.c_str(), WriteInto(&device_path, kMaxPathBufLen), kMaxPathBufLen); |
79 base::string16 device_slash = base::string16(L"\\\\.\\"); | 79 base::string16 device_slash = base::string16(L"\\\\.\\"); |
80 device_slash += device; | 80 device_slash += device; |
81 DWORD dos_device_slash = QueryDosDevice( | 81 DWORD dos_device_slash = QueryDosDevice( |
82 device_slash.c_str(), WriteInto(&device_path_slash, kMaxPathBufLen), | 82 device_slash.c_str(), WriteInto(&device_path_slash, kMaxPathBufLen), |
83 kMaxPathBufLen); | 83 kMaxPathBufLen); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 callback.Run(StorageMonitor::EJECT_FAILURE); | 542 callback.Run(StorageMonitor::EJECT_FAILURE); |
543 return; | 543 return; |
544 } | 544 } |
545 | 545 |
546 device_info_task_runner_->PostTask( | 546 device_info_task_runner_->PostTask( |
547 FROM_HERE, base::Bind(&EjectDeviceInThreadPool, device, callback, | 547 FROM_HERE, base::Bind(&EjectDeviceInThreadPool, device, callback, |
548 device_info_task_runner_, 0)); | 548 device_info_task_runner_, 0)); |
549 } | 549 } |
550 | 550 |
551 } // namespace storage_monitor | 551 } // namespace storage_monitor |
OLD | NEW |