| 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 (base::EndsWith(mount_point, L"\\", false)) | 73 if (base::EndsWith(mount_point, L"\\", base::CompareCase::INSENSITIVE_ASCII)) |
| 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(), base::WriteInto(&device_path, kMaxPathBufLen), | 78 device.c_str(), base::WriteInto(&device_path, kMaxPathBufLen), |
| 79 kMaxPathBufLen); | 79 kMaxPathBufLen); |
| 80 base::string16 device_slash = base::string16(L"\\\\.\\"); | 80 base::string16 device_slash = base::string16(L"\\\\.\\"); |
| 81 device_slash += device; | 81 device_slash += device; |
| 82 DWORD dos_device_slash = QueryDosDevice( | 82 DWORD dos_device_slash = QueryDosDevice( |
| 83 device_slash.c_str(), base::WriteInto(&device_path_slash, kMaxPathBufLen), | 83 device_slash.c_str(), base::WriteInto(&device_path_slash, kMaxPathBufLen), |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 callback.Run(StorageMonitor::EJECT_FAILURE); | 544 callback.Run(StorageMonitor::EJECT_FAILURE); |
| 545 return; | 545 return; |
| 546 } | 546 } |
| 547 | 547 |
| 548 device_info_task_runner_->PostTask( | 548 device_info_task_runner_->PostTask( |
| 549 FROM_HERE, base::Bind(&EjectDeviceInThreadPool, device, callback, | 549 FROM_HERE, base::Bind(&EjectDeviceInThreadPool, device, callback, |
| 550 device_info_task_runner_, 0)); | 550 device_info_task_runner_, 0)); |
| 551 } | 551 } |
| 552 | 552 |
| 553 } // namespace storage_monitor | 553 } // namespace storage_monitor |
| OLD | NEW |