| 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/WebPassOwnPtr.h" | |
| 10 #include "public/platform/WebVector.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 struct WebUSBDeviceInfo; | |
| 15 struct WebUSBError; | |
| 16 struct WebUSBTransferInfo; | |
| 17 | |
| 18 using WebUSBDeviceOpenCallbacks = WebCallbacks<void, const WebUSBError&>; | |
| 19 using WebUSBDeviceCloseCallbacks = WebCallbacks<void, const WebUSBError&>; | |
| 20 using WebUSBDeviceSetConfigurationCallbacks = WebCallbacks<void, const WebUSBErr
or&>; | |
| 21 using WebUSBDeviceClaimInterfaceCallbacks = WebCallbacks<void, const WebUSBError
&>; | |
| 22 using WebUSBDeviceReleaseInterfaceCallbacks = WebCallbacks<void, const WebUSBErr
or&>; | |
| 23 using WebUSBDeviceResetCallbacks = WebCallbacks<void, const WebUSBError&>; | |
| 24 using WebUSBDeviceSetInterfaceAlternateSettingCallbacks = WebCallbacks<void, con
st WebUSBError&>; | |
| 25 using WebUSBDeviceClearHaltCallbacks = WebCallbacks<void, const WebUSBError&>; | |
| 26 using WebUSBDeviceTransferCallbacks = WebCallbacks<WebPassOwnPtr<WebUSBTransferI
nfo>, const WebUSBError&>; | |
| 27 | |
| 28 class WebUSBDevice { | |
| 29 public: | |
| 30 enum class TransferDirection { | |
| 31 In, | |
| 32 Out, | |
| 33 }; | |
| 34 | |
| 35 enum class RequestType { | |
| 36 Standard, | |
| 37 Class, | |
| 38 Vendor, | |
| 39 }; | |
| 40 | |
| 41 enum class RequestRecipient { | |
| 42 Device, | |
| 43 Interface, | |
| 44 Endpoint, | |
| 45 Other, | |
| 46 }; | |
| 47 | |
| 48 struct ControlTransferParameters { | |
| 49 TransferDirection direction; | |
| 50 RequestType type; | |
| 51 RequestRecipient recipient; | |
| 52 uint8_t request; | |
| 53 uint16_t value; | |
| 54 uint16_t index; | |
| 55 }; | |
| 56 | |
| 57 virtual ~WebUSBDevice() { } | |
| 58 | |
| 59 virtual const WebUSBDeviceInfo& info() const = 0; | |
| 60 | |
| 61 // Opens the device. | |
| 62 // Ownership of the WebUSBDeviceOpenCallbacks is transferred to the client. | |
| 63 virtual void open(WebUSBDeviceOpenCallbacks*) = 0; | |
| 64 | |
| 65 // Closes the device. | |
| 66 // Ownership of the WebUSBDeviceCloseCallbacks is transferred to the client. | |
| 67 virtual void close(WebUSBDeviceCloseCallbacks*) = 0; | |
| 68 | |
| 69 // Sets the active configuration for the device. | |
| 70 // Ownership of the WebUSBDeviceSetConfigurationCallbacks is transferred to
the client. | |
| 71 virtual void setConfiguration(uint8_t configurationValue, WebUSBDeviceSetCon
figurationCallbacks*) = 0; | |
| 72 | |
| 73 // Claims an interface in the active configuration. | |
| 74 // Ownership of the WebUSBDeviceClaimInterfaceCallbacks is transferred to th
e client. | |
| 75 virtual void claimInterface(uint8_t interfaceNumber, WebUSBDeviceClaimInterf
aceCallbacks*) = 0; | |
| 76 | |
| 77 // Releases a claimed interface. | |
| 78 // Ownership of the WebUSBDeviceReleaseInterfaceCallbacks is transferred to
the client. | |
| 79 virtual void releaseInterface(uint8_t interfaceNumber, WebUSBDeviceReleaseIn
terfaceCallbacks*) = 0; | |
| 80 | |
| 81 // Sets the alternate setting of an interface. | |
| 82 // Ownership of the WebUSBDeviceSetInterfaceAlternateSettingCallbacks is tra
nsferred to the client. | |
| 83 virtual void setInterface(uint8_t interfaceNumber, uint8_t alternateSetting,
WebUSBDeviceSetInterfaceAlternateSettingCallbacks*) = 0; | |
| 84 | |
| 85 // Clears the halt condition on a specific endpoint. | |
| 86 // Ownership of the WebUSBDeviceClearHaltCallbacks is transferred to the cli
ent. | |
| 87 virtual void clearHalt(uint8_t endpointNumber, WebUSBDeviceClearHaltCallback
s*) = 0; | |
| 88 | |
| 89 // Initiates a control transfer. | |
| 90 // Ownership of the WebUSBDeviceTransferCallbacks is transferred to the clie
nt. | |
| 91 virtual void controlTransfer(const ControlTransferParameters&, uint8_t* data
, size_t dataSize, unsigned timeout, WebUSBDeviceTransferCallbacks*) = 0; | |
| 92 | |
| 93 // Initiates a bulk or interrupt transfer. | |
| 94 // Ownership of the WebUSBDeviceTransferCallbacks is transferred to the clie
nt. | |
| 95 virtual void transfer(TransferDirection, uint8_t endpointNumber, uint8_t* da
ta, size_t dataSize, unsigned timeout, WebUSBDeviceTransferCallbacks*) = 0; | |
| 96 | |
| 97 // Initiates an isochronous transfer. | |
| 98 // Ownership of the WebUSBDeviceTransferCallbacks is transferred to the clie
nt. | |
| 99 virtual void isochronousTransfer(TransferDirection, uint8_t endpointNumber,
uint8_t* data, size_t dataSize, WebVector<unsigned> packetLengths, unsigned time
out, WebUSBDeviceTransferCallbacks*) = 0; | |
| 100 | |
| 101 // Resets the device. | |
| 102 // Ownership of the WebUSBDeviceResetCallbacks is transferred to the client. | |
| 103 virtual void reset(WebUSBDeviceResetCallbacks*) = 0; | |
| 104 }; | |
| 105 | |
| 106 } // namespace blink | |
| 107 | |
| 108 #endif // WebUSBDevice_h | |
| OLD | NEW |