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" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "components/storage_monitor/storage_info.h" | 13 #include "components/storage_monitor/storage_info.h" |
| 14 #include "content/public/browser/browser_thread.h" |
14 | 15 |
15 namespace storage_monitor { | 16 namespace storage_monitor { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 base::FilePath GetTempRoot() { | 20 base::FilePath GetTempRoot() { |
20 base::ScopedTempDir temp_dir; | 21 base::ScopedTempDir temp_dir; |
21 temp_dir.CreateUniqueTempDir(); | 22 temp_dir.CreateUniqueTempDir(); |
22 base::FilePath temp_root = temp_dir.path(); | 23 base::FilePath temp_root = temp_dir.path(); |
23 while (temp_root.DirName() != temp_root) | 24 while (temp_root.DirName() != temp_root) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 StorageInfo info(device_id, device_path.value(), storage_label, | 102 StorageInfo info(device_id, device_path.value(), storage_label, |
102 base::string16(), base::string16(), total_size_in_bytes); | 103 base::string16(), base::string16(), total_size_in_bytes); |
103 HandleDeviceAttachEventOnUIThread(device_path, info); | 104 HandleDeviceAttachEventOnUIThread(device_path, info); |
104 } | 105 } |
105 | 106 |
106 void TestVolumeMountWatcherWin::SetAttachedDevicesFake() { | 107 void TestVolumeMountWatcherWin::SetAttachedDevicesFake() { |
107 attached_devices_fake_ = true; | 108 attached_devices_fake_ = true; |
108 } | 109 } |
109 | 110 |
110 void TestVolumeMountWatcherWin::FlushWorkerPoolForTesting() { | 111 void TestVolumeMountWatcherWin::FlushWorkerPoolForTesting() { |
111 device_info_worker_pool_->FlushForTesting(); | 112 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
112 } | 113 } |
113 | 114 |
114 void TestVolumeMountWatcherWin::DeviceCheckComplete( | 115 void TestVolumeMountWatcherWin::DeviceCheckComplete( |
115 const base::FilePath& device_path) { | 116 const base::FilePath& device_path) { |
116 devices_checked_.push_back(device_path); | 117 devices_checked_.push_back(device_path); |
117 if (device_check_complete_event_.get()) | 118 if (device_check_complete_event_.get()) |
118 device_check_complete_event_->Wait(); | 119 device_check_complete_event_->Wait(); |
119 VolumeMountWatcherWin::DeviceCheckComplete(device_path); | 120 VolumeMountWatcherWin::DeviceCheckComplete(device_path); |
120 } | 121 } |
121 | 122 |
(...skipping 21 matching lines...) Expand all Loading... |
143 return base::Bind(&GetMassStorageDeviceDetails); | 144 return base::Bind(&GetMassStorageDeviceDetails); |
144 } | 145 } |
145 | 146 |
146 VolumeMountWatcherWin::GetAttachedDevicesCallbackType | 147 VolumeMountWatcherWin::GetAttachedDevicesCallbackType |
147 TestVolumeMountWatcherWin::GetAttachedDevicesCallback() const { | 148 TestVolumeMountWatcherWin::GetAttachedDevicesCallback() const { |
148 if (attached_devices_fake_) | 149 if (attached_devices_fake_) |
149 return base::Bind(&FakeGetAttachedDevices); | 150 return base::Bind(&FakeGetAttachedDevices); |
150 return base::Bind(&FakeGetSingleAttachedDevice); | 151 return base::Bind(&FakeGetSingleAttachedDevice); |
151 } | 152 } |
152 | 153 |
153 void TestVolumeMountWatcherWin::ShutdownWorkerPool() { | |
154 device_info_worker_pool_->Shutdown(); | |
155 } | |
156 | |
157 } // namespace storage_monitor | 154 } // namespace storage_monitor |
OLD | NEW |