| 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 "chrome/browser/chrome_device_client.h" | 5 #include "chrome/browser/chrome_device_client.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | |
| 8 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 9 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 10 #include "device/hid/hid_service.h" | 9 #include "device/hid/hid_service.h" |
| 11 #include "device/usb/usb_service.h" | 10 #include "device/usb/usb_service.h" |
| 12 | 11 |
| 13 using content::BrowserThread; | 12 using content::BrowserThread; |
| 14 | 13 |
| 15 ChromeDeviceClient::ChromeDeviceClient() {} | 14 ChromeDeviceClient::ChromeDeviceClient() {} |
| 16 | 15 |
| 17 ChromeDeviceClient::~ChromeDeviceClient() {} | 16 ChromeDeviceClient::~ChromeDeviceClient() { |
| 17 #if DCHECK_IS_ON() |
| 18 DCHECK(did_shutdown_); |
| 19 #endif |
| 20 } |
| 21 |
| 22 void ChromeDeviceClient::Shutdown() { |
| 23 if (usb_service_) |
| 24 usb_service_->Shutdown(); |
| 25 if (hid_service_) |
| 26 hid_service_->Shutdown(); |
| 27 #if DCHECK_IS_ON() |
| 28 did_shutdown_ = true; |
| 29 #endif |
| 30 } |
| 18 | 31 |
| 19 device::UsbService* ChromeDeviceClient::GetUsbService() { | 32 device::UsbService* ChromeDeviceClient::GetUsbService() { |
| 20 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 33 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 21 if (!usb_service_) { | 34 if (!usb_service_) { |
| 22 usb_service_ = device::UsbService::Create( | 35 usb_service_ = device::UsbService::Create( |
| 23 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); | 36 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); |
| 24 } | 37 } |
| 25 return usb_service_.get(); | 38 return usb_service_.get(); |
| 26 } | 39 } |
| 27 | 40 |
| 28 device::HidService* ChromeDeviceClient::GetHidService() { | 41 device::HidService* ChromeDeviceClient::GetHidService() { |
| 29 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 42 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 30 #if !defined(OS_ANDROID) | 43 #if !defined(OS_ANDROID) |
| 31 if (!hid_service_) { | 44 if (!hid_service_) { |
| 32 hid_service_ = device::HidService::Create( | 45 hid_service_ = device::HidService::Create( |
| 33 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); | 46 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); |
| 34 } | 47 } |
| 35 #endif | 48 #endif |
| 36 return hid_service_.get(); | 49 return hid_service_.get(); |
| 37 } | 50 } |
| OLD | NEW |