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 "components/usb_service/usb_device_impl.h" | 5 #include "components/usb_service/usb_device_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "components/usb_service/usb_context.h" | 10 #include "components/usb_service/usb_context.h" |
11 #include "components/usb_service/usb_device_handle.h" | 11 #include "components/usb_service/usb_device_handle.h" |
| 12 #include "components/usb_service/usb_interface_impl.h" |
12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
13 #include "third_party/libusb/src/libusb/libusb.h" | 14 #include "third_party/libusb/src/libusb/libusb.h" |
14 | 15 |
15 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
16 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
17 #include "chromeos/dbus/dbus_thread_manager.h" | 18 #include "chromeos/dbus/dbus_thread_manager.h" |
18 #include "chromeos/dbus/permission_broker_client.h" | 19 #include "chromeos/dbus/permission_broker_client.h" |
19 #endif // defined(OS_CHROMEOS) | 20 #endif // defined(OS_CHROMEOS) |
20 | 21 |
21 using content::BrowserThread; | 22 using content::BrowserThread; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return false; | 120 return false; |
120 } | 121 } |
121 | 122 |
122 scoped_refptr<UsbConfigDescriptor> UsbDeviceImpl::ListInterfaces() { | 123 scoped_refptr<UsbConfigDescriptor> UsbDeviceImpl::ListInterfaces() { |
123 DCHECK(thread_checker_.CalledOnValidThread()); | 124 DCHECK(thread_checker_.CalledOnValidThread()); |
124 | 125 |
125 PlatformUsbConfigDescriptor platform_config; | 126 PlatformUsbConfigDescriptor platform_config; |
126 const int list_result = | 127 const int list_result = |
127 libusb_get_active_config_descriptor(platform_device_, &platform_config); | 128 libusb_get_active_config_descriptor(platform_device_, &platform_config); |
128 if (list_result == 0) | 129 if (list_result == 0) |
129 return new UsbConfigDescriptor(platform_config); | 130 return new UsbConfigDescriptorImpl(platform_config); |
130 | 131 |
131 return NULL; | 132 return NULL; |
132 } | 133 } |
133 | 134 |
134 void UsbDeviceImpl::OnDisconnect() { | 135 void UsbDeviceImpl::OnDisconnect() { |
135 DCHECK(thread_checker_.CalledOnValidThread()); | 136 DCHECK(thread_checker_.CalledOnValidThread()); |
136 HandlesVector handles; | 137 HandlesVector handles; |
137 swap(handles, handles_); | 138 swap(handles, handles_); |
138 for (std::vector<scoped_refptr<UsbDeviceHandle> >::iterator it = | 139 for (std::vector<scoped_refptr<UsbDeviceHandle> >::iterator it = |
139 handles.begin(); | 140 handles.begin(); |
140 it != handles.end(); | 141 it != handles.end(); |
141 ++it) { | 142 ++it) { |
142 (*it)->InternalClose(); | 143 (*it)->InternalClose(); |
143 } | 144 } |
144 } | 145 } |
145 | 146 |
146 } // namespace usb_service | 147 } // namespace usb_service |
OLD | NEW |