| 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 "device/usb/usb_device_impl.h" | 5 #include "device/usb/usb_device_impl.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 descriptor.idVendor, | 38 descriptor.idVendor, |
| 39 descriptor.idProduct, | 39 descriptor.idProduct, |
| 40 descriptor.bcdDevice, | 40 descriptor.bcdDevice, |
| 41 base::string16(), | 41 base::string16(), |
| 42 base::string16(), | 42 base::string16(), |
| 43 base::string16()), | 43 base::string16()), |
| 44 platform_device_(platform_device), | 44 platform_device_(platform_device), |
| 45 context_(context), | 45 context_(context), |
| 46 task_runner_(base::ThreadTaskRunnerHandle::Get()), | 46 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 47 blocking_task_runner_(blocking_task_runner) { | 47 blocking_task_runner_(blocking_task_runner) { |
| 48 CHECK(platform_device) << "platform_device cannot be NULL"; | 48 // platform_device cannot be NULL |
| 49 CHECK(platform_device); |
| 49 libusb_ref_device(platform_device); | 50 libusb_ref_device(platform_device); |
| 50 ReadAllConfigurations(); | 51 ReadAllConfigurations(); |
| 51 RefreshActiveConfiguration(); | 52 RefreshActiveConfiguration(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 UsbDeviceImpl::~UsbDeviceImpl() { | 55 UsbDeviceImpl::~UsbDeviceImpl() { |
| 55 // The destructor must be safe to call from any thread. | 56 // The destructor must be safe to call from any thread. |
| 56 libusb_unref_device(platform_device_); | 57 libusb_unref_device(platform_device_); |
| 57 } | 58 } |
| 58 | 59 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void UsbDeviceImpl::Opened(PlatformUsbDeviceHandle platform_handle, | 118 void UsbDeviceImpl::Opened(PlatformUsbDeviceHandle platform_handle, |
| 118 const OpenCallback& callback) { | 119 const OpenCallback& callback) { |
| 119 DCHECK(thread_checker_.CalledOnValidThread()); | 120 DCHECK(thread_checker_.CalledOnValidThread()); |
| 120 scoped_refptr<UsbDeviceHandle> device_handle = new UsbDeviceHandleImpl( | 121 scoped_refptr<UsbDeviceHandle> device_handle = new UsbDeviceHandleImpl( |
| 121 context_, this, platform_handle, blocking_task_runner_); | 122 context_, this, platform_handle, blocking_task_runner_); |
| 122 handles().push_back(device_handle.get()); | 123 handles().push_back(device_handle.get()); |
| 123 callback.Run(device_handle); | 124 callback.Run(device_handle); |
| 124 } | 125 } |
| 125 | 126 |
| 126 } // namespace device | 127 } // namespace device |
| OLD | NEW |