OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "device/usb/mock_usb_service.h" | 5 #include "device/usb/mock_usb_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "base/threading/thread_task_runner_handle.h" |
10 #include "device/usb/usb_device.h" | 11 #include "device/usb/usb_device.h" |
11 | 12 |
12 namespace device { | 13 namespace device { |
13 | 14 |
14 MockUsbService::MockUsbService() : UsbService(nullptr, nullptr) {} | 15 MockUsbService::MockUsbService() |
| 16 : UsbService(base::ThreadTaskRunnerHandle::IsSet() |
| 17 ? base::ThreadTaskRunnerHandle::Get() |
| 18 : nullptr, |
| 19 nullptr) {} |
15 | 20 |
16 MockUsbService::~MockUsbService() { | 21 MockUsbService::~MockUsbService() { |
17 // Shutdown() must be called before the base class destructor. | 22 // Shutdown() must be called before the base class destructor. |
18 Shutdown(); | 23 Shutdown(); |
19 } | 24 } |
20 | 25 |
21 void MockUsbService::AddDevice(scoped_refptr<UsbDevice> device) { | 26 void MockUsbService::AddDevice(scoped_refptr<UsbDevice> device) { |
22 devices()[device->guid()] = device; | 27 devices()[device->guid()] = device; |
23 NotifyDeviceAdded(device); | 28 NotifyDeviceAdded(device); |
24 } | 29 } |
25 | 30 |
26 void MockUsbService::RemoveDevice(scoped_refptr<UsbDevice> device) { | 31 void MockUsbService::RemoveDevice(scoped_refptr<UsbDevice> device) { |
27 devices().erase(device->guid()); | 32 devices().erase(device->guid()); |
28 UsbService::NotifyDeviceRemoved(device); | 33 UsbService::NotifyDeviceRemoved(device); |
29 } | 34 } |
30 | 35 |
31 } // namespace device | 36 } // namespace device |
OLD | NEW |