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
|
// Copyright 2015 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 WebUSBDevice_h
#define WebUSBDevice_h
#include "public/platform/WebCallbacks.h"
#include "public/platform/WebPassOwnPtr.h"
#include "public/platform/WebVector.h"
namespace blink {
struct WebUSBDeviceInfo;
struct WebUSBError;
struct WebUSBTransferInfo;
using WebUSBDeviceOpenCallbacks = WebCallbacks<void, const WebUSBError&>;
using WebUSBDeviceCloseCallbacks = WebCallbacks<void, const WebUSBError&>;
using WebUSBDeviceSetConfigurationCallbacks = WebCallbacks<void, const WebUSBError&>;
using WebUSBDeviceClaimInterfaceCallbacks = WebCallbacks<void, const WebUSBError&>;
using WebUSBDeviceReleaseInterfaceCallbacks = WebCallbacks<void, const WebUSBError&>;
using WebUSBDeviceResetCallbacks = WebCallbacks<void, const WebUSBError&>;
using WebUSBDeviceSetInterfaceAlternateSettingCallbacks = WebCallbacks<void, const WebUSBError&>;
using WebUSBDeviceClearHaltCallbacks = WebCallbacks<void, const WebUSBError&>;
using WebUSBDeviceTransferCallbacks = WebCallbacks<WebPassOwnPtr<WebUSBTransferInfo>, const WebUSBError&>;
class WebUSBDevice {
public:
enum class TransferDirection {
In,
Out,
};
enum class RequestType {
Standard,
Class,
Vendor,
};
enum class RequestRecipient {
Device,
Interface,
Endpoint,
Other,
};
struct ControlTransferParameters {
TransferDirection direction;
RequestType type;
RequestRecipient recipient;
uint8_t request;
uint16_t value;
uint16_t index;
};
virtual ~WebUSBDevice() { }
virtual const WebUSBDeviceInfo& info() const = 0;
// Opens the device.
// Ownership of the WebUSBDeviceOpenCallbacks is transferred to the client.
virtual void open(WebUSBDeviceOpenCallbacks*) = 0;
// Closes the device.
// Ownership of the WebUSBDeviceCloseCallbacks is transferred to the client.
virtual void close(WebUSBDeviceCloseCallbacks*) = 0;
// Sets the active configuration for the device.
// Ownership of the WebUSBDeviceSetConfigurationCallbacks is transferred to the client.
virtual void setConfiguration(uint8_t configurationValue, WebUSBDeviceSetConfigurationCallbacks*) = 0;
// Claims an interface in the active configuration.
// Ownership of the WebUSBDeviceClaimInterfaceCallbacks is transferred to the client.
virtual void claimInterface(uint8_t interfaceNumber, WebUSBDeviceClaimInterfaceCallbacks*) = 0;
// Releases a claimed interface.
// Ownership of the WebUSBDeviceReleaseInterfaceCallbacks is transferred to the client.
virtual void releaseInterface(uint8_t interfaceNumber, WebUSBDeviceReleaseInterfaceCallbacks*) = 0;
// Sets the alternate setting of an interface.
// Ownership of the WebUSBDeviceSetInterfaceAlternateSettingCallbacks is transferred to the client.
virtual void setInterface(uint8_t interfaceNumber, uint8_t alternateSetting, WebUSBDeviceSetInterfaceAlternateSettingCallbacks*) = 0;
// Clears the halt condition on a specific endpoint.
// Ownership of the WebUSBDeviceClearHaltCallbacks is transferred to the client.
virtual void clearHalt(uint8_t endpointNumber, WebUSBDeviceClearHaltCallbacks*) = 0;
// Initiates a control transfer.
// Ownership of the WebUSBDeviceTransferCallbacks is transferred to the client.
virtual void controlTransfer(const ControlTransferParameters&, uint8_t* data, size_t dataSize, unsigned timeout, WebUSBDeviceTransferCallbacks*) = 0;
// Initiates a bulk or interrupt transfer.
// Ownership of the WebUSBDeviceTransferCallbacks is transferred to the client.
virtual void transfer(TransferDirection, uint8_t endpointNumber, uint8_t* data, size_t dataSize, unsigned timeout, WebUSBDeviceTransferCallbacks*) = 0;
// Initiates an isochronous transfer.
// Ownership of the WebUSBDeviceTransferCallbacks is transferred to the client.
virtual void isochronousTransfer(TransferDirection, uint8_t endpointNumber, uint8_t* data, size_t dataSize, WebVector<unsigned> packetLengths, unsigned timeout, WebUSBDeviceTransferCallbacks*) = 0;
// Resets the device.
// Ownership of the WebUSBDeviceResetCallbacks is transferred to the client.
virtual void reset(WebUSBDeviceResetCallbacks*) = 0;
};
} // namespace blink
#endif // WebUSBDevice_h
|