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 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 RequestTypeReserved | |
|
Reilly Grant (use Gerrit)
2015/07/28 22:51:43
Since this is a reserved value we shouldn't have a
Ken Rockot(use gerrit already)
2015/07/28 23:21:39
Done.
| |
| 41 }; | |
| 42 | |
| 43 enum RequestRecipient { | |
| 44 RequestRecipientDevice, | |
| 45 RequestRecipientInterface, | |
| 46 RequestRecipientEndpoint, | |
| 47 RequestRecipientOther, | |
| 48 }; | |
| 49 | |
| 50 struct ControlTransferParameters { | |
| 51 TransferDirection direction; | |
| 52 RequestType type; | |
| 53 RequestRecipient recipient; | |
| 54 uint8_t request; | |
| 55 uint16_t value; | |
| 56 uint16_t index; | |
| 57 }; | |
| 58 | |
| 59 virtual ~WebUSBDevice() { } | |
| 60 | |
| 61 virtual const WebUSBDeviceInfo& info() const = 0; | |
| 62 | |
| 63 // Opens the device. | |
| 64 // Ownership of the WebUSBDeviceOpenCallbacks is transferred to the client. | |
| 65 virtual void open(WebUSBDeviceOpenCallbacks*) = 0; | |
| 66 | |
| 67 // Closes the device. | |
| 68 // Ownership of the WebUSBDeviceCloseCallbacks is transferred to the client. | |
| 69 virtual void close(WebUSBDeviceCloseCallbacks*) = 0; | |
| 70 | |
| 71 // Sets the active configuration for the device. | |
| 72 // Ownership of the WebUSBDeviceSetConfigurationCallbacks is transferred to the client. | |
| 73 virtual void setConfiguration(uint8_t configurationValue, WebUSBDeviceSetCon figurationCallbacks*) = 0; | |
| 74 | |
| 75 // Claims an interface in the active configuration. | |
| 76 // Ownership of the WebUSBDeviceClaimInterfaceCallbacks is transferred to th e client. | |
| 77 virtual void claimInterface(uint8_t interfaceNumber, WebUSBDeviceClaimInterf aceCallbacks*) = 0; | |
| 78 | |
| 79 // Releases a claimed interface. | |
| 80 // Ownership of the WebUSBDeviceReleaseInterfaceCallbacks is transferred to the client. | |
| 81 virtual void releaseInterface(uint8_t interfaceNumber, WebUSBDeviceReleaseIn terfaceCallbacks*) = 0; | |
| 82 | |
| 83 // Sets the alternate setting of an interface. | |
| 84 // Ownership of the WebUSBDeviceSetInterfaceAlternateSettingCallbacks is tra nsferred to the client. | |
| 85 virtual void setInterface(uint8_t interfaceNumber, uint8_t alternateSetting, WebUSBDeviceSetInterfaceAlternateSettingCallbacks*) = 0; | |
| 86 | |
| 87 // Clears the halt condition on a specific endpoint. | |
| 88 // Ownership of the WebUSBDeviceClearHaltCallbacks is transferred to the cli ent. | |
| 89 virtual void clearHalt(uint8_t endpointNumber, WebUSBDeviceClearHaltCallback s*) = 0; | |
| 90 | |
| 91 // Initiates a control transfer. | |
| 92 // Ownership of the WebUSBDeviceControlTransferCallbacks is transferred to t he client. | |
| 93 virtual void controlTransfer(const ControlTransferParameters&, uint8_t* data , size_t dataSize, unsigned timeout, WebUSBDeviceControlTransferCallbacks*) = 0; | |
| 94 | |
| 95 // Initiates a bulk or interrupt transfer. | |
| 96 // Ownership of the WebUSBDeviceBulkTransferCallbacks is transferred to the client. | |
| 97 virtual void transfer(TransferDirection, uint8_t endpointNumber, uint8_t* da ta, size_t dataSize, unsigned timeout, WebUSBDeviceBulkTransferCallbacks*) = 0; | |
| 98 | |
| 99 // Resets the device. | |
| 100 // Ownership of the WebUSBDeviceResetCallbacks is transferred to the client. | |
| 101 virtual void reset(WebUSBDeviceResetCallbacks*) = 0; | |
| 102 }; | |
| 103 | |
| 104 } // namespace blink | |
| 105 | |
| 106 #endif // WebUSBDevice_h | |
| OLD | NEW |