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

Side by Side Diff: chrome/common/extensions/api/usb.idl

Issue 16316004: Separate usb device handle from usb device. (deprecate) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows compile and a bug. Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 namespace usb { 5 namespace usb {
6 6
7 // Direction, Recipient, RequestType, and TransferType all map to their 7 // Direction, Recipient, RequestType, and TransferType all map to their
8 // namesakes within the USB specification. 8 // namesakes within the USB specification.
9 enum Direction {in, out}; 9 enum Direction {in, out};
10 enum Recipient {device, _interface, endpoint, other}; 10 enum Recipient {device, _interface, endpoint, other};
11 enum RequestType {standard, class, vendor, reserved}; 11 enum RequestType {standard, class, vendor, reserved};
12 enum TransferType {control, interrupt, isochronous, bulk}; 12 enum TransferType {control, interrupt, isochronous, bulk};
13 13
14 // For isochronous mode, SynchronizationType and UsageType map to their 14 // For isochronous mode, SynchronizationType and UsageType map to their
15 // namesakes within the USB specification. 15 // namesakes within the USB specification.
16 enum SynchronizationType {asynchronous, adaptive, synchronous}; 16 enum SynchronizationType {asynchronous, adaptive, synchronous};
17 enum UsageType {data, feedback, explicitFeedback}; 17 enum UsageType {data, feedback, explicitFeedback};
18 18
19 // A Device encapsulates everything that is needed to communicate with a USB 19 // A <code>Device</code> uniquely identifies a connected USB device.
20 // device. They are returned by findDevice calls and have all of their 20 // They are returned by <code>findDevices</code> calls and the
21 // fields populated before being returned. 21 // <code>device</code> field remains consistent for the same device.
22 dictionary Device { 22 dictionary Device {
23 long handle; 23 long device;
24 long vendorId; 24 long vendorId;
25 long productId; 25 long productId;
26 }; 26 };
27 27
28 // A <code>DeviceHandle</code> encapsulates everything needed to communicate
29 // with a USB device.
30 // They are returned by <code>openDevice</code> calls.
31 dictionary DeviceHandle {
32 long handle;
33 };
asargent_no_longer_on_chrome 2013/06/06 21:57:29 Because this API is now released to stable, we can
34
28 dictionary EndpointDescriptor { 35 dictionary EndpointDescriptor {
29 long address; 36 long address;
30 TransferType type; 37 TransferType type;
31 Direction direction; 38 Direction direction;
32 long maximumPacketSize; 39 long maximumPacketSize;
33 40
34 // Used for isochronous mode. 41 // Used for isochronous mode.
35 SynchronizationType? synchronization; 42 SynchronizationType? synchronization;
36 UsageType? usage; 43 UsageType? usage;
37 44
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // FindDevicesOptions describes the properties of devices which are found and 128 // FindDevicesOptions describes the properties of devices which are found and
122 // opened via findDevices. 129 // opened via findDevices.
123 dictionary FindDevicesOptions { 130 dictionary FindDevicesOptions {
124 long vendorId; 131 long vendorId;
125 long productId; 132 long productId;
126 long? interfaceId; 133 long? interfaceId;
127 }; 134 };
128 135
129 callback VoidCallback = void (); 136 callback VoidCallback = void ();
130 callback FindDevicesCallback = void (Device[] device); 137 callback FindDevicesCallback = void (Device[] device);
138 callback OpenDeviceCallback = void (DeviceHandle handle);
131 callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors); 139 callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors);
132 callback CloseDeviceCallback = void (); 140 callback CloseDeviceCallback = void ();
133 callback TransferCallback = void (TransferResultInfo info); 141 callback TransferCallback = void (TransferResultInfo info);
134 callback ResetDeviceCallback = void(boolean result); 142 callback ResetDeviceCallback = void(boolean result);
135 143
136 interface Functions { 144 interface Functions {
137 // Finds the first instance of the USB device specified by the vendorId/ 145 // Finds all instances of the USB devices specified by the vendorId/
138 // productId pair and, if permissions allow, opens it for use. 146 // productId pair.
139 // Upon successfully opening a device the callback is invoked with a 147 //
140 // populated Device object. On failure, the callback is invoked with null. 148 // Upon successfully enumerate the USB devices, the callback will be called
149 // with an array of <code>Device</code> dictionaries.
150 // On failure, the callback is invoked with null.
151 //
141 // |options|: The properties to search for on target devices. 152 // |options|: The properties to search for on target devices.
142 // |callback|: Invoked with the opened Device on success. 153 // |callback|: Invoked after the enumeration completes.
143 static void findDevices(FindDevicesOptions options, 154 static void findDevices(FindDevicesOptions options,
144 FindDevicesCallback callback); 155 FindDevicesCallback callback);
145 156
146 // Closes an open device instance. Invoking operations on a device after it 157 // Create a <code>DeviceHandle</code> for further operations.
147 // has been closed is a safe operation, but causes no action to be taken. 158 //
148 // |device|: The device to close. 159 // Multiple <code>DeviceHandle</code>s can be created for a same USB Device
160 // and it is possible to use those handles independently with the device
161 // support.
162 //
163 // Developers are responsible to call <code>closeDevice</code> to close
164 // the handle, otherwise the device handle will not be closed even if there
165 // is no reference to the <code>DeviceHandle</code> object.
166 // |device|: The device to be opened.
167 // |callback|: Invoked with the created <code>DeviceHandle</code>.
168 static void openDevice(Device device,
169 OpenDeviceCallback callback);
170
171 // Closes an device handle. This operation does not effect other handles
172 // of the same device.
173 // |handle|: The device handle to close.
149 // |callback|: The callback to invoke once the device is closed. 174 // |callback|: The callback to invoke once the device is closed.
150 static void closeDevice(Device device, 175 static void closeDevice(DeviceHandle handle,
151 optional CloseDeviceCallback callback); 176 optional CloseDeviceCallback callback);
152 177
153 // Lists all the interfaces on the USB device. 178 // Lists all the interfaces on the USB device.
154 // |device|: The device from which the interfaces should be listed. 179 // |handle|: The handle of the device from which the interfaces should be
180 // listed.
155 // |callback|: The callback to invoke when the interfaces are enumerated. 181 // |callback|: The callback to invoke when the interfaces are enumerated.
156 static void listInterfaces(Device device, 182 static void listInterfaces(DeviceHandle handle,
157 ListInterfacesCallback callback); 183 ListInterfacesCallback callback);
158 184
159 // Claims an interface on the specified USB device. 185 // Claims an interface on the specified USB device.
160 // |device|: The device on which the interface is to be claimed. 186 // |device|: The device on which the interface is to be claimed.
161 // |interface|: The interface number to be claimed. 187 // |interface|: The interface number to be claimed.
162 // |callback|: The callback to invoke once the interface is claimed. 188 // |callback|: The callback to invoke once the interface is claimed.
163 static void claimInterface(Device device, long interfaceNumber, 189 static void claimInterface(DeviceHandle handle, long interfaceNumber,
164 VoidCallback callback); 190 VoidCallback callback);
165 191
166 // Releases a claim to an interface on the provided device. 192 // Releases a claim to an interface on the provided device.
167 // |device|: The device on which the interface is to be released. 193 // |handle|: The handle of the device on which the interface is to be
194 // released.
168 // |interface|: The interface number to be released. 195 // |interface|: The interface number to be released.
169 // |callback|: The callback to invoke once the interface is released. 196 // |callback|: The callback to invoke once the interface is released.
170 static void releaseInterface(Device device, long interfaceNumber, 197 static void releaseInterface(DeviceHandle handle, long interfaceNumber,
171 VoidCallback callback); 198 VoidCallback callback);
172 199
173 // Selects an alternate setting on a previously claimed interface on a 200 // Selects an alternate setting on a previously claimed interface on a
174 // device. 201 // device.
175 // |device|: The device on which the interface settings are to be set. 202 // |handle|: The handle of the device on which the interface settings are
203 // to be set.
176 // |interface|: The interface number to be set. 204 // |interface|: The interface number to be set.
177 // |alternateSetting|: The alternate setting to set. 205 // |alternateSetting|: The alternate setting to set.
178 // |callback|: The callback to invoke once the interface setting is set. 206 // |callback|: The callback to invoke once the interface setting is set.
179 static void setInterfaceAlternateSetting(Device device, 207 static void setInterfaceAlternateSetting(DeviceHandle handle,
180 long interfaceNumber, long alternateSetting, VoidCallback callback); 208 long interfaceNumber, long alternateSetting, VoidCallback callback);
181 209
182 // Performs a control transfer on the specified device. See the 210 // Performs a control transfer on the specified device. See the
183 // ControlTransferInfo structure for the parameters required to make a 211 // ControlTransferInfo structure for the parameters required to make a
184 // transfer. 212 // transfer.
185 // |device|: An open device to make the transfer on. 213 // |handle|: An device handle to make the transfer on.
186 // |transferInfo|: The parameters to the transfer. See ControlTransferInfo. 214 // |transferInfo|: The parameters to the transfer. See ControlTransferInfo.
187 // |callback|: Invoked once the transfer has completed. 215 // |callback|: Invoked once the transfer has completed.
188 static void controlTransfer(Device device, 216 static void controlTransfer(DeviceHandle handle,
189 ControlTransferInfo transferInfo, TransferCallback callback); 217 ControlTransferInfo transferInfo, TransferCallback callback);
190 218
191 // Performs a bulk transfer on the specified device. 219 // Performs a bulk transfer on the specified device.
192 // |device|: An open device to make the transfer on. 220 // |handle|: An device handle to make the transfer on.
193 // |transferInfo|: The paramters to the transfer. See GenericTransferInfo. 221 // |transferInfo|: The paramters to the transfer. See GenericTransferInfo.
194 // |callback|: Invoked once the transfer has completed. 222 // |callback|: Invoked once the transfer has completed.
195 static void bulkTransfer(Device device, GenericTransferInfo transferInfo, 223 static void bulkTransfer(DeviceHandle handle, GenericTransferInfo transferIn fo,
196 TransferCallback callback); 224 TransferCallback callback);
197 225
198 // Performs an interrupt transfer on the specified device. 226 // Performs an interrupt transfer on the specified device.
199 // |device|: An open device to make the transfer on. 227 // |handle|: An device handle to make the transfer on.
200 // |transferInfo|: The paramters to the transfer. See GenericTransferInfo. 228 // |transferInfo|: The paramters to the transfer. See GenericTransferInfo.
201 // |callback|: Invoked once the transfer has completed. 229 // |callback|: Invoked once the transfer has completed.
202 static void interruptTransfer(Device device, 230 static void interruptTransfer(DeviceHandle handle,
203 GenericTransferInfo transferInfo, TransferCallback callback); 231 GenericTransferInfo transferInfo, TransferCallback callback);
204 232
205 // Performs an isochronous transfer on the specific device. 233 // Performs an isochronous transfer on the specific device.
206 // |device|: An open device to make the transfer on. 234 // |handle|: An device handle to make the transfer on.
207 // |transferInfo|: The parameters to the transfer. See 235 // |transferInfo|: The parameters to the transfer. See
208 // IsochronousTransferInfo. 236 // IsochronousTransferInfo.
209 // |callback|: Invoked once the transfer has been completed. 237 // |callback|: Invoked once the transfer has been completed.
210 static void isochronousTransfer(Device device, 238 static void isochronousTransfer(DeviceHandle handle,
211 IsochronousTransferInfo transferInfo, 239 IsochronousTransferInfo transferInfo,
212 TransferCallback callback); 240 TransferCallback callback);
213 241
214 // Try to reset the USB device and restore the previous status. 242 // Try to reset the USB device and restore the previous status.
215 // 243 //
216 // If the reset fails, the given device will be closed and the USB device 244 // If the reset fails, the given device will be closed and the USB device
217 // will appear to be disconected and reconnected. 245 // will appear to be disconected and reconnected.
218 // You must call <code>findDevice</code> again to acquire the device. 246 // You must call <code>findDevice</code> again to acquire the device.
219 // 247 //
220 // |device|: An opened device to reset. 248 // |handle|: An device handle to reset.
221 // |callback|: Invoked once the device is reset with a boolean indicating 249 // |callback|: Invoked once the device is reset with a boolean indicating
222 // whether the reset is completed successfully. 250 // whether the reset is completed successfully.
223 static void resetDevice(Device device, 251 static void resetDevice(DeviceHandle handle,
224 ResetDeviceCallback callback); 252 ResetDeviceCallback callback);
225 }; 253 };
226 }; 254 };
OLDNEW
« no previous file with comments | « chrome/chrome_browser.gypi ('k') | chrome/test/data/extensions/api_test/usb/device_handling/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698