| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/storage_monitor/test_volume_mount_watcher_win.h" | 7 #include "chrome/browser/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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if (path.value() != ASCIIToUTF16("N:\\") && | 70 if (path.value() != ASCIIToUTF16("N:\\") && |
| 71 path.value() != ASCIIToUTF16("C:\\") && | 71 path.value() != ASCIIToUTF16("C:\\") && |
| 72 path.value() != GetTempRoot().value()) { | 72 path.value() != GetTempRoot().value()) { |
| 73 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM; | 73 type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM; |
| 74 } | 74 } |
| 75 std::string unique_id = | 75 std::string unique_id = |
| 76 "\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\"; | 76 "\\\\?\\Volume{00000000-0000-0000-0000-000000000000}\\"; |
| 77 unique_id[11] = device_path.value()[0]; | 77 unique_id[11] = device_path.value()[0]; |
| 78 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id); | 78 std::string device_id = StorageInfo::MakeDeviceId(type, unique_id); |
| 79 base::string16 storage_label = path.Append(L" Drive").LossyDisplayName(); | 79 base::string16 storage_label = path.Append(L" Drive").LossyDisplayName(); |
| 80 *info = StorageInfo(device_id, base::string16(), path.value(), storage_label, | 80 *info = StorageInfo(device_id, path.value(), storage_label, |
| 81 base::string16(), base::string16(), 1000000); | 81 base::string16(), base::string16(), 1000000); |
| 82 | 82 |
| 83 return true; | 83 return true; |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace | 86 } // namespace |
| 87 | 87 |
| 88 // TestVolumeMountWatcherWin --------------------------------------------------- | 88 // TestVolumeMountWatcherWin --------------------------------------------------- |
| 89 | 89 |
| 90 TestVolumeMountWatcherWin::TestVolumeMountWatcherWin() | 90 TestVolumeMountWatcherWin::TestVolumeMountWatcherWin() |
| 91 : attached_devices_fake_(false) {} | 91 : attached_devices_fake_(false) {} |
| 92 | 92 |
| 93 TestVolumeMountWatcherWin::~TestVolumeMountWatcherWin() { | 93 TestVolumeMountWatcherWin::~TestVolumeMountWatcherWin() { |
| 94 } | 94 } |
| 95 | 95 |
| 96 void TestVolumeMountWatcherWin::AddDeviceForTesting( | 96 void TestVolumeMountWatcherWin::AddDeviceForTesting( |
| 97 const base::FilePath& device_path, | 97 const base::FilePath& device_path, |
| 98 const std::string& device_id, | 98 const std::string& device_id, |
| 99 const base::string16& device_name, | 99 const base::string16& device_name, |
| 100 uint64 total_size_in_bytes) { | 100 uint64 total_size_in_bytes) { |
| 101 StorageInfo info(device_id, device_name, device_path.value(), | 101 StorageInfo info(device_id, device_path.value(), device_name, |
| 102 base::string16(), base::string16(), base::string16(), | 102 base::string16(), base::string16(), total_size_in_bytes); |
| 103 total_size_in_bytes); | |
| 104 HandleDeviceAttachEventOnUIThread(device_path, info); | 103 HandleDeviceAttachEventOnUIThread(device_path, info); |
| 105 } | 104 } |
| 106 | 105 |
| 107 void TestVolumeMountWatcherWin::SetAttachedDevicesFake() { | 106 void TestVolumeMountWatcherWin::SetAttachedDevicesFake() { |
| 108 attached_devices_fake_ = true; | 107 attached_devices_fake_ = true; |
| 109 } | 108 } |
| 110 | 109 |
| 111 void TestVolumeMountWatcherWin::FlushWorkerPoolForTesting() { | 110 void TestVolumeMountWatcherWin::FlushWorkerPoolForTesting() { |
| 112 device_info_worker_pool_->FlushForTesting(); | 111 device_info_worker_pool_->FlushForTesting(); |
| 113 } | 112 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return base::Bind(&FakeGetAttachedDevices); | 149 return base::Bind(&FakeGetAttachedDevices); |
| 151 return base::Bind(&FakeGetSingleAttachedDevice); | 150 return base::Bind(&FakeGetSingleAttachedDevice); |
| 152 } | 151 } |
| 153 | 152 |
| 154 void TestVolumeMountWatcherWin::ShutdownWorkerPool() { | 153 void TestVolumeMountWatcherWin::ShutdownWorkerPool() { |
| 155 device_info_worker_pool_->Shutdown(); | 154 device_info_worker_pool_->Shutdown(); |
| 156 } | 155 } |
| 157 | 156 |
| 158 } // namespace test | 157 } // namespace test |
| 159 } // namespace chrome | 158 } // namespace chrome |
| OLD | NEW |