Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: public/platform/modules/webusb/WebUSBDevice.h

Issue 1264483005: Add WebUSB bindings and client interface [part 2] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: enum class Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/webusb/USBError.cpp ('k') | public/platform/modules/webusb/WebUSBDeviceInfo.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/WebPassOwnPtr.h"
10 #include "public/platform/WebVector.h"
11
12 namespace blink {
13
14 struct WebUSBDeviceInfo;
15 struct WebUSBError;
16 struct WebUSBTransferInfo;
17
18 using WebUSBDeviceOpenCallbacks = WebCallbacks<void, const WebUSBError&>;
19 using WebUSBDeviceCloseCallbacks = WebCallbacks<void, const WebUSBError&>;
20 using WebUSBDeviceSetConfigurationCallbacks = WebCallbacks<void, const WebUSBErr or&>;
21 using WebUSBDeviceClaimInterfaceCallbacks = WebCallbacks<void, const WebUSBError &>;
22 using WebUSBDeviceReleaseInterfaceCallbacks = WebCallbacks<void, const WebUSBErr or&>;
23 using WebUSBDeviceResetCallbacks = WebCallbacks<void, const WebUSBError&>;
24 using WebUSBDeviceSetInterfaceAlternateSettingCallbacks = WebCallbacks<void, con st WebUSBError&>;
25 using WebUSBDeviceClearHaltCallbacks = WebCallbacks<void, const WebUSBError&>;
26 using WebUSBDeviceControlTransferCallbacks = WebCallbacks<WebPassOwnPtr<WebUSBTr ansferInfo>, const WebUSBError&>;
27 using WebUSBDeviceBulkTransferCallbacks = WebCallbacks<WebPassOwnPtr<WebUSBTrans ferInfo>, const WebUSBError&>;
28 using WebUSBDeviceInterruptTransferCallbacks = WebCallbacks<WebPassOwnPtr<WebUSB TransferInfo>, const WebUSBError&>;
29
30 class WebUSBDevice {
31 public:
32 enum class TransferDirection {
33 In,
34 Out,
35 };
36
37 enum class RequestType {
38 Standard,
39 Class,
40 Vendor,
41 };
42
43 enum RequestRecipient {
44 Device,
45 Interface,
46 Endpoint,
47 Other,
48 };
49
50 struct ControlTransferParameters {
51 TransferDirection direction;
52 RequestType type;
53 RequestRecipient recipient;
54 uint8_t request;
55 uint16_t value;
56 uint16_t index;
57 };
58
59 virtual ~WebUSBDevice() { }
60
61 virtual const WebUSBDeviceInfo& info() const = 0;
62
63 // Opens the device.
64 // Ownership of the WebUSBDeviceOpenCallbacks is transferred to the client.
65 virtual void open(WebUSBDeviceOpenCallbacks*) = 0;
66
67 // Closes the device.
68 // Ownership of the WebUSBDeviceCloseCallbacks is transferred to the client.
69 virtual void close(WebUSBDeviceCloseCallbacks*) = 0;
70
71 // Sets the active configuration for the device.
72 // Ownership of the WebUSBDeviceSetConfigurationCallbacks is transferred to the client.
73 virtual void setConfiguration(uint8_t configurationValue, WebUSBDeviceSetCon figurationCallbacks*) = 0;
74
75 // Claims an interface in the active configuration.
76 // Ownership of the WebUSBDeviceClaimInterfaceCallbacks is transferred to th e client.
77 virtual void claimInterface(uint8_t interfaceNumber, WebUSBDeviceClaimInterf aceCallbacks*) = 0;
78
79 // Releases a claimed interface.
80 // Ownership of the WebUSBDeviceReleaseInterfaceCallbacks is transferred to the client.
81 virtual void releaseInterface(uint8_t interfaceNumber, WebUSBDeviceReleaseIn terfaceCallbacks*) = 0;
82
83 // Sets the alternate setting of an interface.
84 // Ownership of the WebUSBDeviceSetInterfaceAlternateSettingCallbacks is tra nsferred to the client.
85 virtual void setInterface(uint8_t interfaceNumber, uint8_t alternateSetting, WebUSBDeviceSetInterfaceAlternateSettingCallbacks*) = 0;
86
87 // Clears the halt condition on a specific endpoint.
88 // Ownership of the WebUSBDeviceClearHaltCallbacks is transferred to the cli ent.
89 virtual void clearHalt(uint8_t endpointNumber, WebUSBDeviceClearHaltCallback s*) = 0;
90
91 // Initiates a control transfer.
92 // Ownership of the WebUSBDeviceControlTransferCallbacks is transferred to t he client.
93 virtual void controlTransfer(const ControlTransferParameters&, uint8_t* data , size_t dataSize, unsigned timeout, WebUSBDeviceControlTransferCallbacks*) = 0;
94
95 // Initiates a bulk or interrupt transfer.
96 // Ownership of the WebUSBDeviceBulkTransferCallbacks is transferred to the client.
97 virtual void transfer(TransferDirection, uint8_t endpointNumber, uint8_t* da ta, size_t dataSize, unsigned timeout, WebUSBDeviceBulkTransferCallbacks*) = 0;
98
99 // Resets the device.
100 // Ownership of the WebUSBDeviceResetCallbacks is transferred to the client.
101 virtual void reset(WebUSBDeviceResetCallbacks*) = 0;
102 };
103
104 } // namespace blink
105
106 #endif // WebUSBDevice_h
OLDNEW
« no previous file with comments | « Source/modules/webusb/USBError.cpp ('k') | public/platform/modules/webusb/WebUSBDeviceInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698