Chromium Code Reviews| 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 #include "base/memory/scoped_ptr.h" | |
| 10 | |
| 11 struct libusb_config_descriptor; | |
| 12 struct libusb_endpoint_descriptor; | |
| 13 struct libusb_interface; | |
| 14 struct libusb_interface_descriptor; | |
| 15 | |
| 16 typedef libusb_config_descriptor* PlatformUsbConfigDescriptor; | |
| 17 typedef const libusb_endpoint_descriptor* PlatformUsbEndpointDescriptor; | |
| 18 typedef const libusb_interface* PlatformUsbInterface; | |
| 19 typedef const libusb_interface_descriptor* PlatformUsbInterfaceDescriptor; | |
| 20 | |
| 21 class UsbDevice; | |
| 22 | |
| 23 enum UsbEndpointType { | |
|
Bei Zhang
2013/04/26 22:38:01
Why not UsbTransferType? This is actually mapping
Kenny Root (Google)
2013/05/08 01:15:08
Done.
| |
| 24 USB_ENDPOINT_CONTROL = 0, | |
| 25 USB_ENDPOINT_INTERRUPT, | |
| 26 USB_ENDPOINT_ISOCHRONOUS, | |
| 27 USB_ENDPOINT_BULK | |
| 28 }; | |
| 29 | |
| 30 enum UsbInterfaceDirection { | |
|
Bei Zhang
2013/04/26 22:38:01
Fix the naming as mentioned elsewhere.
Kenny Root (Google)
2013/05/08 01:15:08
Done.
| |
| 31 USB_DIRECTION_INBOUND = 0, | |
| 32 USB_DIRECTION_OUTBOUND | |
| 33 }; | |
| 34 | |
| 35 enum UsbSynchronizationType { | |
| 36 USB_SYNCHRONIZATION_NONE = 0, | |
| 37 USB_SYNCHRONIZATION_ASYNCHRONOUS, | |
| 38 USB_SYNCHRONIZATION_ADAPTIVE, | |
| 39 USB_SYNCHRONIZATION_SYNCHRONOUS, | |
| 40 }; | |
| 41 | |
| 42 enum UsbUsageType { | |
| 43 USB_USAGE_DATA = 0, | |
| 44 USB_USAGE_FEEDBACK, | |
| 45 USB_USAGE_EXPLICIT_FEEDBACK | |
| 46 }; | |
| 47 | |
| 48 class UsbConfigDescriptor; | |
| 49 | |
| 50 class UsbEndpointDescriptor : public base::RefCounted<UsbEndpointDescriptor> { | |
| 51 public: | |
| 52 UsbEndpointDescriptor(scoped_refptr<const UsbConfigDescriptor> config, | |
| 53 PlatformUsbEndpointDescriptor descriptor); | |
| 54 virtual ~UsbEndpointDescriptor(); | |
|
Bei Zhang
2013/04/26 22:38:01
Classes that are ref-counted should have destructo
Kenny Root (Google)
2013/05/08 01:15:08
Done.
| |
| 55 | |
| 56 int GetAddress() const; | |
| 57 UsbInterfaceDirection GetDirection() const; | |
| 58 int GetMaximumPacketSize() const; | |
| 59 UsbEndpointType GetEndpointType() const; | |
| 60 UsbSynchronizationType GetSynchronizationType() const; | |
| 61 UsbUsageType GetUsageType() const; | |
| 62 int GetPollingInterval() const; | |
| 63 | |
| 64 private: | |
| 65 scoped_refptr<const UsbConfigDescriptor> config_; | |
| 66 PlatformUsbEndpointDescriptor descriptor_; | |
| 67 }; | |
| 68 | |
| 69 class UsbInterfaceDescriptor | |
| 70 : public base::RefCounted<UsbInterfaceDescriptor> { | |
| 71 public: | |
| 72 UsbInterfaceDescriptor(scoped_refptr<const UsbConfigDescriptor> config, | |
| 73 PlatformUsbInterfaceDescriptor descriptor); | |
| 74 virtual ~UsbInterfaceDescriptor(); | |
| 75 | |
| 76 size_t numEndpoints() const; | |
|
Bei Zhang
2013/04/26 22:38:01
GetNumEndpoints
Kenny Root (Google)
2013/05/08 01:15:08
Done.
| |
| 77 scoped_refptr<const UsbEndpointDescriptor> | |
| 78 getEndpoint(size_t index) const; | |
|
Bei Zhang
2013/04/26 22:38:01
Should be GetEndpointAt;
Fix all of them.
Kenny Root (Google)
2013/05/08 01:15:08
Done.
| |
| 79 | |
| 80 int GetInterfaceNumber() const; | |
| 81 int GetAlternateSetting() const; | |
| 82 int GetInterfaceClass() const; | |
| 83 int GetInterfaceSubclass() const; | |
| 84 int GetInterfaceProtocol() const; | |
| 85 | |
| 86 private: | |
| 87 scoped_refptr<const UsbConfigDescriptor> config_; | |
| 88 PlatformUsbInterfaceDescriptor descriptor_; | |
| 89 }; | |
| 90 | |
| 91 class UsbInterface : public base::RefCounted<UsbInterface> { | |
| 92 public: | |
| 93 UsbInterface(scoped_refptr<const UsbConfigDescriptor> config, | |
| 94 PlatformUsbInterface usbInterface); | |
| 95 virtual ~UsbInterface(); | |
| 96 | |
| 97 size_t numAltSettings() const; | |
| 98 scoped_refptr<const UsbInterfaceDescriptor> | |
| 99 getAltSetting(size_t index) const; | |
| 100 | |
| 101 private: | |
| 102 scoped_refptr<const UsbConfigDescriptor> config_; | |
| 103 PlatformUsbInterface interface_; | |
| 104 }; | |
| 105 | |
| 106 class UsbConfigDescriptor : public base::RefCounted<UsbConfigDescriptor> { | |
| 107 public: | |
| 108 explicit UsbConfigDescriptor(PlatformUsbConfigDescriptor config); | |
| 109 virtual ~UsbConfigDescriptor(); | |
| 110 | |
| 111 size_t numInterfaces() const; | |
| 112 | |
| 113 scoped_refptr<const UsbInterface> | |
| 114 getInterface(size_t index) const; | |
| 115 | |
| 116 private: | |
| 117 PlatformUsbConfigDescriptor config_; | |
| 118 }; | |
| 119 | |
| 120 #endif // CHROME_BROWSER_USB_USB_INTERFACE_H_ | |
| OLD | NEW |