Chromium Code Reviews| Index: chrome/browser/usb/usb_interface.h |
| diff --git a/chrome/browser/usb/usb_interface.h b/chrome/browser/usb/usb_interface.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2b6a0c9d5b76aadbc1922b5ca2f9803c3292c681 |
| --- /dev/null |
| +++ b/chrome/browser/usb/usb_interface.h |
| @@ -0,0 +1,120 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_USB_USB_INTERFACE_H_ |
| +#define CHROME_BROWSER_USB_USB_INTERFACE_H_ |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| + |
| +struct libusb_config_descriptor; |
| +struct libusb_endpoint_descriptor; |
| +struct libusb_interface; |
| +struct libusb_interface_descriptor; |
| + |
| +typedef libusb_config_descriptor* PlatformUsbConfigDescriptor; |
| +typedef const libusb_endpoint_descriptor* PlatformUsbEndpointDescriptor; |
| +typedef const libusb_interface* PlatformUsbInterface; |
| +typedef const libusb_interface_descriptor* PlatformUsbInterfaceDescriptor; |
| + |
| +class UsbDevice; |
| + |
| +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.
|
| + USB_ENDPOINT_CONTROL = 0, |
| + USB_ENDPOINT_INTERRUPT, |
| + USB_ENDPOINT_ISOCHRONOUS, |
| + USB_ENDPOINT_BULK |
| +}; |
| + |
| +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.
|
| + USB_DIRECTION_INBOUND = 0, |
| + USB_DIRECTION_OUTBOUND |
| +}; |
| + |
| +enum UsbSynchronizationType { |
| + USB_SYNCHRONIZATION_NONE = 0, |
| + USB_SYNCHRONIZATION_ASYNCHRONOUS, |
| + USB_SYNCHRONIZATION_ADAPTIVE, |
| + USB_SYNCHRONIZATION_SYNCHRONOUS, |
| +}; |
| + |
| +enum UsbUsageType { |
| + USB_USAGE_DATA = 0, |
| + USB_USAGE_FEEDBACK, |
| + USB_USAGE_EXPLICIT_FEEDBACK |
| +}; |
| + |
| +class UsbConfigDescriptor; |
| + |
| +class UsbEndpointDescriptor : public base::RefCounted<UsbEndpointDescriptor> { |
| + public: |
| + UsbEndpointDescriptor(scoped_refptr<const UsbConfigDescriptor> config, |
| + PlatformUsbEndpointDescriptor descriptor); |
| + 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.
|
| + |
| + int GetAddress() const; |
| + UsbInterfaceDirection GetDirection() const; |
| + int GetMaximumPacketSize() const; |
| + UsbEndpointType GetEndpointType() const; |
| + UsbSynchronizationType GetSynchronizationType() const; |
| + UsbUsageType GetUsageType() const; |
| + int GetPollingInterval() const; |
| + |
| + private: |
| + scoped_refptr<const UsbConfigDescriptor> config_; |
| + PlatformUsbEndpointDescriptor descriptor_; |
| +}; |
| + |
| +class UsbInterfaceDescriptor |
| + : public base::RefCounted<UsbInterfaceDescriptor> { |
| + public: |
| + UsbInterfaceDescriptor(scoped_refptr<const UsbConfigDescriptor> config, |
| + PlatformUsbInterfaceDescriptor descriptor); |
| + virtual ~UsbInterfaceDescriptor(); |
| + |
| + size_t numEndpoints() const; |
|
Bei Zhang
2013/04/26 22:38:01
GetNumEndpoints
Kenny Root (Google)
2013/05/08 01:15:08
Done.
|
| + scoped_refptr<const UsbEndpointDescriptor> |
| + 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.
|
| + |
| + int GetInterfaceNumber() const; |
| + int GetAlternateSetting() const; |
| + int GetInterfaceClass() const; |
| + int GetInterfaceSubclass() const; |
| + int GetInterfaceProtocol() const; |
| + |
| + private: |
| + scoped_refptr<const UsbConfigDescriptor> config_; |
| + PlatformUsbInterfaceDescriptor descriptor_; |
| +}; |
| + |
| +class UsbInterface : public base::RefCounted<UsbInterface> { |
| + public: |
| + UsbInterface(scoped_refptr<const UsbConfigDescriptor> config, |
| + PlatformUsbInterface usbInterface); |
| + virtual ~UsbInterface(); |
| + |
| + size_t numAltSettings() const; |
| + scoped_refptr<const UsbInterfaceDescriptor> |
| + getAltSetting(size_t index) const; |
| + |
| + private: |
| + scoped_refptr<const UsbConfigDescriptor> config_; |
| + PlatformUsbInterface interface_; |
| +}; |
| + |
| +class UsbConfigDescriptor : public base::RefCounted<UsbConfigDescriptor> { |
| + public: |
| + explicit UsbConfigDescriptor(PlatformUsbConfigDescriptor config); |
| + virtual ~UsbConfigDescriptor(); |
| + |
| + size_t numInterfaces() const; |
| + |
| + scoped_refptr<const UsbInterface> |
| + getInterface(size_t index) const; |
| + |
| + private: |
| + PlatformUsbConfigDescriptor config_; |
| +}; |
| + |
| +#endif // CHROME_BROWSER_USB_USB_INTERFACE_H_ |