| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef USBDevice_h | 5 #ifndef USBDevice_h |
| 6 #define USBDevice_h | 6 #define USBDevice_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 10 #include "bindings/modules/v8/UnionTypesModules.h" | 10 #include "bindings/modules/v8/UnionTypesModules.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 return new USBDevice(device, context); | 35 return new USBDevice(device, context); |
| 36 } | 36 } |
| 37 | 37 |
| 38 static USBDevice* take(ScriptPromiseResolver*, PassOwnPtr<WebUSBDevice>); | 38 static USBDevice* take(ScriptPromiseResolver*, PassOwnPtr<WebUSBDevice>); |
| 39 | 39 |
| 40 explicit USBDevice(PassOwnPtr<WebUSBDevice> device, ExecutionContext* contex
t) | 40 explicit USBDevice(PassOwnPtr<WebUSBDevice> device, ExecutionContext* contex
t) |
| 41 : ContextLifecycleObserver(context) | 41 : ContextLifecycleObserver(context) |
| 42 , m_device(device) | 42 , m_device(device) |
| 43 , m_opened(false) | 43 , m_opened(false) |
| 44 , m_deviceStateChangeInProgress(false) | 44 , m_deviceStateChangeInProgress(false) |
| 45 , m_activeConfiguration(m_device->info().activeConfiguration) |
| 45 { | 46 { |
| 46 } | 47 } |
| 47 | 48 |
| 48 virtual ~USBDevice() { } | 49 virtual ~USBDevice() { } |
| 49 | 50 |
| 50 const WebUSBDeviceInfo& info() const { return m_device->info(); } | 51 const WebUSBDeviceInfo& info() const { return m_device->info(); } |
| 51 void onDeviceOpenedOrClosed(bool); | 52 void onDeviceOpenedOrClosed(bool); |
| 53 void onConfigurationSelected(bool success, uint8_t configurationValue); |
| 52 | 54 |
| 53 // IDL exposed interface: | 55 // IDL exposed interface: |
| 54 String guid() const { return info().guid; } | 56 String guid() const { return info().guid; } |
| 55 uint8_t usbVersionMajor() { return info().usbVersionMajor; } | 57 uint8_t usbVersionMajor() { return info().usbVersionMajor; } |
| 56 uint8_t usbVersionMinor() { return info().usbVersionMinor; } | 58 uint8_t usbVersionMinor() { return info().usbVersionMinor; } |
| 57 uint8_t usbVersionSubminor() { return info().usbVersionSubminor; } | 59 uint8_t usbVersionSubminor() { return info().usbVersionSubminor; } |
| 58 uint8_t deviceClass() { return info().deviceClass; } | 60 uint8_t deviceClass() { return info().deviceClass; } |
| 59 uint8_t deviceSubclass() const { return info().deviceSubclass; } | 61 uint8_t deviceSubclass() const { return info().deviceSubclass; } |
| 60 uint8_t deviceProtocol() const { return info().deviceProtocol; } | 62 uint8_t deviceProtocol() const { return info().deviceProtocol; } |
| 61 uint16_t vendorId() const { return info().vendorID; } | 63 uint16_t vendorId() const { return info().vendorID; } |
| 62 uint16_t productId() const { return info().productID; } | 64 uint16_t productId() const { return info().productID; } |
| 63 uint8_t deviceVersionMajor() const { return info().deviceVersionMajor; } | 65 uint8_t deviceVersionMajor() const { return info().deviceVersionMajor; } |
| 64 uint8_t deviceVersionMinor() const { return info().deviceVersionMinor; } | 66 uint8_t deviceVersionMinor() const { return info().deviceVersionMinor; } |
| 65 uint8_t deviceVersionSubminor() const { return info().deviceVersionSubminor;
} | 67 uint8_t deviceVersionSubminor() const { return info().deviceVersionSubminor;
} |
| 66 String manufacturerName() const { return info().manufacturerName; } | 68 String manufacturerName() const { return info().manufacturerName; } |
| 67 String productName() const { return info().productName; } | 69 String productName() const { return info().productName; } |
| 68 String serialNumber() const { return info().serialNumber; } | 70 String serialNumber() const { return info().serialNumber; } |
| 71 USBConfiguration* configuration() const; |
| 69 HeapVector<Member<USBConfiguration>> configurations() const; | 72 HeapVector<Member<USBConfiguration>> configurations() const; |
| 70 bool opened() const { return m_opened; } | 73 bool opened() const { return m_opened; } |
| 71 | 74 |
| 72 ScriptPromise open(ScriptState*); | 75 ScriptPromise open(ScriptState*); |
| 73 ScriptPromise close(ScriptState*); | 76 ScriptPromise close(ScriptState*); |
| 74 ScriptPromise getConfiguration(ScriptState*); | 77 ScriptPromise selectConfiguration(ScriptState*, uint8_t configurationValue); |
| 75 ScriptPromise setConfiguration(ScriptState*, uint8_t configurationValue); | |
| 76 ScriptPromise claimInterface(ScriptState*, uint8_t interfaceNumber); | 78 ScriptPromise claimInterface(ScriptState*, uint8_t interfaceNumber); |
| 77 ScriptPromise releaseInterface(ScriptState*, uint8_t interfaceNumber); | 79 ScriptPromise releaseInterface(ScriptState*, uint8_t interfaceNumber); |
| 78 ScriptPromise setInterface(ScriptState*, uint8_t interfaceNumber, uint8_t al
ternateSetting); | 80 ScriptPromise setInterface(ScriptState*, uint8_t interfaceNumber, uint8_t al
ternateSetting); |
| 79 ScriptPromise controlTransferIn(ScriptState*, const USBControlTransferParame
ters& setup, unsigned length); | 81 ScriptPromise controlTransferIn(ScriptState*, const USBControlTransferParame
ters& setup, unsigned length); |
| 80 ScriptPromise controlTransferOut(ScriptState*, const USBControlTransferParam
eters& setup); | 82 ScriptPromise controlTransferOut(ScriptState*, const USBControlTransferParam
eters& setup); |
| 81 ScriptPromise controlTransferOut(ScriptState*, const USBControlTransferParam
eters& setup, const ArrayBufferOrArrayBufferView& data); | 83 ScriptPromise controlTransferOut(ScriptState*, const USBControlTransferParam
eters& setup, const ArrayBufferOrArrayBufferView& data); |
| 82 ScriptPromise clearHalt(ScriptState*, uint8_t endpointNumber); | 84 ScriptPromise clearHalt(ScriptState*, uint8_t endpointNumber); |
| 83 ScriptPromise transferIn(ScriptState*, uint8_t endpointNumber, unsigned leng
th); | 85 ScriptPromise transferIn(ScriptState*, uint8_t endpointNumber, unsigned leng
th); |
| 84 ScriptPromise transferOut(ScriptState*, uint8_t endpointNumber, const ArrayB
ufferOrArrayBufferView& data); | 86 ScriptPromise transferOut(ScriptState*, uint8_t endpointNumber, const ArrayB
ufferOrArrayBufferView& data); |
| 85 ScriptPromise isochronousTransferIn(ScriptState*, uint8_t endpointNumber, Ve
ctor<unsigned> packetLengths); | 87 ScriptPromise isochronousTransferIn(ScriptState*, uint8_t endpointNumber, Ve
ctor<unsigned> packetLengths); |
| 86 ScriptPromise isochronousTransferOut(ScriptState*, uint8_t endpointNumber, c
onst ArrayBufferOrArrayBufferView& data, Vector<unsigned> packetLengths); | 88 ScriptPromise isochronousTransferOut(ScriptState*, uint8_t endpointNumber, c
onst ArrayBufferOrArrayBufferView& data, Vector<unsigned> packetLengths); |
| 87 ScriptPromise reset(ScriptState*); | 89 ScriptPromise reset(ScriptState*); |
| 88 | 90 |
| 89 void contextDestroyed() override; | 91 void contextDestroyed() override; |
| 90 | 92 |
| 91 DECLARE_TRACE(); | 93 DECLARE_TRACE(); |
| 92 | 94 |
| 93 private: | 95 private: |
| 94 OwnPtr<WebUSBDevice> m_device; | 96 OwnPtr<WebUSBDevice> m_device; |
| 95 bool m_opened; | 97 bool m_opened; |
| 96 bool m_deviceStateChangeInProgress; | 98 bool m_deviceStateChangeInProgress; |
| 99 uint8_t m_activeConfiguration; |
| 97 }; | 100 }; |
| 98 | 101 |
| 99 } // namespace blink | 102 } // namespace blink |
| 100 | 103 |
| 101 #endif // USBDevice_h | 104 #endif // USBDevice_h |
| OLD | NEW |