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

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 build 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>getDevices</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 device;
24 long vendorId;
25 long productId;
26 };
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 {
23 long handle; 32 long handle;
24 long vendorId; 33 long vendorId;
25 long productId; 34 long productId;
26 }; 35 };
27 36
28 dictionary EndpointDescriptor { 37 dictionary EndpointDescriptor {
29 long address; 38 long address;
30 TransferType type; 39 TransferType type;
31 Direction direction; 40 Direction direction;
32 long maximumPacketSize; 41 long maximumPacketSize;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 dictionary TransferResultInfo { 120 dictionary TransferResultInfo {
112 // A value of 0 indicates that the transfer was a success. Other values 121 // A value of 0 indicates that the transfer was a success. Other values
113 // indicate failure. 122 // indicate failure.
114 long? resultCode; 123 long? resultCode;
115 124
116 // If the transfer was an input transfer then this field will contain all 125 // If the transfer was an input transfer then this field will contain all
117 // of the input data requested. 126 // of the input data requested.
118 ArrayBuffer? data; 127 ArrayBuffer? data;
119 }; 128 };
120 129
121 // FindDevicesOptions describes the properties of devices which are found and 130 // GetDevicesOptions describes the properties of devices which are found and
122 // opened via findDevices. 131 // opened via getDevices.
123 dictionary FindDevicesOptions { 132 dictionary GetDevicesOptions {
124 long vendorId; 133 long vendorId;
125 long productId; 134 long productId;
126 long? interfaceId; 135 long? interfaceId;
127 }; 136 };
128 137
129 callback VoidCallback = void (); 138 callback VoidCallback = void ();
130 callback FindDevicesCallback = void (Device[] device); 139 callback GetDevicesCallback = void (Device[] devices);
140 callback FindDevicesCallback = void (DeviceHandle[] handles);
141 callback OpenDeviceCallback = void (DeviceHandle handle);
131 callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors); 142 callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors);
132 callback CloseDeviceCallback = void (); 143 callback CloseDeviceCallback = void ();
133 callback TransferCallback = void (TransferResultInfo info); 144 callback TransferCallback = void (TransferResultInfo info);
134 callback ResetDeviceCallback = void(boolean result); 145 callback ResetDeviceCallback = void(boolean result);
135 146
136 interface Functions { 147 interface Functions {
137 // Finds the first instance of the USB device specified by the vendorId/ 148 // Get all instances of the USB devices specified by the vendorId/
138 // productId pair and, if permissions allow, opens it for use. 149 // productId pair.
139 // Upon successfully opening a device the callback is invoked with a 150 //
140 // populated Device object. On failure, the callback is invoked with null. 151 // Upon successfully enumeration, the callback will be called with an array
152 // of <code>Device</code> objects. <code>Device</code> objects can further
153 // be opened by <code>openDevice</code> before any communication takes
154 // place.
155 //
141 // |options|: The properties to search for on target devices. 156 // |options|: The properties to search for on target devices.
142 // |callback|: Invoked with the opened Device on success. 157 // |callback|: Invoked after the enumeration completes.
143 static void findDevices(FindDevicesOptions options, 158 static void getDevices(GetDevicesOptions options,
144 FindDevicesCallback callback); 159 GetDevicesCallback callback);
145 160
146 // Closes an open device instance. Invoking operations on a device after it 161 // Open all instances of the USB devices specified by the vendorId/
147 // has been closed is a safe operation, but causes no action to be taken. 162 // productId pair.
148 // |device|: The device to close. 163 //
164 // Upon successfully enumeration, the callback will be called with an array
165 // of <code>DeviceHandle</code> objects. Developer is responsible to call
166 // <code>closeDevice</code> on every <code>DeviceHandle</code>, otherwise
167 // the USB device will not be closed even if the app not long possess any
168 // reference to the <code>DeviceHanlde</code> object.
169 //
170 // |options|: The properties to search for on target devices.
171 // |callback|: Invoked after the enumeration completes.
172 static void findDevices(GetDevicesOptions options,
173 FindDevicesCallback callback);
174
175 // Create a <code>DeviceHandle</code> for further operations.
176 //
177 // Multiple <code>DeviceHandle</code>s can be created for a same USB Device
178 // and it is possible to use those handles independently with the device
179 // support.
180 //
181 // Developers are responsible to call <code>closeDevice</code> to close
182 // the handle, otherwise the device handle will not be closed even if there
183 // is no reference to the <code>DeviceHandle</code> object.
184 // |device|: The device to be opened.
185 // |callback|: Invoked with the created <code>DeviceHandle</code>.
186 static void openDevice(Device device,
187 OpenDeviceCallback callback);
188
189 // Closes an device handle. This operation does not effect other handles
190 // of the same device.
191 // |handle|: The device handle to close.
149 // |callback|: The callback to invoke once the device is closed. 192 // |callback|: The callback to invoke once the device is closed.
150 static void closeDevice(Device device, 193 static void closeDevice(DeviceHandle handle,
151 optional CloseDeviceCallback callback); 194 optional CloseDeviceCallback callback);
152 195
153 // Lists all the interfaces on the USB device. 196 // Lists all the interfaces on the USB device.
154 // |device|: The device from which the interfaces should be listed. 197 // |handle|: The handle of the device from which the interfaces should be
198 // listed.
155 // |callback|: The callback to invoke when the interfaces are enumerated. 199 // |callback|: The callback to invoke when the interfaces are enumerated.
156 static void listInterfaces(Device device, 200 static void listInterfaces(DeviceHandle handle,
157 ListInterfacesCallback callback); 201 ListInterfacesCallback callback);
158 202
159 // Claims an interface on the specified USB device. 203 // Claims an interface on the specified USB device.
160 // |device|: The device on which the interface is to be claimed. 204 // |device|: The device on which the interface is to be claimed.
161 // |interface|: The interface number to be claimed. 205 // |interface|: The interface number to be claimed.
162 // |callback|: The callback to invoke once the interface is claimed. 206 // |callback|: The callback to invoke once the interface is claimed.
163 static void claimInterface(Device device, long interfaceNumber, 207 static void claimInterface(DeviceHandle handle, long interfaceNumber,
164 VoidCallback callback); 208 VoidCallback callback);
165 209
166 // Releases a claim to an interface on the provided device. 210 // Releases a claim to an interface on the provided device.
167 // |device|: The device on which the interface is to be released. 211 // |handle|: The handle of the device on which the interface is to be
212 // released.
168 // |interface|: The interface number to be released. 213 // |interface|: The interface number to be released.
169 // |callback|: The callback to invoke once the interface is released. 214 // |callback|: The callback to invoke once the interface is released.
170 static void releaseInterface(Device device, long interfaceNumber, 215 static void releaseInterface(DeviceHandle handle, long interfaceNumber,
171 VoidCallback callback); 216 VoidCallback callback);
172 217
173 // Selects an alternate setting on a previously claimed interface on a 218 // Selects an alternate setting on a previously claimed interface on a
174 // device. 219 // device.
175 // |device|: The device on which the interface settings are to be set. 220 // |handle|: The handle of the device on which the interface settings are
221 // to be set.
176 // |interface|: The interface number to be set. 222 // |interface|: The interface number to be set.
177 // |alternateSetting|: The alternate setting to set. 223 // |alternateSetting|: The alternate setting to set.
178 // |callback|: The callback to invoke once the interface setting is set. 224 // |callback|: The callback to invoke once the interface setting is set.
179 static void setInterfaceAlternateSetting(Device device, 225 static void setInterfaceAlternateSetting(DeviceHandle handle,
180 long interfaceNumber, long alternateSetting, VoidCallback callback); 226 long interfaceNumber, long alternateSetting, VoidCallback callback);
181 227
182 // Performs a control transfer on the specified device. See the 228 // Performs a control transfer on the specified device. See the
183 // ControlTransferInfo structure for the parameters required to make a 229 // ControlTransferInfo structure for the parameters required to make a
184 // transfer. 230 // transfer.
185 // |device|: An open device to make the transfer on. 231 // |handle|: An device handle to make the transfer on.
186 // |transferInfo|: The parameters to the transfer. See ControlTransferInfo. 232 // |transferInfo|: The parameters to the transfer. See ControlTransferInfo.
187 // |callback|: Invoked once the transfer has completed. 233 // |callback|: Invoked once the transfer has completed.
188 static void controlTransfer(Device device, 234 static void controlTransfer(DeviceHandle handle,
189 ControlTransferInfo transferInfo, TransferCallback callback); 235 ControlTransferInfo transferInfo, TransferCallback callback);
190 236
191 // Performs a bulk transfer on the specified device. 237 // Performs a bulk transfer on the specified device.
192 // |device|: An open device to make the transfer on. 238 // |handle|: An device handle to make the transfer on.
193 // |transferInfo|: The paramters to the transfer. See GenericTransferInfo. 239 // |transferInfo|: The paramters to the transfer. See GenericTransferInfo.
194 // |callback|: Invoked once the transfer has completed. 240 // |callback|: Invoked once the transfer has completed.
195 static void bulkTransfer(Device device, GenericTransferInfo transferInfo, 241 static void bulkTransfer(DeviceHandle handle, GenericTransferInfo transferIn fo,
196 TransferCallback callback); 242 TransferCallback callback);
197 243
198 // Performs an interrupt transfer on the specified device. 244 // Performs an interrupt transfer on the specified device.
199 // |device|: An open device to make the transfer on. 245 // |handle|: An device handle to make the transfer on.
200 // |transferInfo|: The paramters to the transfer. See GenericTransferInfo. 246 // |transferInfo|: The paramters to the transfer. See GenericTransferInfo.
201 // |callback|: Invoked once the transfer has completed. 247 // |callback|: Invoked once the transfer has completed.
202 static void interruptTransfer(Device device, 248 static void interruptTransfer(DeviceHandle handle,
203 GenericTransferInfo transferInfo, TransferCallback callback); 249 GenericTransferInfo transferInfo, TransferCallback callback);
204 250
205 // Performs an isochronous transfer on the specific device. 251 // Performs an isochronous transfer on the specific device.
206 // |device|: An open device to make the transfer on. 252 // |handle|: An device handle to make the transfer on.
207 // |transferInfo|: The parameters to the transfer. See 253 // |transferInfo|: The parameters to the transfer. See
208 // IsochronousTransferInfo. 254 // IsochronousTransferInfo.
209 // |callback|: Invoked once the transfer has been completed. 255 // |callback|: Invoked once the transfer has been completed.
210 static void isochronousTransfer(Device device, 256 static void isochronousTransfer(DeviceHandle handle,
211 IsochronousTransferInfo transferInfo, 257 IsochronousTransferInfo transferInfo,
212 TransferCallback callback); 258 TransferCallback callback);
213 259
214 // Try to reset the USB device and restore the previous status. 260 // Try to reset the USB device and restore the previous status.
215 // 261 //
216 // If the reset fails, the given device will be closed and the USB device 262 // If the reset fails, the given device will be closed and the USB device
217 // will appear to be disconected and reconnected. 263 // will appear to be disconected and reconnected.
218 // You must call <code>findDevice</code> again to acquire the device. 264 // You must call <code>findDevice</code> again to acquire the device.
219 // 265 //
220 // |device|: An opened device to reset. 266 // |handle|: An device handle to reset.
221 // |callback|: Invoked once the device is reset with a boolean indicating 267 // |callback|: Invoked once the device is reset with a boolean indicating
222 // whether the reset is completed successfully. 268 // whether the reset is completed successfully.
223 static void resetDevice(Device device, 269 static void resetDevice(DeviceHandle handle,
224 ResetDeviceCallback callback); 270 ResetDeviceCallback callback);
225 }; 271 };
226 }; 272 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698