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 typedef WebCallbacks<void, WebUSBError*> WebUSBDeviceOpenCallbacks; |
| 18 typedef WebCallbacks<void, WebUSBError*> WebUSBDeviceCloseCallbacks; |
| 19 typedef WebCallbacks<void, WebUSBError*> WebUSBDeviceSetConfigurationCallbacks; |
| 20 typedef WebCallbacks<void, WebUSBError*> WebUSBDeviceClaimInterfaceCallbacks; |
| 21 typedef WebCallbacks<void, WebUSBError*> WebUSBDeviceReleaseInterfaceCallbacks; |
| 22 typedef WebCallbacks<void, WebUSBError*> WebUSBDeviceResetCallbacks; |
| 23 typedef WebCallbacks<void, WebUSBError*> WebUSBDeviceSetInterfaceAlternateSettin
gCallbacks; |
| 24 typedef WebCallbacks<void, WebUSBError*> WebUSBDeviceClearHaltCallbacks; |
| 25 typedef WebCallbacks<WebUSBTransferInfo*, WebUSBError*> WebUSBDeviceControlTrans
ferCallbacks; |
| 26 typedef WebCallbacks<WebUSBTransferInfo*, WebUSBError*> WebUSBDeviceBulkTransfer
Callbacks; |
| 27 typedef WebCallbacks<WebUSBTransferInfo*, WebUSBError*> WebUSBDeviceInterruptTra
nsferCallbacks; |
| 28 |
| 29 class WebUSBDevice { |
| 30 public: |
| 31 enum TransferDirection { |
| 32 TransferDirectionIn, |
| 33 TransferDirectionOut |
| 34 }; |
| 35 |
| 36 enum RequestType { |
| 37 RequestTypeStandard, |
| 38 RequestTypeClass, |
| 39 RequestTypeVendor, |
| 40 }; |
| 41 |
| 42 enum RequestRecipient { |
| 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 |