| 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 // TestVolumeMountWatcherWin implementation. | 5 // TestVolumeMountWatcherWin implementation. |
| 6 | 6 |
| 7 #include "components/storage_monitor/test_volume_mount_watcher_win.h" | 7 #include "components/storage_monitor/test_volume_mount_watcher_win.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // |device_path| inputs of 'A:\' - 'Z:\' are valid. 'N:\' is not removable. | 55 // |device_path| inputs of 'A:\' - 'Z:\' are valid. 'N:\' is not removable. |
| 56 // 'C:\' is not removable (so that auto-added paths are correctly handled). | 56 // 'C:\' is not removable (so that auto-added paths are correctly handled). |
| 57 bool GetMassStorageDeviceDetails(const base::FilePath& device_path, | 57 bool GetMassStorageDeviceDetails(const base::FilePath& device_path, |
| 58 StorageInfo* info) { | 58 StorageInfo* info) { |
| 59 DCHECK(info); | 59 DCHECK(info); |
| 60 | 60 |
| 61 // Truncate to root path. | 61 // Truncate to root path. |
| 62 base::FilePath path(device_path); | 62 base::FilePath path(device_path); |
| 63 if (device_path.value().length() > 3) | 63 if (device_path.value().length() > 3) |
| 64 path = base::FilePath(device_path.value().substr(0, 3)); | 64 path = base::FilePath(device_path.value().substr(0, 3)); |
| 65 if (path.value()[0] < L'A' || path.value()[0] > L'Z') | 65 base::FilePath::CharType drive_letter = path.value()[0]; |
| 66 if (drive_letter < L'A' || drive_letter > L'Z') |
| 66 return false; | 67 return false; |
| 67 | 68 |
| 68 StorageInfo::Type type = StorageInfo::FIXED_MASS_STORAGE; | 69 StorageInfo::Type type = StorageInfo::FIXED_MASS_STORAGE; |
| 69 if (path.value() != base::ASCIIToUTF16("N:\\") && | 70 if (path.value() != base::ASCIIToUTF16("N:\\") && |
| 70 path.value() != base::ASCIIToUTF16("C:\\") && | 71 path.value() != base::ASCIIToUTF16("C:\\") && |
| 71 path.value() != GetTempRoot().value()) { | 72 path.value() != GetTempRoot().value()) { |
| 72 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM; | 73 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM; |
| 73 } | 74 } |
| 74 std::string unique_id = | 75 std::string unique_id = |
| 75 "\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\"; | 76 "\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\"; |
| 76 unique_id[11] = device_path.value()[0]; | 77 unique_id[11] = static_cast<char>(drive_letter); |
| 77 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id); | 78 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id); |
| 78 base::string16 storage_label = path.Append(L" Drive").LossyDisplayName(); | 79 base::string16 storage_label = path.Append(L" Drive").LossyDisplayName(); |
| 79 *info = StorageInfo(device_id, path.value(), storage_label, base::string16(), | 80 *info = StorageInfo(device_id, path.value(), storage_label, base::string16(), |
| 80 base::string16(), 1000000); | 81 base::string16(), 1000000); |
| 81 | 82 |
| 82 return true; | 83 return true; |
| 83 } | 84 } |
| 84 | 85 |
| 85 } // namespace | 86 } // namespace |
| 86 | 87 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (attached_devices_fake_) | 148 if (attached_devices_fake_) |
| 148 return base::Bind(&FakeGetAttachedDevices); | 149 return base::Bind(&FakeGetAttachedDevices); |
| 149 return base::Bind(&FakeGetSingleAttachedDevice); | 150 return base::Bind(&FakeGetSingleAttachedDevice); |
| 150 } | 151 } |
| 151 | 152 |
| 152 void TestVolumeMountWatcherWin::ShutdownWorkerPool() { | 153 void TestVolumeMountWatcherWin::ShutdownWorkerPool() { |
| 153 device_info_worker_pool_->Shutdown(); | 154 device_info_worker_pool_->Shutdown(); |
| 154 } | 155 } |
| 155 | 156 |
| 156 } // namespace storage_monitor | 157 } // namespace storage_monitor |
| OLD | NEW |