| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 CHROME_BROWSER_USB_USB_INTERFACE_H_ | |
| 6 #define CHROME_BROWSER_USB_USB_INTERFACE_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 | |
| 10 struct libusb_config_descriptor; | |
| 11 struct libusb_endpoint_descriptor; | |
| 12 struct libusb_interface; | |
| 13 struct libusb_interface_descriptor; | |
| 14 | |
| 15 typedef libusb_config_descriptor* PlatformUsbConfigDescriptor; | |
| 16 typedef const libusb_endpoint_descriptor* PlatformUsbEndpointDescriptor; | |
| 17 typedef const libusb_interface* PlatformUsbInterface; | |
| 18 typedef const libusb_interface_descriptor* PlatformUsbInterfaceDescriptor; | |
| 19 | |
| 20 enum UsbTransferType { | |
| 21 USB_TRANSFER_CONTROL = 0, | |
| 22 USB_TRANSFER_ISOCHRONOUS, | |
| 23 USB_TRANSFER_BULK, | |
| 24 USB_TRANSFER_INTERRUPT, | |
| 25 }; | |
| 26 | |
| 27 enum UsbEndpointDirection { | |
| 28 USB_DIRECTION_INBOUND = 0, | |
| 29 USB_DIRECTION_OUTBOUND, | |
| 30 }; | |
| 31 | |
| 32 enum UsbSynchronizationType { | |
| 33 USB_SYNCHRONIZATION_NONE = 0, | |
| 34 USB_SYNCHRONIZATION_ASYNCHRONOUS, | |
| 35 USB_SYNCHRONIZATION_ADAPTIVE, | |
| 36 USB_SYNCHRONIZATION_SYNCHRONOUS, | |
| 37 }; | |
| 38 | |
| 39 enum UsbUsageType { | |
| 40 USB_USAGE_DATA = 0, | |
| 41 USB_USAGE_FEEDBACK, | |
| 42 USB_USAGE_EXPLICIT_FEEDBACK | |
| 43 }; | |
| 44 | |
| 45 class UsbDevice; | |
| 46 class UsbConfigDescriptor; | |
| 47 class UsbInterfaceDescriptor; | |
| 48 class UsbInterfaceAltSettingDescriptor; | |
| 49 | |
| 50 class UsbEndpointDescriptor | |
| 51 : public base::RefCounted<const UsbEndpointDescriptor> { | |
| 52 public: | |
| 53 int GetAddress() const; | |
| 54 UsbEndpointDirection GetDirection() const; | |
| 55 int GetMaximumPacketSize() const; | |
| 56 UsbSynchronizationType GetSynchronizationType() const; | |
| 57 UsbTransferType GetTransferType() const; | |
| 58 UsbUsageType GetUsageType() const; | |
| 59 int GetPollingInterval() const; | |
| 60 | |
| 61 private: | |
| 62 friend class base::RefCounted<const UsbEndpointDescriptor>; | |
| 63 friend class UsbInterfaceAltSettingDescriptor; | |
| 64 | |
| 65 UsbEndpointDescriptor( | |
| 66 scoped_refptr<const UsbConfigDescriptor> config, | |
| 67 PlatformUsbEndpointDescriptor descriptor); | |
| 68 ~UsbEndpointDescriptor(); | |
| 69 | |
| 70 scoped_refptr<const UsbConfigDescriptor> config_; | |
| 71 PlatformUsbEndpointDescriptor descriptor_; | |
| 72 | |
| 73 DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptor); | |
| 74 }; | |
| 75 | |
| 76 class UsbInterfaceAltSettingDescriptor | |
| 77 : public base::RefCounted<const UsbInterfaceAltSettingDescriptor> { | |
| 78 public: | |
| 79 size_t GetNumEndpoints() const; | |
| 80 scoped_refptr<const UsbEndpointDescriptor> GetEndpoint(size_t index) const; | |
| 81 | |
| 82 int GetInterfaceNumber() const; | |
| 83 int GetAlternateSetting() const; | |
| 84 int GetInterfaceClass() const; | |
| 85 int GetInterfaceSubclass() const; | |
| 86 int GetInterfaceProtocol() const; | |
| 87 | |
| 88 private: | |
| 89 friend class base::RefCounted<const UsbInterfaceAltSettingDescriptor>; | |
| 90 friend class UsbInterfaceDescriptor; | |
| 91 | |
| 92 UsbInterfaceAltSettingDescriptor( | |
| 93 scoped_refptr<const UsbConfigDescriptor> config, | |
| 94 PlatformUsbInterfaceDescriptor descriptor); | |
| 95 ~UsbInterfaceAltSettingDescriptor(); | |
| 96 | |
| 97 scoped_refptr<const UsbConfigDescriptor> config_; | |
| 98 PlatformUsbInterfaceDescriptor descriptor_; | |
| 99 | |
| 100 DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptor); | |
| 101 }; | |
| 102 | |
| 103 class UsbInterfaceDescriptor | |
| 104 : public base::RefCounted<const UsbInterfaceDescriptor> { | |
| 105 public: | |
| 106 size_t GetNumAltSettings() const; | |
| 107 scoped_refptr<const UsbInterfaceAltSettingDescriptor> GetAltSetting( | |
| 108 size_t index) const; | |
| 109 | |
| 110 private: | |
| 111 friend class base::RefCounted<const UsbInterfaceDescriptor>; | |
| 112 friend class UsbConfigDescriptor; | |
| 113 | |
| 114 UsbInterfaceDescriptor(scoped_refptr<const UsbConfigDescriptor> config, | |
| 115 PlatformUsbInterface usbInterface); | |
| 116 ~UsbInterfaceDescriptor(); | |
| 117 | |
| 118 scoped_refptr<const UsbConfigDescriptor> config_; | |
| 119 PlatformUsbInterface interface_; | |
| 120 | |
| 121 DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptor); | |
| 122 }; | |
| 123 | |
| 124 class UsbConfigDescriptor : public base::RefCounted<UsbConfigDescriptor> { | |
| 125 public: | |
| 126 size_t GetNumInterfaces() const; | |
| 127 scoped_refptr<const UsbInterfaceDescriptor> GetInterface(size_t index) const; | |
| 128 | |
| 129 private: | |
| 130 friend class base::RefCounted<UsbConfigDescriptor>; | |
| 131 friend class UsbDevice; | |
| 132 | |
| 133 explicit UsbConfigDescriptor(PlatformUsbConfigDescriptor config); | |
| 134 ~UsbConfigDescriptor(); | |
| 135 | |
| 136 PlatformUsbConfigDescriptor config_; | |
| 137 | |
| 138 DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptor); | |
| 139 }; | |
| 140 | |
| 141 #endif // CHROME_BROWSER_USB_USB_INTERFACE_H_ | |
| OLD | NEW |