Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / usb / usb_interface.h
blobe73b044ca0df776f68b911f57e619450d9cb309a
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,
23 USB_TRANSFER_BULK,
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,
39 enum UsbUsageType {
40 USB_USAGE_DATA = 0,
41 USB_USAGE_FEEDBACK,
42 USB_USAGE_EXPLICIT_FEEDBACK
45 class UsbDevice;
46 class UsbConfigDescriptor;
47 class UsbInterfaceDescriptor;
48 class UsbInterfaceAltSettingDescriptor;
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;
61 private:
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> {
78 public:
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;
88 private:
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> {
105 public:
106 size_t GetNumAltSettings() const;
107 scoped_refptr<const UsbInterfaceAltSettingDescriptor> GetAltSetting(
108 size_t index) const;
110 private:
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> {
125 public:
126 size_t GetNumInterfaces() const;
127 scoped_refptr<const UsbInterfaceDescriptor> GetInterface(size_t index) const;
129 private:
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_