Home | History | Annotate | Download | only in usb_service
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef COMPONENTS_USB_SERVICE_USB_INTERFACE_H_
      6 #define COMPONENTS_USB_SERVICE_USB_INTERFACE_H_
      7 
      8 #include "base/memory/ref_counted.h"
      9 #include "components/usb_service/usb_service_export.h"
     10 
     11 namespace usb_service {
     12 
     13 enum UsbTransferType {
     14   USB_TRANSFER_CONTROL = 0,
     15   USB_TRANSFER_ISOCHRONOUS,
     16   USB_TRANSFER_BULK,
     17   USB_TRANSFER_INTERRUPT,
     18 };
     19 
     20 enum UsbEndpointDirection {
     21   USB_DIRECTION_INBOUND = 0,
     22   USB_DIRECTION_OUTBOUND,
     23 };
     24 
     25 enum UsbSynchronizationType {
     26   USB_SYNCHRONIZATION_NONE = 0,
     27   USB_SYNCHRONIZATION_ASYNCHRONOUS,
     28   USB_SYNCHRONIZATION_ADAPTIVE,
     29   USB_SYNCHRONIZATION_SYNCHRONOUS,
     30 };
     31 
     32 enum UsbUsageType {
     33   USB_USAGE_DATA = 0,
     34   USB_USAGE_FEEDBACK,
     35   USB_USAGE_EXPLICIT_FEEDBACK
     36 };
     37 
     38 class USB_SERVICE_EXPORT UsbEndpointDescriptor
     39     : public base::RefCounted<const UsbEndpointDescriptor> {
     40  public:
     41   virtual int GetAddress() const = 0;
     42   virtual UsbEndpointDirection GetDirection() const = 0;
     43   virtual int GetMaximumPacketSize() const = 0;
     44   virtual UsbSynchronizationType GetSynchronizationType() const = 0;
     45   virtual UsbTransferType GetTransferType() const = 0;
     46   virtual UsbUsageType GetUsageType() const = 0;
     47   virtual int GetPollingInterval() const = 0;
     48 
     49  protected:
     50   friend class base::RefCounted<const UsbEndpointDescriptor>;
     51 
     52   UsbEndpointDescriptor() {};
     53   virtual ~UsbEndpointDescriptor() {};
     54 
     55   DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptor);
     56 };
     57 
     58 class USB_SERVICE_EXPORT UsbInterfaceAltSettingDescriptor
     59     : public base::RefCounted<const UsbInterfaceAltSettingDescriptor> {
     60  public:
     61   virtual size_t GetNumEndpoints() const = 0;
     62   virtual scoped_refptr<const UsbEndpointDescriptor> GetEndpoint(
     63       size_t index) const = 0;
     64 
     65   virtual int GetInterfaceNumber() const = 0;
     66   virtual int GetAlternateSetting() const = 0;
     67   virtual int GetInterfaceClass() const = 0;
     68   virtual int GetInterfaceSubclass() const = 0;
     69   virtual int GetInterfaceProtocol() const = 0;
     70 
     71  protected:
     72   friend class base::RefCounted<const UsbInterfaceAltSettingDescriptor>;
     73 
     74   UsbInterfaceAltSettingDescriptor() {};
     75   virtual ~UsbInterfaceAltSettingDescriptor() {};
     76 
     77   DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptor);
     78 };
     79 
     80 class USB_SERVICE_EXPORT UsbInterfaceDescriptor
     81     : public base::RefCounted<const UsbInterfaceDescriptor> {
     82  public:
     83   virtual size_t GetNumAltSettings() const = 0;
     84   virtual scoped_refptr<const UsbInterfaceAltSettingDescriptor> GetAltSetting(
     85       size_t index) const = 0;
     86 
     87  protected:
     88   friend class base::RefCounted<const UsbInterfaceDescriptor>;
     89 
     90   UsbInterfaceDescriptor() {};
     91   virtual ~UsbInterfaceDescriptor() {};
     92 
     93   DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptor);
     94 };
     95 
     96 class USB_SERVICE_EXPORT UsbConfigDescriptor
     97     : public base::RefCounted<UsbConfigDescriptor> {
     98  public:
     99   virtual size_t GetNumInterfaces() const = 0;
    100   virtual scoped_refptr<const UsbInterfaceDescriptor> GetInterface(
    101       size_t index) const = 0;
    102 
    103  protected:
    104   friend class base::RefCounted<UsbConfigDescriptor>;
    105 
    106   UsbConfigDescriptor() {};
    107   virtual ~UsbConfigDescriptor() {};
    108 
    109   DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptor);
    110 };
    111 
    112 }  // namespace usb_service;
    113 
    114 #endif  // COMPONENTS_USB_SERVICE_USB_INTERFACE_H_
    115