Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: device/test/test_device_client.cc

Issue 1312993008: Manage HidService lifetime in DeviceClient implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_usb_service_get_instance
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/test/test_device_client.h ('k') | extensions/browser/api/hid/hid_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
OLDNEW
« no previous file with comments | « device/test/test_device_client.h ('k') | extensions/browser/api/hid/hid_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698