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/test/test_device_client.h" | 5 #include "device/test/test_device_client.h" |
6 | 6 |
7 #include "device/hid/hid_service.h" | 7 #include "device/hid/hid_service.h" |
8 #include "device/usb/usb_service.h" | 8 #include "device/usb/usb_service.h" |
9 | 9 |
10 namespace device { | 10 namespace device { |
11 | 11 |
12 TestDeviceClient::TestDeviceClient( | 12 TestDeviceClient::TestDeviceClient( |
13 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner) | 13 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner) |
14 : blocking_task_runner_(blocking_task_runner) {} | 14 : blocking_task_runner_(blocking_task_runner) {} |
15 | 15 |
16 TestDeviceClient::~TestDeviceClient() {} | 16 TestDeviceClient::~TestDeviceClient() {} |
17 | 17 |
18 HidService* TestDeviceClient::GetHidService() { | 18 HidService* TestDeviceClient::GetHidService() { |
19 #if !defined(OS_LINUX) || defined(USE_UDEV) | 19 #if !defined(OS_ANDROID) && !defined(OS_IOS) && \ |
20 return HidService::GetInstance(blocking_task_runner_); | 20 !(defined(OS_LINUX) && !defined(USE_UDEV)) |
21 #else | 21 if (!hid_service_) { |
22 return nullptr; | 22 hid_service_ = HidService::Create(blocking_task_runner_); |
| 23 } |
23 #endif | 24 #endif |
| 25 return hid_service_.get(); |
24 } | 26 } |
25 | 27 |
26 UsbService* TestDeviceClient::GetUsbService() { | 28 UsbService* TestDeviceClient::GetUsbService() { |
27 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 29 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
28 if (!usb_service_) { | 30 if (!usb_service_) { |
29 usb_service_ = UsbService::Create(blocking_task_runner_); | 31 usb_service_ = UsbService::Create(blocking_task_runner_); |
30 } | 32 } |
31 #endif | 33 #endif |
32 return usb_service_.get(); | 34 return usb_service_.get(); |
33 } | 35 } |
34 | 36 |
35 } // namespace device | 37 } // namespace device |
OLD | NEW |