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.
5 #ifndef CHROME_BROWSER_USB_USB_INTERFACE_H_
6 #define CHROME_BROWSER_USB_USB_INTERFACE_H_
8 #include "base/memory/ref_counted.h"
10 struct libusb_config_descriptor
;
11 struct libusb_endpoint_descriptor
;
12 struct libusb_interface
;
13 struct libusb_interface_descriptor
;
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
;
20 enum UsbTransferType
{
21 USB_TRANSFER_CONTROL
= 0,
22 USB_TRANSFER_ISOCHRONOUS
,
24 USB_TRANSFER_INTERRUPT
,
27 enum UsbEndpointDirection
{
28 USB_DIRECTION_INBOUND
= 0,
29 USB_DIRECTION_OUTBOUND
,
32 enum UsbSynchronizationType
{
33 USB_SYNCHRONIZATION_NONE
= 0,
34 USB_SYNCHRONIZATION_ASYNCHRONOUS
,
35 USB_SYNCHRONIZATION_ADAPTIVE
,
36 USB_SYNCHRONIZATION_SYNCHRONOUS
,
42 USB_USAGE_EXPLICIT_FEEDBACK
46 class UsbConfigDescriptor
;
47 class UsbInterfaceDescriptor
;
48 class UsbInterfaceAltSettingDescriptor
;
50 class UsbEndpointDescriptor
51 : public base::RefCounted
<const UsbEndpointDescriptor
> {
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;
62 friend class base::RefCounted
<const UsbEndpointDescriptor
>;
63 friend class UsbInterfaceAltSettingDescriptor
;
65 UsbEndpointDescriptor(
66 scoped_refptr
<const UsbConfigDescriptor
> config
,
67 PlatformUsbEndpointDescriptor descriptor
);
68 ~UsbEndpointDescriptor();
70 scoped_refptr
<const UsbConfigDescriptor
> config_
;
71 PlatformUsbEndpointDescriptor descriptor_
;
73 DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptor
);
76 class UsbInterfaceAltSettingDescriptor
77 : public base::RefCounted
<const UsbInterfaceAltSettingDescriptor
> {
79 size_t GetNumEndpoints() const;
80 scoped_refptr
<const UsbEndpointDescriptor
> GetEndpoint(size_t index
) const;
82 int GetInterfaceNumber() const;
83 int GetAlternateSetting() const;
84 int GetInterfaceClass() const;
85 int GetInterfaceSubclass() const;
86 int GetInterfaceProtocol() const;
89 friend class base::RefCounted
<const UsbInterfaceAltSettingDescriptor
>;
90 friend class UsbInterfaceDescriptor
;
92 UsbInterfaceAltSettingDescriptor(
93 scoped_refptr
<const UsbConfigDescriptor
> config
,
94 PlatformUsbInterfaceDescriptor descriptor
);
95 ~UsbInterfaceAltSettingDescriptor();
97 scoped_refptr
<const UsbConfigDescriptor
> config_
;
98 PlatformUsbInterfaceDescriptor descriptor_
;
100 DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptor
);
103 class UsbInterfaceDescriptor
104 : public base::RefCounted
<const UsbInterfaceDescriptor
> {
106 size_t GetNumAltSettings() const;
107 scoped_refptr
<const UsbInterfaceAltSettingDescriptor
> GetAltSetting(
111 friend class base::RefCounted
<const UsbInterfaceDescriptor
>;
112 friend class UsbConfigDescriptor
;
114 UsbInterfaceDescriptor(scoped_refptr
<const UsbConfigDescriptor
> config
,
115 PlatformUsbInterface usbInterface
);
116 ~UsbInterfaceDescriptor();
118 scoped_refptr
<const UsbConfigDescriptor
> config_
;
119 PlatformUsbInterface interface_
;
121 DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptor
);
124 class UsbConfigDescriptor
: public base::RefCounted
<UsbConfigDescriptor
> {
126 size_t GetNumInterfaces() const;
127 scoped_refptr
<const UsbInterfaceDescriptor
> GetInterface(size_t index
) const;
130 friend class base::RefCounted
<UsbConfigDescriptor
>;
131 friend class UsbDevice
;
133 explicit UsbConfigDescriptor(PlatformUsbConfigDescriptor config
);
134 ~UsbConfigDescriptor();
136 PlatformUsbConfigDescriptor config_
;
138 DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptor
);
141 #endif // CHROME_BROWSER_USB_USB_INTERFACE_H_