blob: defde69d903144d6e4d8b6f8eaefba9a2bf7fa77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
// Copyright 2014 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 COMPONENTS_USB_SERVICE_USB_INTERFACE_IMPL_H_
#define COMPONENTS_USB_SERVICE_USB_INTERFACE_IMPL_H_
#include "base/memory/ref_counted.h"
#include "components/usb_service/usb_interface.h"
#include "components/usb_service/usb_service_export.h"
struct libusb_config_descriptor;
struct libusb_endpoint_descriptor;
struct libusb_interface;
struct libusb_interface_descriptor;
namespace usb_service {
typedef libusb_config_descriptor* PlatformUsbConfigDescriptor;
typedef const libusb_endpoint_descriptor* PlatformUsbEndpointDescriptor;
typedef const libusb_interface* PlatformUsbInterface;
typedef const libusb_interface_descriptor* PlatformUsbInterfaceDescriptor;
class UsbConfigDescriptorImpl;
class UsbInterfaceAltSettingDescriptor;
class UsbEndpointDescriptorImpl : public UsbEndpointDescriptor {
public:
virtual int GetAddress() const OVERRIDE;
virtual UsbEndpointDirection GetDirection() const OVERRIDE;
virtual int GetMaximumPacketSize() const OVERRIDE;
virtual UsbSynchronizationType GetSynchronizationType() const OVERRIDE;
virtual UsbTransferType GetTransferType() const OVERRIDE;
virtual UsbUsageType GetUsageType() const OVERRIDE;
virtual int GetPollingInterval() const OVERRIDE;
private:
friend class base::RefCounted<const UsbEndpointDescriptorImpl>;
friend class UsbInterfaceAltSettingDescriptorImpl;
UsbEndpointDescriptorImpl(scoped_refptr<const UsbConfigDescriptor> config,
PlatformUsbEndpointDescriptor descriptor);
virtual ~UsbEndpointDescriptorImpl();
scoped_refptr<const UsbConfigDescriptor> config_;
PlatformUsbEndpointDescriptor descriptor_;
DISALLOW_COPY_AND_ASSIGN(UsbEndpointDescriptorImpl);
};
class UsbInterfaceAltSettingDescriptorImpl
: public UsbInterfaceAltSettingDescriptor {
public:
virtual size_t GetNumEndpoints() const OVERRIDE;
virtual scoped_refptr<const UsbEndpointDescriptor> GetEndpoint(
size_t index) const OVERRIDE;
virtual int GetInterfaceNumber() const OVERRIDE;
virtual int GetAlternateSetting() const OVERRIDE;
virtual int GetInterfaceClass() const OVERRIDE;
virtual int GetInterfaceSubclass() const OVERRIDE;
virtual int GetInterfaceProtocol() const OVERRIDE;
private:
friend class UsbInterfaceDescriptorImpl;
UsbInterfaceAltSettingDescriptorImpl(
scoped_refptr<const UsbConfigDescriptor> config,
PlatformUsbInterfaceDescriptor descriptor);
virtual ~UsbInterfaceAltSettingDescriptorImpl();
scoped_refptr<const UsbConfigDescriptor> config_;
PlatformUsbInterfaceDescriptor descriptor_;
DISALLOW_COPY_AND_ASSIGN(UsbInterfaceAltSettingDescriptorImpl);
};
class UsbInterfaceDescriptorImpl : public UsbInterfaceDescriptor {
public:
virtual size_t GetNumAltSettings() const OVERRIDE;
virtual scoped_refptr<const UsbInterfaceAltSettingDescriptor> GetAltSetting(
size_t index) const OVERRIDE;
private:
friend class base::RefCounted<const UsbInterfaceDescriptorImpl>;
friend class UsbConfigDescriptorImpl;
UsbInterfaceDescriptorImpl(scoped_refptr<const UsbConfigDescriptor> config,
PlatformUsbInterface usbInterface);
virtual ~UsbInterfaceDescriptorImpl();
scoped_refptr<const UsbConfigDescriptor> config_;
PlatformUsbInterface interface_;
DISALLOW_COPY_AND_ASSIGN(UsbInterfaceDescriptorImpl);
};
class UsbConfigDescriptorImpl : public UsbConfigDescriptor {
public:
virtual size_t GetNumInterfaces() const OVERRIDE;
virtual scoped_refptr<const UsbInterfaceDescriptor> GetInterface(
size_t index) const OVERRIDE;
private:
friend class base::RefCounted<UsbConfigDescriptor>;
friend class UsbDeviceImpl;
explicit UsbConfigDescriptorImpl(PlatformUsbConfigDescriptor config);
virtual ~UsbConfigDescriptorImpl();
PlatformUsbConfigDescriptor config_;
DISALLOW_COPY_AND_ASSIGN(UsbConfigDescriptorImpl);
};
} // namespace usb_service;
#endif // COMPONENTS_USB_SERVICE_USB_INTERFACE_IMPL_H_
|