Chromium Code Reviews| Index: chrome/common/extensions/api/usb.idl |
| diff --git a/chrome/common/extensions/api/usb.idl b/chrome/common/extensions/api/usb.idl |
| index 068f34be5696029a4f8c912f08ec874894e0d1c8..36c2ad9b090b5ef1fd07786c09ab4ba551ad5ffc 100644 |
| --- a/chrome/common/extensions/api/usb.idl |
| +++ b/chrome/common/extensions/api/usb.idl |
| @@ -16,15 +16,22 @@ namespace usb { |
| enum SynchronizationType {asynchronous, adaptive, synchronous}; |
| enum UsageType {data, feedback, explicitFeedback}; |
| - // A Device encapsulates everything that is needed to communicate with a USB |
| - // device. They are returned by findDevice calls and have all of their |
| - // fields populated before being returned. |
| + // A <code>Device</code> uniquely identifies a connected USB device. |
| + // They are returned by <code>findDevices</code> calls and the |
| + // <code>device</code> field remains consistent for the same device. |
| dictionary Device { |
| - long handle; |
| + long device; |
| long vendorId; |
| long productId; |
| }; |
| + // A <code>DeviceHandle</code> encapsulates everything needed to communicate |
| + // with a USB device. |
| + // They are returned by <code>openDevice</code> calls. |
| + dictionary DeviceHandle { |
| + long handle; |
| + }; |
|
asargent_no_longer_on_chrome
2013/06/06 21:57:29
Because this API is now released to stable, we can
|
| + |
| dictionary EndpointDescriptor { |
| long address; |
| TransferType type; |
| @@ -128,86 +135,107 @@ namespace usb { |
| callback VoidCallback = void (); |
| callback FindDevicesCallback = void (Device[] device); |
| + callback OpenDeviceCallback = void (DeviceHandle handle); |
| callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors); |
| callback CloseDeviceCallback = void (); |
| callback TransferCallback = void (TransferResultInfo info); |
| callback ResetDeviceCallback = void(boolean result); |
| interface Functions { |
| - // Finds the first instance of the USB device specified by the vendorId/ |
| - // productId pair and, if permissions allow, opens it for use. |
| - // Upon successfully opening a device the callback is invoked with a |
| - // populated Device object. On failure, the callback is invoked with null. |
| + // Finds all instances of the USB devices specified by the vendorId/ |
| + // productId pair. |
| + // |
| + // Upon successfully enumerate the USB devices, the callback will be called |
| + // with an array of <code>Device</code> dictionaries. |
| + // On failure, the callback is invoked with null. |
| + // |
| // |options|: The properties to search for on target devices. |
| - // |callback|: Invoked with the opened Device on success. |
| + // |callback|: Invoked after the enumeration completes. |
| static void findDevices(FindDevicesOptions options, |
| FindDevicesCallback callback); |
| - // Closes an open device instance. Invoking operations on a device after it |
| - // has been closed is a safe operation, but causes no action to be taken. |
| - // |device|: The device to close. |
| + // Create a <code>DeviceHandle</code> for further operations. |
| + // |
| + // Multiple <code>DeviceHandle</code>s can be created for a same USB Device |
| + // and it is possible to use those handles independently with the device |
| + // support. |
| + // |
| + // Developers are responsible to call <code>closeDevice</code> to close |
| + // the handle, otherwise the device handle will not be closed even if there |
| + // is no reference to the <code>DeviceHandle</code> object. |
| + // |device|: The device to be opened. |
| + // |callback|: Invoked with the created <code>DeviceHandle</code>. |
| + static void openDevice(Device device, |
| + OpenDeviceCallback callback); |
| + |
| + // Closes an device handle. This operation does not effect other handles |
| + // of the same device. |
| + // |handle|: The device handle to close. |
| // |callback|: The callback to invoke once the device is closed. |
| - static void closeDevice(Device device, |
| + static void closeDevice(DeviceHandle handle, |
| optional CloseDeviceCallback callback); |
| // Lists all the interfaces on the USB device. |
| - // |device|: The device from which the interfaces should be listed. |
| + // |handle|: The handle of the device from which the interfaces should be |
| + // listed. |
| // |callback|: The callback to invoke when the interfaces are enumerated. |
| - static void listInterfaces(Device device, |
| + static void listInterfaces(DeviceHandle handle, |
| ListInterfacesCallback callback); |
| // Claims an interface on the specified USB device. |
| // |device|: The device on which the interface is to be claimed. |
| // |interface|: The interface number to be claimed. |
| // |callback|: The callback to invoke once the interface is claimed. |
| - static void claimInterface(Device device, long interfaceNumber, |
| + static void claimInterface(DeviceHandle handle, long interfaceNumber, |
| VoidCallback callback); |
| // Releases a claim to an interface on the provided device. |
| - // |device|: The device on which the interface is to be released. |
| + // |handle|: The handle of the device on which the interface is to be |
| + // released. |
| // |interface|: The interface number to be released. |
| // |callback|: The callback to invoke once the interface is released. |
| - static void releaseInterface(Device device, long interfaceNumber, |
| + static void releaseInterface(DeviceHandle handle, long interfaceNumber, |
| VoidCallback callback); |
| // Selects an alternate setting on a previously claimed interface on a |
| // device. |
| - // |device|: The device on which the interface settings are to be set. |
| + // |handle|: The handle of the device on which the interface settings are |
| + // to be set. |
| // |interface|: The interface number to be set. |
| // |alternateSetting|: The alternate setting to set. |
| // |callback|: The callback to invoke once the interface setting is set. |
| - static void setInterfaceAlternateSetting(Device device, |
| + static void setInterfaceAlternateSetting(DeviceHandle handle, |
| long interfaceNumber, long alternateSetting, VoidCallback callback); |
| // Performs a control transfer on the specified device. See the |
| // ControlTransferInfo structure for the parameters required to make a |
| // transfer. |
| - // |device|: An open device to make the transfer on. |
| + // |handle|: An device handle to make the transfer on. |
| // |transferInfo|: The parameters to the transfer. See ControlTransferInfo. |
| // |callback|: Invoked once the transfer has completed. |
| - static void controlTransfer(Device device, |
| + static void controlTransfer(DeviceHandle handle, |
| ControlTransferInfo transferInfo, TransferCallback callback); |
| // Performs a bulk transfer on the specified device. |
| - // |device|: An open device to make the transfer on. |
| + // |handle|: An device handle to make the transfer on. |
| // |transferInfo|: The paramters to the transfer. See GenericTransferInfo. |
| // |callback|: Invoked once the transfer has completed. |
| - static void bulkTransfer(Device device, GenericTransferInfo transferInfo, |
| + static void bulkTransfer(DeviceHandle handle, GenericTransferInfo transferInfo, |
| TransferCallback callback); |
| // Performs an interrupt transfer on the specified device. |
| - // |device|: An open device to make the transfer on. |
| + // |handle|: An device handle to make the transfer on. |
| // |transferInfo|: The paramters to the transfer. See GenericTransferInfo. |
| // |callback|: Invoked once the transfer has completed. |
| - static void interruptTransfer(Device device, |
| + static void interruptTransfer(DeviceHandle handle, |
| GenericTransferInfo transferInfo, TransferCallback callback); |
| // Performs an isochronous transfer on the specific device. |
| - // |device|: An open device to make the transfer on. |
| + // |handle|: An device handle to make the transfer on. |
| // |transferInfo|: The parameters to the transfer. See |
| // IsochronousTransferInfo. |
| // |callback|: Invoked once the transfer has been completed. |
| - static void isochronousTransfer(Device device, |
| + static void isochronousTransfer(DeviceHandle handle, |
| IsochronousTransferInfo transferInfo, |
| TransferCallback callback); |
| @@ -217,10 +245,10 @@ namespace usb { |
| // will appear to be disconected and reconnected. |
| // You must call <code>findDevice</code> again to acquire the device. |
| // |
| - // |device|: An opened device to reset. |
| + // |handle|: An device handle to reset. |
| // |callback|: Invoked once the device is reset with a boolean indicating |
| // whether the reset is completed successfully. |
| - static void resetDevice(Device device, |
| + static void resetDevice(DeviceHandle handle, |
| ResetDeviceCallback callback); |
| }; |
| }; |