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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // a) Enumerate attached devices | 353 // a) Enumerate attached devices |
354 // b) Create weak pointers for which to send completion signals from | 354 // b) Create weak pointers for which to send completion signals from |
355 // c) Retrieve metadata on the volumes and then | 355 // c) Retrieve metadata on the volumes and then |
356 // d) Notify that metadata to listeners. | 356 // d) Notify that metadata to listeners. |
357 void VolumeMountWatcherWin::Init() { | 357 void VolumeMountWatcherWin::Init() { |
358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 358 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
359 | 359 |
360 // When VolumeMountWatcherWin is created, the message pumps are not running | 360 // When VolumeMountWatcherWin is created, the message pumps are not running |
361 // so a posted task from the constructor would never run. Therefore, do all | 361 // so a posted task from the constructor would never run. Therefore, do all |
362 // the initializations here. | 362 // the initializations here. |
363 base::PostTaskAndReplyWithResult(task_runner_, FROM_HERE, | 363 base::PostTaskAndReplyWithResult( |
364 GetAttachedDevicesCallback(), | 364 task_runner_.get(), FROM_HERE, GetAttachedDevicesCallback(), |
365 base::Bind(&VolumeMountWatcherWin::AddDevicesOnUIThread, | 365 base::Bind(&VolumeMountWatcherWin::AddDevicesOnUIThread, |
366 weak_factory_.GetWeakPtr())); | 366 weak_factory_.GetWeakPtr())); |
367 } | 367 } |
368 | 368 |
369 void VolumeMountWatcherWin::AddDevicesOnUIThread( | 369 void VolumeMountWatcherWin::AddDevicesOnUIThread( |
370 std::vector<base::FilePath> removable_devices) { | 370 std::vector<base::FilePath> removable_devices) { |
371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 371 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
372 | 372 |
373 for (size_t i = 0; i < removable_devices.size(); i++) { | 373 for (size_t i = 0; i < removable_devices.size(); i++) { |
374 if (ContainsKey(pending_device_checks_, removable_devices[i])) | 374 if (ContainsKey(pending_device_checks_, removable_devices[i])) |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 callback.Run(StorageMonitor::EJECT_FAILURE); | 547 callback.Run(StorageMonitor::EJECT_FAILURE); |
548 return; | 548 return; |
549 } | 549 } |
550 | 550 |
551 task_runner_->PostTask( | 551 task_runner_->PostTask( |
552 FROM_HERE, | 552 FROM_HERE, |
553 base::Bind(&EjectDeviceInThreadPool, device, callback, task_runner_, 0)); | 553 base::Bind(&EjectDeviceInThreadPool, device, callback, task_runner_, 0)); |
554 } | 554 } |
555 | 555 |
556 } // namespace storage_monitor | 556 } // namespace storage_monitor |
OLD | NEW |