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 "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 // This file unconditionally includes these headers despite conditionally | 9 // This file unconditionally includes these headers despite conditionally |
10 // depending on the corresponding targets. The code below needs the destructors | 10 // depending on the corresponding targets. The code below needs the destructors |
11 // of the classes defined even when the classes are never instantiated. | 11 // of the classes defined even when the classes are never instantiated. |
12 // TODO: This should probably be done more explicitly to avoid ambiguity. | 12 // TODO: This should probably be done more explicitly to avoid ambiguity. |
13 #include "device/hid/hid_service.h" // nogncheck | 13 #include "device/hid/hid_service.h" // nogncheck |
14 #include "device/usb/usb_service.h" // nogncheck | 14 #include "device/usb/usb_service.h" // nogncheck |
15 | 15 |
16 namespace device { | 16 namespace device { |
17 | 17 |
18 TestDeviceClient::TestDeviceClient( | 18 TestDeviceClient::TestDeviceClient( |
19 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner) | 19 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner) |
20 : blocking_task_runner_(blocking_task_runner) {} | 20 : blocking_task_runner_(blocking_task_runner) {} |
21 | 21 |
22 TestDeviceClient::~TestDeviceClient() {} | 22 TestDeviceClient::~TestDeviceClient() { |
| 23 if (hid_service_) |
| 24 hid_service_->Shutdown(); |
| 25 if (usb_service_) |
| 26 usb_service_->Shutdown(); |
| 27 } |
23 | 28 |
24 HidService* TestDeviceClient::GetHidService() { | 29 HidService* TestDeviceClient::GetHidService() { |
25 #if !defined(OS_ANDROID) && !defined(OS_IOS) && \ | 30 #if !defined(OS_ANDROID) && !defined(OS_IOS) && \ |
26 !(defined(OS_LINUX) && !defined(USE_UDEV)) | 31 !(defined(OS_LINUX) && !defined(USE_UDEV)) |
27 if (!hid_service_) { | 32 if (!hid_service_) { |
28 hid_service_ = HidService::Create(blocking_task_runner_); | 33 hid_service_ = HidService::Create(blocking_task_runner_); |
29 } | 34 } |
30 #endif | 35 #endif |
31 return hid_service_.get(); | 36 return hid_service_.get(); |
32 } | 37 } |
33 | 38 |
34 UsbService* TestDeviceClient::GetUsbService() { | 39 UsbService* TestDeviceClient::GetUsbService() { |
35 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 40 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
36 if (!usb_service_) { | 41 if (!usb_service_) { |
37 usb_service_ = UsbService::Create(blocking_task_runner_); | 42 usb_service_ = UsbService::Create(blocking_task_runner_); |
38 } | 43 } |
39 #endif | 44 #endif |
40 return usb_service_.get(); | 45 return usb_service_.get(); |
41 } | 46 } |
42 | 47 |
43 } // namespace device | 48 } // namespace device |
OLD | NEW |