OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 // TODO(gdk): The string-style enumerations are temporary, and will be removed | |
6 // once full enumeration support is added. Also, the array-of-longs are | |
7 // temporary and will be removed once there is full ArrayBuffer support. | |
8 | |
9 [nodoc] namespace experimental.usb { | |
10 | |
11 // A Device encapsulates everything that is needed to communicate with a USB | |
12 // device. They are returned by findDevice calls and have all of their | |
13 // fields populated before being returned. | |
14 dictionary Device { | |
15 long handle; | |
16 long vendorId; | |
17 long productId; | |
18 }; | |
19 | |
20 // ControlTransferInfo represents that parameters to a single USB control | |
21 // transfer. | |
22 dictionary ControlTransferInfo { | |
23 // The direction of this transfer. Must be one of either in or out. | |
24 DOMString direction; | |
miket_OOO
2012/04/25 23:10:37
A little vertical whitespace would be helpful for
Garret Kelly
2012/04/26 20:13:44
Done.
| |
25 // The intended recipient for this transfer. Must be one of device, | |
26 // interface, endpoint, or other. | |
27 DOMString recipient; | |
28 // The type of this request. Must be one of standard, class, vendor, | |
29 // or reserved. | |
30 DOMString requestType; | |
31 long request; | |
32 long value; | |
33 long index; | |
34 // If this transfer is an input transfer, then this field must be set to | |
35 // indicate the expected data length. If this is an output transfer, then | |
36 // this field is ignored. | |
37 long? length; | |
38 long[]? data; | |
39 }; | |
40 | |
41 // GenericTransferInfo is used by both bulk and interrupt transfers to | |
42 // specify the parameters of the transfer. | |
43 dictionary GenericTransferInfo { | |
44 // The direction of this transfer. Must be one of in or out. | |
45 DOMString direction; | |
46 long endpoint; | |
47 // If this is an input transfer then this field indicates the size of the | |
48 // input buffer. If this is an output transfer then this field is ignored. | |
49 long? length; | |
50 Blob? data; | |
51 // If this is an output transfer then this field must be populated. | |
52 // Otherwise, it will be ignored. | |
53 long[]? data; | |
54 }; | |
55 | |
56 // When a USB event occurs the event handler specified in findDevice will | |
asargent_no_longer_on_chrome
2012/04/26 21:21:45
Can you clarify here that it's the onEvent propert
Garret Kelly
2012/04/27 00:32:34
Done.
| |
57 // have a UsbEvent delivered to it which will contain the result of a | |
58 // trasnsfer, including returned data. | |
miket_OOO
2012/04/25 23:10:37
spelling
Garret Kelly
2012/04/26 20:13:44
Done.
| |
59 dictionary UsbEvent { | |
60 // A string indicating the type of the event. Currently will only contain | |
61 // the value 'transferResult'. | |
62 DOMString type; | |
63 // A value of 1 indicates that the transfer was a success. Other values | |
miket_OOO
2012/04/25 23:10:37
This feels nonstandard. Could zero indicate succes
Garret Kelly
2012/04/26 20:13:44
Done.
| |
64 // indicate faliure. | |
miket_OOO
2012/04/25 23:10:37
spelling
Garret Kelly
2012/04/26 20:13:44
Done.
| |
65 long? resultCode; | |
66 // If the transfer was an input transfer then this field will contain all | |
67 // of the input data requested. | |
68 long[]? data; | |
69 | |
70 // The following fields are used for internal event routing and can be | |
71 // ignored. | |
72 [nodoc] boolean isFinalEvent; | |
73 [nodoc] long srcId; | |
74 }; | |
75 | |
76 callback OnEventCallback = void (UsbEvent event); | |
77 | |
78 dictionary DeviceOptions { | |
79 // The schema generator does not support dictionaries with only events. | |
80 // Ignore this field. | |
81 [nodoc] long? dummyValue; | |
82 // Invoked by the extension API whenever an event occurs the device(s) | |
miket_OOO
2012/04/25 23:10:37
occurs for? with?
Garret Kelly
2012/04/26 20:13:44
Done.
| |
83 // that this DeviceOptions is associated with. | |
84 OnEventCallback? onEvent; | |
85 }; | |
86 | |
87 callback FindDeviceCallback = void (optional Device device); | |
88 callback TransferCallback = void (); | |
89 | |
90 interface Functions { | |
91 // Finds the first instance of the USB device specified by the vendorId/ | |
92 // productId pair and, if permissions allow, opens it for use. | |
93 // If the device is successfully opened, invokes the provided callback with | |
94 // the Device object. | |
asargent_no_longer_on_chrome
2012/04/26 21:21:45
comment nit: The FindDeviceCallback should fire on
Garret Kelly
2012/04/27 00:32:34
Quite right. It actually does, and this comment is
| |
95 // |vendorId|: The vendor ID of the USB device to find. | |
96 // |productId|: The product ID of the USB device to find. | |
97 // |callback|: Invoked with the opened Device on success. | |
98 static void findDevice(long vendorId, long productId, | |
99 DeviceOptions options, FindDeviceCallback callback); | |
100 | |
101 // Closes an open device instance. Invoking operations on a device after it | |
102 // has been closed is a safe operation, but causes no action to be taken. | |
103 // |device|: The device to close. | |
104 static void closeDevice(Device device); | |
105 | |
106 // Performs a control transfer on the specified device. See the | |
107 // ControlTransferInfo structure for the parameters required to make a | |
108 // transfer. | |
109 // |device|: An open device to make the transfer on. | |
110 // |transferInfo|: The parameters to the transfer. See ControlTransferInfo. | |
111 // |callback|: Invoked once the transfer has completed. | |
112 static void controlTransfer(Device device, | |
113 ControlTransferInfo transferInfo, optional TransferCallback callback); | |
114 | |
115 // Performs a bulk transfer on the specified device. | |
116 // |device|: An open device to make the transfer on. | |
117 // |transferInfo|: The paramters to the transfer. See GenericTransferInfo. | |
118 // |callback|: Invoked once the transfer has completed. | |
119 static void bulkTransfer(Device device, GenericTransferInfo transferInfo, | |
120 optional TransferCallback callback); | |
121 | |
122 // Performs a control transfer on the specified device. | |
asargent_no_longer_on_chrome
2012/04/26 21:21:45
nit: Should this say "Performs an interrupt transf
Garret Kelly
2012/04/27 00:32:34
D'oh! Done.
| |
123 // |device|: An open device to make the transfer on. | |
124 // |transferInfo|: The paramters to the transfer. See GenericTransferInfo. | |
125 // |callback|: Invoked once the transfer has completed. | |
126 static void interruptTransfer(Device device, | |
127 GenericTransferInfo transferInfo, optional TransferCallback callback); | |
128 }; | |
129 | |
130 interface Events { | |
131 static void onEvent(UsbEvent event); | |
132 }; | |
133 | |
134 }; | |
OLD | NEW |