OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef DEVICE_USB_USB_INTERFACE_IMPL_H_ |
| 6 #define DEVICE_USB_USB_INTERFACE_IMPL_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "device/usb/usb_interface.h" |
| 10 |
| 11 struct libusb_config_descriptor; |
| 12 struct libusb_endpoint_descriptor; |
| 13 struct libusb_interface; |
| 14 struct libusb_interface_descriptor; |
| 15 |
| 16 namespace device { |
| 17 |
| 18 typedef libusb_config_descriptor* PlatformUsbConfigDescriptor; |
| 19 typedef const libusb_endpoint_descriptor* PlatformUsbEndpointDescriptor; |
| 20 typedef const libusb_interface* PlatformUsbInterface; |
| 21 typedef const libusb_interface_descriptor* PlatformUsbInterfaceDescriptor; |
| 22 |
| 23 class UsbConfigDescriptorImpl; |
| 24 class UsbInterfaceAltSettingDescriptor; |
| 25 |
| 26 class UsbEndpointDescriptorImpl : public UsbEndpointDescriptor { |
| 27 public: |
| 28 virtual int GetAddress() const OVERRIDE; |
| 29 virtual UsbEndpointDirection GetDirection() const OVERRIDE; |
| 30 virtual int GetMaximumPacketSize() const OVERRIDE; |
| 31 virtual UsbSynchronizationType GetSynchronizationType() const OVERRIDE; |
| 32 virtual UsbTransferType GetTransferType() const OVERRIDE; |
| 33 virtual UsbUsageType GetUsageType() const OVERRIDE; |
| 34 virtual int GetPollingInterval() const OVERRIDE; |
| 35 |
| 36 private: |
| 37 friend class base::RefCounted<const UsbEndpointDescriptorImpl>; |
| 38 friend class UsbInterfaceAltSettingDescriptorImpl; |
| 39 |
| 40 UsbEndpointDescriptorImpl(scoped_refptr<const UsbConfigDescriptor> config, |
| 41 PlatformUsbEndpointDescriptor descriptor); |
| 42 virtual ~UsbEndpointDescriptorImpl(); |
| 43 |
| 44 scoped_refptr<const UsbConfigDescriptor> config_; |
| 45 PlatformUsbEndpointDescriptor descriptor_; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptorImpl); |
| 48 }; |
| 49 |
| 50 class UsbInterfaceAltSettingDescriptorImpl |
| 51 : public UsbInterfaceAltSettingDescriptor { |
| 52 public: |
| 53 virtual size_t GetNumEndpoints() const OVERRIDE; |
| 54 virtual scoped_refptr<const UsbEndpointDescriptor> GetEndpoint( |
| 55 size_t index) const OVERRIDE; |
| 56 |
| 57 virtual int GetInterfaceNumber() const OVERRIDE; |
| 58 virtual int GetAlternateSetting() const OVERRIDE; |
| 59 virtual int GetInterfaceClass() const OVERRIDE; |
| 60 virtual int GetInterfaceSubclass() const OVERRIDE; |
| 61 virtual int GetInterfaceProtocol() const OVERRIDE; |
| 62 |
| 63 private: |
| 64 friend class UsbInterfaceDescriptorImpl; |
| 65 |
| 66 UsbInterfaceAltSettingDescriptorImpl( |
| 67 scoped_refptr<const UsbConfigDescriptor> config, |
| 68 PlatformUsbInterfaceDescriptor descriptor); |
| 69 virtual ~UsbInterfaceAltSettingDescriptorImpl(); |
| 70 |
| 71 scoped_refptr<const UsbConfigDescriptor> config_; |
| 72 PlatformUsbInterfaceDescriptor descriptor_; |
| 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptorImpl); |
| 75 }; |
| 76 |
| 77 class UsbInterfaceDescriptorImpl : public UsbInterfaceDescriptor { |
| 78 public: |
| 79 virtual size_t GetNumAltSettings() const OVERRIDE; |
| 80 virtual scoped_refptr<const UsbInterfaceAltSettingDescriptor> GetAltSetting( |
| 81 size_t index) const OVERRIDE; |
| 82 |
| 83 private: |
| 84 friend class base::RefCounted<const UsbInterfaceDescriptorImpl>; |
| 85 friend class UsbConfigDescriptorImpl; |
| 86 |
| 87 UsbInterfaceDescriptorImpl(scoped_refptr<const UsbConfigDescriptor> config, |
| 88 PlatformUsbInterface usbInterface); |
| 89 virtual ~UsbInterfaceDescriptorImpl(); |
| 90 |
| 91 scoped_refptr<const UsbConfigDescriptor> config_; |
| 92 PlatformUsbInterface interface_; |
| 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptorImpl); |
| 95 }; |
| 96 |
| 97 class UsbConfigDescriptorImpl : public UsbConfigDescriptor { |
| 98 public: |
| 99 virtual size_t GetNumInterfaces() const OVERRIDE; |
| 100 virtual scoped_refptr<const UsbInterfaceDescriptor> GetInterface( |
| 101 size_t index) const OVERRIDE; |
| 102 |
| 103 private: |
| 104 friend class base::RefCounted<UsbConfigDescriptor>; |
| 105 friend class UsbDeviceImpl; |
| 106 |
| 107 explicit UsbConfigDescriptorImpl(PlatformUsbConfigDescriptor config); |
| 108 virtual ~UsbConfigDescriptorImpl(); |
| 109 |
| 110 PlatformUsbConfigDescriptor config_; |
| 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptorImpl); |
| 113 }; |
| 114 |
| 115 } // namespace device |
| 116 |
| 117 #endif // DEVICE_USB_USB_INTERFACE_IMPL_H_ |
OLD | NEW |