Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_USB_SERVICE_USB_INTERFACE_H_ | 5 #ifndef COMPONENTS_USB_SERVICE_USB_INTERFACE_H_ |
| 6 #define COMPONENTS_USB_SERVICE_USB_INTERFACE_H_ | 6 #define COMPONENTS_USB_SERVICE_USB_INTERFACE_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "components/usb_service/usb_service_export.h" | 9 #include "components/usb_service/usb_service_export.h" |
| 10 | 10 |
| 11 struct libusb_config_descriptor; | |
| 12 struct libusb_endpoint_descriptor; | |
| 13 struct libusb_interface; | |
| 14 struct libusb_interface_descriptor; | |
| 15 | |
| 16 namespace usb_service { | 11 namespace usb_service { |
| 17 | 12 |
| 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 enum UsbTransferType { | 13 enum UsbTransferType { |
| 24 USB_TRANSFER_CONTROL = 0, | 14 USB_TRANSFER_CONTROL = 0, |
| 25 USB_TRANSFER_ISOCHRONOUS, | 15 USB_TRANSFER_ISOCHRONOUS, |
| 26 USB_TRANSFER_BULK, | 16 USB_TRANSFER_BULK, |
| 27 USB_TRANSFER_INTERRUPT, | 17 USB_TRANSFER_INTERRUPT, |
| 28 }; | 18 }; |
| 29 | 19 |
| 30 enum UsbEndpointDirection { | 20 enum UsbEndpointDirection { |
| 31 USB_DIRECTION_INBOUND = 0, | 21 USB_DIRECTION_INBOUND = 0, |
| 32 USB_DIRECTION_OUTBOUND, | 22 USB_DIRECTION_OUTBOUND, |
| 33 }; | 23 }; |
| 34 | 24 |
| 35 enum UsbSynchronizationType { | 25 enum UsbSynchronizationType { |
| 36 USB_SYNCHRONIZATION_NONE = 0, | 26 USB_SYNCHRONIZATION_NONE = 0, |
| 37 USB_SYNCHRONIZATION_ASYNCHRONOUS, | 27 USB_SYNCHRONIZATION_ASYNCHRONOUS, |
| 38 USB_SYNCHRONIZATION_ADAPTIVE, | 28 USB_SYNCHRONIZATION_ADAPTIVE, |
| 39 USB_SYNCHRONIZATION_SYNCHRONOUS, | 29 USB_SYNCHRONIZATION_SYNCHRONOUS, |
| 40 }; | 30 }; |
| 41 | 31 |
| 42 enum UsbUsageType { | 32 enum UsbUsageType { |
| 43 USB_USAGE_DATA = 0, | 33 USB_USAGE_DATA = 0, |
| 44 USB_USAGE_FEEDBACK, | 34 USB_USAGE_FEEDBACK, |
| 45 USB_USAGE_EXPLICIT_FEEDBACK | 35 USB_USAGE_EXPLICIT_FEEDBACK |
| 46 }; | 36 }; |
| 47 | 37 |
| 48 class UsbDevice; | |
| 49 class UsbConfigDescriptor; | |
| 50 class UsbInterfaceDescriptor; | |
| 51 class UsbInterfaceAltSettingDescriptor; | |
| 52 | |
| 53 class USB_SERVICE_EXPORT UsbEndpointDescriptor | 38 class USB_SERVICE_EXPORT UsbEndpointDescriptor |
|
Ken Rockot(use gerrit already)
2014/05/08 12:57:21
Please don't feel obligated to do it in this CL (o
| |
| 54 : public base::RefCounted<const UsbEndpointDescriptor> { | 39 : public base::RefCounted<const UsbEndpointDescriptor> { |
| 55 public: | 40 public: |
| 56 int GetAddress() const; | 41 virtual int GetAddress() const = 0; |
| 57 UsbEndpointDirection GetDirection() const; | 42 virtual UsbEndpointDirection GetDirection() const = 0; |
| 58 int GetMaximumPacketSize() const; | 43 virtual int GetMaximumPacketSize() const = 0; |
| 59 UsbSynchronizationType GetSynchronizationType() const; | 44 virtual UsbSynchronizationType GetSynchronizationType() const = 0; |
| 60 UsbTransferType GetTransferType() const; | 45 virtual UsbTransferType GetTransferType() const = 0; |
| 61 UsbUsageType GetUsageType() const; | 46 virtual UsbUsageType GetUsageType() const = 0; |
| 62 int GetPollingInterval() const; | 47 virtual int GetPollingInterval() const = 0; |
| 63 | 48 |
| 64 private: | 49 protected: |
| 65 friend class base::RefCounted<const UsbEndpointDescriptor>; | 50 friend class base::RefCounted<const UsbEndpointDescriptor>; |
| 66 friend class UsbInterfaceAltSettingDescriptor; | |
| 67 | 51 |
| 68 UsbEndpointDescriptor(scoped_refptr<const UsbConfigDescriptor> config, | 52 UsbEndpointDescriptor() {}; |
| 69 PlatformUsbEndpointDescriptor descriptor); | 53 virtual ~UsbEndpointDescriptor() {}; |
| 70 ~UsbEndpointDescriptor(); | |
| 71 | |
| 72 scoped_refptr<const UsbConfigDescriptor> config_; | |
| 73 PlatformUsbEndpointDescriptor descriptor_; | |
| 74 | 54 |
| 75 DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptor); | 55 DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptor); |
| 76 }; | 56 }; |
| 77 | 57 |
| 78 class USB_SERVICE_EXPORT UsbInterfaceAltSettingDescriptor | 58 class USB_SERVICE_EXPORT UsbInterfaceAltSettingDescriptor |
| 79 : public base::RefCounted<const UsbInterfaceAltSettingDescriptor> { | 59 : public base::RefCounted<const UsbInterfaceAltSettingDescriptor> { |
| 80 public: | 60 public: |
| 81 size_t GetNumEndpoints() const; | 61 virtual size_t GetNumEndpoints() const = 0; |
| 82 scoped_refptr<const UsbEndpointDescriptor> GetEndpoint(size_t index) const; | 62 virtual scoped_refptr<const UsbEndpointDescriptor> GetEndpoint( |
| 63 size_t index) const = 0; | |
| 83 | 64 |
| 84 int GetInterfaceNumber() const; | 65 virtual int GetInterfaceNumber() const = 0; |
| 85 int GetAlternateSetting() const; | 66 virtual int GetAlternateSetting() const = 0; |
| 86 int GetInterfaceClass() const; | 67 virtual int GetInterfaceClass() const = 0; |
| 87 int GetInterfaceSubclass() const; | 68 virtual int GetInterfaceSubclass() const = 0; |
| 88 int GetInterfaceProtocol() const; | 69 virtual int GetInterfaceProtocol() const = 0; |
| 89 | 70 |
| 90 private: | 71 protected: |
| 91 friend class base::RefCounted<const UsbInterfaceAltSettingDescriptor>; | 72 friend class base::RefCounted<const UsbInterfaceAltSettingDescriptor>; |
| 92 friend class UsbInterfaceDescriptor; | |
| 93 | 73 |
| 94 UsbInterfaceAltSettingDescriptor( | 74 UsbInterfaceAltSettingDescriptor() {}; |
| 95 scoped_refptr<const UsbConfigDescriptor> config, | 75 virtual ~UsbInterfaceAltSettingDescriptor() {}; |
| 96 PlatformUsbInterfaceDescriptor descriptor); | |
| 97 ~UsbInterfaceAltSettingDescriptor(); | |
| 98 | |
| 99 scoped_refptr<const UsbConfigDescriptor> config_; | |
| 100 PlatformUsbInterfaceDescriptor descriptor_; | |
| 101 | 76 |
| 102 DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptor); | 77 DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptor); |
| 103 }; | 78 }; |
| 104 | 79 |
| 105 class USB_SERVICE_EXPORT UsbInterfaceDescriptor | 80 class USB_SERVICE_EXPORT UsbInterfaceDescriptor |
| 106 : public base::RefCounted<const UsbInterfaceDescriptor> { | 81 : public base::RefCounted<const UsbInterfaceDescriptor> { |
| 107 public: | 82 public: |
| 108 size_t GetNumAltSettings() const; | 83 virtual size_t GetNumAltSettings() const = 0; |
| 109 scoped_refptr<const UsbInterfaceAltSettingDescriptor> GetAltSetting( | 84 virtual scoped_refptr<const UsbInterfaceAltSettingDescriptor> GetAltSetting( |
| 110 size_t index) const; | 85 size_t index) const = 0; |
| 111 | 86 |
| 112 private: | 87 protected: |
| 113 friend class base::RefCounted<const UsbInterfaceDescriptor>; | 88 friend class base::RefCounted<const UsbInterfaceDescriptor>; |
| 114 friend class UsbConfigDescriptor; | |
| 115 | 89 |
| 116 UsbInterfaceDescriptor(scoped_refptr<const UsbConfigDescriptor> config, | 90 UsbInterfaceDescriptor() {}; |
| 117 PlatformUsbInterface usbInterface); | 91 virtual ~UsbInterfaceDescriptor() {}; |
| 118 ~UsbInterfaceDescriptor(); | |
| 119 | |
| 120 scoped_refptr<const UsbConfigDescriptor> config_; | |
| 121 PlatformUsbInterface interface_; | |
| 122 | 92 |
| 123 DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptor); | 93 DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptor); |
| 124 }; | 94 }; |
| 125 | 95 |
| 126 class USB_SERVICE_EXPORT UsbConfigDescriptor | 96 class USB_SERVICE_EXPORT UsbConfigDescriptor |
| 127 : public base::RefCounted<UsbConfigDescriptor> { | 97 : public base::RefCounted<UsbConfigDescriptor> { |
| 128 public: | 98 public: |
| 129 virtual size_t GetNumInterfaces() const; | 99 virtual size_t GetNumInterfaces() const = 0; |
| 130 virtual scoped_refptr<const UsbInterfaceDescriptor> GetInterface( | 100 virtual scoped_refptr<const UsbInterfaceDescriptor> GetInterface( |
| 131 size_t index) const; | 101 size_t index) const = 0; |
| 132 | 102 |
| 133 protected: | 103 protected: |
| 134 // Constructor called in test only | 104 friend class base::RefCounted<UsbConfigDescriptor>; |
| 135 UsbConfigDescriptor(); | |
| 136 virtual ~UsbConfigDescriptor(); | |
| 137 | 105 |
| 138 private: | 106 UsbConfigDescriptor() {}; |
| 139 friend class base::RefCounted<UsbConfigDescriptor>; | 107 virtual ~UsbConfigDescriptor() {}; |
| 140 friend class UsbDeviceImpl; | |
| 141 | |
| 142 explicit UsbConfigDescriptor(PlatformUsbConfigDescriptor config); | |
| 143 | |
| 144 PlatformUsbConfigDescriptor config_; | |
| 145 | 108 |
| 146 DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptor); | 109 DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptor); |
| 147 }; | 110 }; |
| 148 | 111 |
| 149 } // namespace usb_service; | 112 } // namespace usb_service; |
| 150 | 113 |
| 151 #endif // COMPONENTS_USB_SERVICE_USB_INTERFACE_H_ | 114 #endif // COMPONENTS_USB_SERVICE_USB_INTERFACE_H_ |
| OLD | NEW |