OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 WebUSBDevice_h | |
6 #define WebUSBDevice_h | |
7 | |
8 #include "public/platform/WebCallbacks.h" | |
9 #include "public/platform/WebVector.h" | |
10 | |
11 namespace blink { | |
12 | |
13 struct WebUSBDeviceInfo; | |
14 struct WebUSBError; | |
15 struct WebUSBTransferInfo; | |
16 | |
17 using WebUSBDeviceOpenCallbacks = WebCallbacks<void, WebUSBError*>; | |
yhirano
2015/08/03 05:28:51
const WebUSBError&
Ken Rockot(use gerrit already)
2015/08/03 21:49:44
Done.
| |
18 using WebUSBDeviceCloseCallbacks = WebCallbacks<void, WebUSBError*>; | |
19 using WebUSBDeviceSetConfigurationCallbacks = WebCallbacks<void, WebUSBError*>; | |
20 using WebUSBDeviceClaimInterfaceCallbacks = WebCallbacks<void, WebUSBError*>; | |
21 using WebUSBDeviceReleaseInterfaceCallbacks = WebCallbacks<void, WebUSBError*>; | |
22 using WebUSBDeviceResetCallbacks = WebCallbacks<void, WebUSBError*>; | |
23 using WebUSBDeviceSetInterfaceAlternateSettingCallbacks = WebCallbacks<void, Web USBError*>; | |
24 using WebUSBDeviceClearHaltCallbacks = WebCallbacks<void, WebUSBError*>; | |
25 using WebUSBDeviceControlTransferCallbacks = WebCallbacks<WebUSBTransferInfo*, W ebUSBError*>; | |
yhirano
2015/08/03 05:28:51
Please consider using |WebPassOwnPtr<WebTransferIn
yhirano
2015/08/03 05:28:52
Is WebUSBTransferInfo defined anywhere?
Ken Rockot(use gerrit already)
2015/08/03 21:49:44
Oops - Added the header to this CL.
Ken Rockot(use gerrit already)
2015/08/03 21:49:44
Done.
| |
26 using WebUSBDeviceBulkTransferCallbacks = WebCallbacks<WebUSBTransferInfo*, WebU SBError*>; | |
27 using WebUSBDeviceInterruptTransferCallbacks = WebCallbacks<WebUSBTransferInfo*, WebUSBError*>; | |
28 | |
29 class WebUSBDevice { | |
30 public: | |
31 enum class TransferDirection { | |
32 In, | |
33 Out, | |
34 }; | |
35 | |
36 enum class RequestType { | |
37 Standard, | |
38 Class, | |
39 Vendor, | |
40 }; | |
41 | |
42 enum RequestRecipient { | |
43 Device, | |
44 Interface, | |
45 Endpoint, | |
46 Other, | |
47 }; | |
48 | |
49 struct ControlTransferParameters { | |
50 TransferDirection direction; | |
51 RequestType type; | |
52 RequestRecipient recipient; | |
53 uint8_t request; | |
54 uint16_t value; | |
55 uint16_t index; | |
56 }; | |
57 | |
58 virtual ~WebUSBDevice() { } | |
59 | |
60 virtual const WebUSBDeviceInfo& info() const = 0; | |
61 | |
62 // Opens the device. | |
63 // Ownership of the WebUSBDeviceOpenCallbacks is transferred to the client. | |
64 virtual void open(WebUSBDeviceOpenCallbacks*) = 0; | |
65 | |
66 // Closes the device. | |
67 // Ownership of the WebUSBDeviceCloseCallbacks is transferred to the client. | |
68 virtual void close(WebUSBDeviceCloseCallbacks*) = 0; | |
69 | |
70 // Sets the active configuration for the device. | |
71 // Ownership of the WebUSBDeviceSetConfigurationCallbacks is transferred to the client. | |
72 virtual void setConfiguration(uint8_t configurationValue, WebUSBDeviceSetCon figurationCallbacks*) = 0; | |
73 | |
74 // Claims an interface in the active configuration. | |
75 // Ownership of the WebUSBDeviceClaimInterfaceCallbacks is transferred to th e client. | |
76 virtual void claimInterface(uint8_t interfaceNumber, WebUSBDeviceClaimInterf aceCallbacks*) = 0; | |
77 | |
78 // Releases a claimed interface. | |
79 // Ownership of the WebUSBDeviceReleaseInterfaceCallbacks is transferred to the client. | |
80 virtual void releaseInterface(uint8_t interfaceNumber, WebUSBDeviceReleaseIn terfaceCallbacks*) = 0; | |
81 | |
82 // Sets the alternate setting of an interface. | |
83 // Ownership of the WebUSBDeviceSetInterfaceAlternateSettingCallbacks is tra nsferred to the client. | |
84 virtual void setInterface(uint8_t interfaceNumber, uint8_t alternateSetting, WebUSBDeviceSetInterfaceAlternateSettingCallbacks*) = 0; | |
85 | |
86 // Clears the halt condition on a specific endpoint. | |
87 // Ownership of the WebUSBDeviceClearHaltCallbacks is transferred to the cli ent. | |
88 virtual void clearHalt(uint8_t endpointNumber, WebUSBDeviceClearHaltCallback s*) = 0; | |
89 | |
90 // Initiates a control transfer. | |
91 // Ownership of the WebUSBDeviceControlTransferCallbacks is transferred to t he client. | |
92 virtual void controlTransfer(const ControlTransferParameters&, uint8_t* data , size_t dataSize, unsigned timeout, WebUSBDeviceControlTransferCallbacks*) = 0; | |
93 | |
94 // Initiates a bulk or interrupt transfer. | |
95 // Ownership of the WebUSBDeviceBulkTransferCallbacks is transferred to the client. | |
96 virtual void transfer(TransferDirection, uint8_t endpointNumber, uint8_t* da ta, size_t dataSize, unsigned timeout, WebUSBDeviceBulkTransferCallbacks*) = 0; | |
97 | |
98 // Resets the device. | |
99 // Ownership of the WebUSBDeviceResetCallbacks is transferred to the client. | |
100 virtual void reset(WebUSBDeviceResetCallbacks*) = 0; | |
101 }; | |
102 | |
103 } // namespace blink | |
104 | |
105 #endif // WebUSBDevice_h | |
OLD | NEW |