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

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

Issue 12471013: Add chrome.usb.listInterfaces API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase of PS10 Created 7 years, 7 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 and RequestType all map to their namesakes within the 7 // Direction, Recipient, RequestType, and TransferType all map to their
8 // 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};
13
14 // For isochronous mode, SynchronizationType and UsageType map to their
15 // namesakes within the USB specification.
16 enum SynchronizationType {asynchronous, adaptive, synchronous};
17 enum UsageType {data, feedback, explicitFeedback};
12 18
13 // A Device encapsulates everything that is needed to communicate with a USB 19 // A Device encapsulates everything that is needed to communicate with a USB
14 // device. They are returned by findDevice calls and have all of their 20 // device. They are returned by findDevice calls and have all of their
15 // fields populated before being returned. 21 // fields populated before being returned.
16 dictionary Device { 22 dictionary Device {
17 long handle; 23 long handle;
18 long vendorId; 24 long vendorId;
19 long productId; 25 long productId;
20 }; 26 };
21 27
28 dictionary EndpointDescriptor {
29 long address;
30 TransferType type;
31 Direction direction;
32 long maximumPacketSize;
33
34 // Used for isochronous mode.
35 SynchronizationType? synchronization;
36 UsageType? usage;
37
38 // If this is an interrupt endpoint, this will be 1-255
39 long? pollingInterval;
40 };
41
42 dictionary InterfaceDescriptor {
43 long interfaceNumber;
44 long alternateSetting;
45 long interfaceClass;
46 long interfaceSubclass;
47 long interfaceProtocol;
48 DOMString? description;
49 EndpointDescriptor[] endpoints;
50 };
51
22 // ControlTransferInfo represents that parameters to a single USB control 52 // ControlTransferInfo represents that parameters to a single USB control
23 // transfer. 53 // transfer.
24 dictionary ControlTransferInfo { 54 dictionary ControlTransferInfo {
25 // The direction of this transfer. 55 // The direction of this transfer.
26 Direction direction; 56 Direction direction;
27 57
28 // The intended recipient for this transfer. 58 // The intended recipient for this transfer.
29 Recipient recipient; 59 Recipient recipient;
30 60
31 // The type of this request. 61 // The type of this request.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 120
91 // FindDevicesOptions describes the properties of devices which are found and 121 // FindDevicesOptions describes the properties of devices which are found and
92 // opened via findDevices. 122 // opened via findDevices.
93 dictionary FindDevicesOptions { 123 dictionary FindDevicesOptions {
94 long vendorId; 124 long vendorId;
95 long productId; 125 long productId;
96 }; 126 };
97 127
98 callback VoidCallback = void (); 128 callback VoidCallback = void ();
99 callback FindDevicesCallback = void (Device[] device); 129 callback FindDevicesCallback = void (Device[] device);
130 callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors);
100 callback CloseDeviceCallback = void (); 131 callback CloseDeviceCallback = void ();
101 callback TransferCallback = void (TransferResultInfo info); 132 callback TransferCallback = void (TransferResultInfo info);
102 callback ResetDeviceCallback = void(boolean result); 133 callback ResetDeviceCallback = void(boolean result);
103 134
104 interface Functions { 135 interface Functions {
105 // Finds the first instance of the USB device specified by the vendorId/ 136 // Finds the first instance of the USB device specified by the vendorId/
106 // productId pair and, if permissions allow, opens it for use. 137 // productId pair and, if permissions allow, opens it for use.
107 // Upon successfully opening a device the callback is invoked with a 138 // Upon successfully opening a device the callback is invoked with a
108 // populated Device object. On failure, the callback is invoked with null. 139 // populated Device object. On failure, the callback is invoked with null.
109 // |options|: The properties to search for on target devices. 140 // |options|: The properties to search for on target devices.
110 // |callback|: Invoked with the opened Device on success. 141 // |callback|: Invoked with the opened Device on success.
111 static void findDevices(FindDevicesOptions options, 142 static void findDevices(FindDevicesOptions options,
112 FindDevicesCallback callback); 143 FindDevicesCallback callback);
113 144
114 // Closes an open device instance. Invoking operations on a device after it 145 // Closes an open device instance. Invoking operations on a device after it
115 // has been closed is a safe operation, but causes no action to be taken. 146 // has been closed is a safe operation, but causes no action to be taken.
116 // |device|: The device to close. 147 // |device|: The device to close.
117 // |callback|: The callback to invoke once the device is closed. 148 // |callback|: The callback to invoke once the device is closed.
118 static void closeDevice(Device device, 149 static void closeDevice(Device device,
119 optional CloseDeviceCallback callback); 150 optional CloseDeviceCallback callback);
120 151
152 // Lists all the interfaces on the USB device.
153 // |device|: The device from which the interfaces should be listed.
154 // |callback|: The callback to invoke when the interfaces are enumerated.
155 static void listInterfaces(Device device,
156 ListInterfacesCallback callback);
157
121 // Claims an interface on the specified USB device. 158 // Claims an interface on the specified USB device.
122 // |device|: The device on which the interface is to be claimed. 159 // |device|: The device on which the interface is to be claimed.
123 // |interface|: The interface number to be claimed. 160 // |interface|: The interface number to be claimed.
124 // |callback|: The callback to invoke once the interface is claimed. 161 // |callback|: The callback to invoke once the interface is claimed.
125 static void claimInterface(Device device, long interfaceNumber, 162 static void claimInterface(Device device, long interfaceNumber,
126 VoidCallback callback); 163 VoidCallback callback);
127 164
128 // Releases a claim to an interface on the provided device. 165 // Releases a claim to an interface on the provided device.
129 // |device|: The device on which the interface is to be released. 166 // |device|: The device on which the interface is to be released.
130 // |interface|: The interface number to be released. 167 // |interface|: The interface number to be released.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // will appear to be disconected and reconnected. 216 // will appear to be disconected and reconnected.
180 // You must call <code>findDevice</code> again to acquire the device. 217 // You must call <code>findDevice</code> again to acquire the device.
181 // 218 //
182 // |device|: An opened device to reset. 219 // |device|: An opened device to reset.
183 // |callback|: Invoked once the device is reset with a boolean indicating 220 // |callback|: Invoked once the device is reset with a boolean indicating
184 // whether the reset is completed successfully. 221 // whether the reset is completed successfully.
185 static void resetDevice(Device device, 222 static void resetDevice(Device device,
186 ResetDeviceCallback callback); 223 ResetDeviceCallback callback);
187 }; 224 };
188 }; 225 };
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/data/extensions/api_test/usb/list_interfaces/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698