Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 #ifndef WebUSBDevice_h | |
| 6 #define WebUSBDevice_h | |
| 7 | |
| 8 #include "public/platform/WebCallbacks.h" | |
| 9 #include "public/platform/WebVector.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 struct WebUSBDeviceInfo; | |
| 14 struct WebUSBError; | |
| 15 struct WebUSBTransferInfo; | |
| 16 | |
| 17 using WebUSBDeviceOpenCallbacks = WebCallbacks<void, WebUSBError*>; | |
| 18 using WebUSBDeviceCloseCallbacks = WebCallbacks<void, WebUSBError*>; | |
| 19 using WebUSBDeviceSetConfigurationCallbacks = WebCallbacks<void, WebUSBError*>; | |
| 20 using WebUSBDeviceClaimInterfaceCallbacks = WebCallbacks<void, WebUSBError*>; | |
| 21 using WebUSBDeviceReleaseInterfaceCallbacks = WebCallbacks<void, WebUSBError*>; | |
| 22 using WebUSBDeviceResetCallbacks = WebCallbacks<void, WebUSBError*>; | |
| 23 using WebUSBDeviceSetInterfaceAlternateSettingCallbacks = WebCallbacks<void, Web USBError*>; | |
| 24 using WebUSBDeviceClearHaltCallbacks = WebCallbacks<void, WebUSBError*>; | |
| 25 using WebUSBDeviceControlTransferCallbacks = WebCallbacks<WebUSBTransferInfo*, W ebUSBError*>; | |
| 26 using WebUSBDeviceBulkTransferCallbacks = WebCallbacks<WebUSBTransferInfo*, WebU SBError*>; | |
| 27 using WebUSBDeviceInterruptTransferCallbacks = WebCallbacks<WebUSBTransferInfo*, WebUSBError*>; | |
| 28 | |
| 29 class WebUSBDevice { | |
| 30 public: | |
| 31 enum TransferDirection { | |
|
dcheng
2015/07/31 18:58:25
enum class
Ken Rockot(use gerrit already)
2015/07/31 19:14:28
Done.
| |
| 32 TransferDirectionIn, | |
| 33 TransferDirectionOut | |
| 34 }; | |
| 35 | |
| 36 enum RequestType { | |
|
dcheng
2015/07/31 18:58:24
enum class
Ken Rockot(use gerrit already)
2015/07/31 19:14:28
Done.
| |
| 37 RequestTypeStandard, | |
|
dcheng
2015/07/31 18:58:24
Then you can just call this "Standard", "Class", "
Ken Rockot(use gerrit already)
2015/07/31 19:14:28
Done.
| |
| 38 RequestTypeClass, | |
| 39 RequestTypeVendor, | |
| 40 }; | |
| 41 | |
| 42 enum RequestRecipient { | |
|
dcheng
2015/07/31 18:58:24
enum class
Ken Rockot(use gerrit already)
2015/07/31 19:14:28
Done.
| |
| 43 RequestRecipientDevice, | |
| 44 RequestRecipientInterface, | |
| 45 RequestRecipientEndpoint, | |
| 46 RequestRecipientOther, | |
| 47 }; | |
| 48 | |
| 49 struct ControlTransferParameters { | |
| 50 TransferDirection direction; | |
| 51 RequestType type; | |
| 52 RequestRecipient recipient; | |
| 53 uint8_t request; | |
| 54 uint16_t value; | |
| 55 uint16_t index; | |
| 56 }; | |
| 57 | |
| 58 virtual ~WebUSBDevice() { } | |
| 59 | |
| 60 virtual const WebUSBDeviceInfo& info() const = 0; | |
| 61 | |
| 62 // Opens the device. | |
| 63 // Ownership of the WebUSBDeviceOpenCallbacks is transferred to the client. | |
| 64 virtual void open(WebUSBDeviceOpenCallbacks*) = 0; | |
| 65 | |
| 66 // Closes the device. | |
| 67 // Ownership of the WebUSBDeviceCloseCallbacks is transferred to the client. | |
| 68 virtual void close(WebUSBDeviceCloseCallbacks*) = 0; | |
| 69 | |
| 70 // Sets the active configuration for the device. | |
| 71 // Ownership of the WebUSBDeviceSetConfigurationCallbacks is transferred to the client. | |
| 72 virtual void setConfiguration(uint8_t configurationValue, WebUSBDeviceSetCon figurationCallbacks*) = 0; | |
| 73 | |
| 74 // Claims an interface in the active configuration. | |
| 75 // Ownership of the WebUSBDeviceClaimInterfaceCallbacks is transferred to th e client. | |
| 76 virtual void claimInterface(uint8_t interfaceNumber, WebUSBDeviceClaimInterf aceCallbacks*) = 0; | |
| 77 | |
| 78 // Releases a claimed interface. | |
| 79 // Ownership of the WebUSBDeviceReleaseInterfaceCallbacks is transferred to the client. | |
| 80 virtual void releaseInterface(uint8_t interfaceNumber, WebUSBDeviceReleaseIn terfaceCallbacks*) = 0; | |
| 81 | |
| 82 // Sets the alternate setting of an interface. | |
| 83 // Ownership of the WebUSBDeviceSetInterfaceAlternateSettingCallbacks is tra nsferred to the client. | |
| 84 virtual void setInterface(uint8_t interfaceNumber, uint8_t alternateSetting, WebUSBDeviceSetInterfaceAlternateSettingCallbacks*) = 0; | |
| 85 | |
| 86 // Clears the halt condition on a specific endpoint. | |
| 87 // Ownership of the WebUSBDeviceClearHaltCallbacks is transferred to the cli ent. | |
| 88 virtual void clearHalt(uint8_t endpointNumber, WebUSBDeviceClearHaltCallback s*) = 0; | |
| 89 | |
| 90 // Initiates a control transfer. | |
| 91 // Ownership of the WebUSBDeviceControlTransferCallbacks is transferred to t he client. | |
| 92 virtual void controlTransfer(const ControlTransferParameters&, uint8_t* data , size_t dataSize, unsigned timeout, WebUSBDeviceControlTransferCallbacks*) = 0; | |
| 93 | |
| 94 // Initiates a bulk or interrupt transfer. | |
| 95 // Ownership of the WebUSBDeviceBulkTransferCallbacks is transferred to the client. | |
| 96 virtual void transfer(TransferDirection, uint8_t endpointNumber, uint8_t* da ta, size_t dataSize, unsigned timeout, WebUSBDeviceBulkTransferCallbacks*) = 0; | |
| 97 | |
| 98 // Resets the device. | |
| 99 // Ownership of the WebUSBDeviceResetCallbacks is transferred to the client. | |
| 100 virtual void reset(WebUSBDeviceResetCallbacks*) = 0; | |
| 101 }; | |
| 102 | |
| 103 } // namespace blink | |
| 104 | |
| 105 #endif // WebUSBDevice_h | |
| OLD | NEW |