| 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_interface_impl.h" | 5 #include "device/usb/usb_interface_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "third_party/libusb/src/libusb/libusb.h" | 8 #include "third_party/libusb/src/libusb/libusb.h" |
| 9 | 9 |
| 10 namespace usb_service { | 10 namespace device { |
| 11 | 11 |
| 12 UsbEndpointDescriptorImpl::UsbEndpointDescriptorImpl( | 12 UsbEndpointDescriptorImpl::UsbEndpointDescriptorImpl( |
| 13 scoped_refptr<const UsbConfigDescriptor> config, | 13 scoped_refptr<const UsbConfigDescriptor> config, |
| 14 PlatformUsbEndpointDescriptor descriptor) | 14 PlatformUsbEndpointDescriptor descriptor) |
| 15 : config_(config), descriptor_(descriptor) { | 15 : config_(config), descriptor_(descriptor) { |
| 16 } | 16 } |
| 17 | 17 |
| 18 UsbEndpointDescriptorImpl::~UsbEndpointDescriptorImpl() { | 18 UsbEndpointDescriptorImpl::~UsbEndpointDescriptorImpl() { |
| 19 } | 19 } |
| 20 | 20 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 31 default: | 31 default: |
| 32 NOTREACHED(); | 32 NOTREACHED(); |
| 33 return USB_DIRECTION_INBOUND; | 33 return USB_DIRECTION_INBOUND; |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 int UsbEndpointDescriptorImpl::GetMaximumPacketSize() const { | 37 int UsbEndpointDescriptorImpl::GetMaximumPacketSize() const { |
| 38 return descriptor_->wMaxPacketSize; | 38 return descriptor_->wMaxPacketSize; |
| 39 } | 39 } |
| 40 | 40 |
| 41 UsbSynchronizationType | 41 UsbSynchronizationType UsbEndpointDescriptorImpl::GetSynchronizationType() |
| 42 UsbEndpointDescriptorImpl::GetSynchronizationType() const { | 42 const { |
| 43 switch (descriptor_->bmAttributes & LIBUSB_ISO_SYNC_TYPE_MASK) { | 43 switch (descriptor_->bmAttributes & LIBUSB_ISO_SYNC_TYPE_MASK) { |
| 44 case LIBUSB_ISO_SYNC_TYPE_NONE: | 44 case LIBUSB_ISO_SYNC_TYPE_NONE: |
| 45 return USB_SYNCHRONIZATION_NONE; | 45 return USB_SYNCHRONIZATION_NONE; |
| 46 case LIBUSB_ISO_SYNC_TYPE_ASYNC: | 46 case LIBUSB_ISO_SYNC_TYPE_ASYNC: |
| 47 return USB_SYNCHRONIZATION_ASYNCHRONOUS; | 47 return USB_SYNCHRONIZATION_ASYNCHRONOUS; |
| 48 case LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: | 48 case LIBUSB_ISO_SYNC_TYPE_ADAPTIVE: |
| 49 return USB_SYNCHRONIZATION_ADAPTIVE; | 49 return USB_SYNCHRONIZATION_ADAPTIVE; |
| 50 case LIBUSB_ISO_SYNC_TYPE_SYNC: | 50 case LIBUSB_ISO_SYNC_TYPE_SYNC: |
| 51 return USB_SYNCHRONIZATION_SYNCHRONOUS; | 51 return USB_SYNCHRONIZATION_SYNCHRONOUS; |
| 52 default: | 52 default: |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 UsbConfigDescriptorImpl::~UsbConfigDescriptorImpl() { | 155 UsbConfigDescriptorImpl::~UsbConfigDescriptorImpl() { |
| 156 libusb_free_config_descriptor(config_); | 156 libusb_free_config_descriptor(config_); |
| 157 } | 157 } |
| 158 | 158 |
| 159 size_t UsbConfigDescriptorImpl::GetNumInterfaces() const { | 159 size_t UsbConfigDescriptorImpl::GetNumInterfaces() const { |
| 160 return config_->bNumInterfaces; | 160 return config_->bNumInterfaces; |
| 161 } | 161 } |
| 162 | 162 |
| 163 scoped_refptr<const UsbInterfaceDescriptor> | 163 scoped_refptr<const UsbInterfaceDescriptor> |
| 164 UsbConfigDescriptorImpl::GetInterface(size_t index) const { | 164 UsbConfigDescriptorImpl::GetInterface(size_t index) const { |
| 165 return new UsbInterfaceDescriptorImpl(this, &config_->interface[index]); | 165 return new UsbInterfaceDescriptorImpl(this, &config_->interface[index]); |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace usb_service | 168 } // namespace device |
| OLD | NEW |