| 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" |
| 11 #include "core/dom/ContextLifecycleObserver.h" | 11 #include "core/dom/ContextLifecycleObserver.h" |
| 12 #include "core/dom/Document.h" |
| 13 #include "core/page/PageLifecycleObserver.h" |
| 12 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
| 13 #include "public/platform/modules/webusb/WebUSBDevice.h" | 15 #include "public/platform/modules/webusb/WebUSBDevice.h" |
| 14 #include "public/platform/modules/webusb/WebUSBDeviceInfo.h" | 16 #include "public/platform/modules/webusb/WebUSBDeviceInfo.h" |
| 15 #include "wtf/BitVector.h" | 17 #include "wtf/BitVector.h" |
| 16 #include "wtf/Vector.h" | 18 #include "wtf/Vector.h" |
| 17 | 19 |
| 18 namespace blink { | 20 namespace blink { |
| 19 | 21 |
| 20 class ScriptPromiseResolver; | 22 class ScriptPromiseResolver; |
| 21 class ScriptState; | 23 class ScriptState; |
| 22 class USBConfiguration; | 24 class USBConfiguration; |
| 23 class USBControlTransferParameters; | 25 class USBControlTransferParameters; |
| 24 | 26 |
| 25 class USBDevice | 27 class USBDevice |
| 26 : public GarbageCollectedFinalized<USBDevice> | 28 : public GarbageCollectedFinalized<USBDevice> |
| 27 , public ContextLifecycleObserver | 29 , public ContextLifecycleObserver |
| 28 , public ScriptWrappable { | 30 , public ScriptWrappable |
| 31 , public PageLifecycleObserver { |
| 29 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(USBDevice); | 32 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(USBDevice); |
| 30 DEFINE_WRAPPERTYPEINFO(); | 33 DEFINE_WRAPPERTYPEINFO(); |
| 31 public: | 34 public: |
| 32 using WebType = OwnPtr<WebUSBDevice>; | 35 using WebType = OwnPtr<WebUSBDevice>; |
| 33 | 36 |
| 34 static USBDevice* create(PassOwnPtr<WebUSBDevice> device, ExecutionContext*
context) | 37 static USBDevice* create(PassOwnPtr<WebUSBDevice> device, ExecutionContext*
context) |
| 35 { | 38 { |
| 36 return new USBDevice(device, context); | 39 return new USBDevice(device, context); |
| 37 } | 40 } |
| 38 | 41 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 ScriptPromise controlTransferIn(ScriptState*, const USBControlTransferParame
ters& setup, unsigned length); | 81 ScriptPromise controlTransferIn(ScriptState*, const USBControlTransferParame
ters& setup, unsigned length); |
| 79 ScriptPromise controlTransferOut(ScriptState*, const USBControlTransferParam
eters& setup); | 82 ScriptPromise controlTransferOut(ScriptState*, const USBControlTransferParam
eters& setup); |
| 80 ScriptPromise controlTransferOut(ScriptState*, const USBControlTransferParam
eters& setup, const ArrayBufferOrArrayBufferView& data); | 83 ScriptPromise controlTransferOut(ScriptState*, const USBControlTransferParam
eters& setup, const ArrayBufferOrArrayBufferView& data); |
| 81 ScriptPromise clearHalt(ScriptState*, String direction, uint8_t endpointNumb
er); | 84 ScriptPromise clearHalt(ScriptState*, String direction, uint8_t endpointNumb
er); |
| 82 ScriptPromise transferIn(ScriptState*, uint8_t endpointNumber, unsigned leng
th); | 85 ScriptPromise transferIn(ScriptState*, uint8_t endpointNumber, unsigned leng
th); |
| 83 ScriptPromise transferOut(ScriptState*, uint8_t endpointNumber, const ArrayB
ufferOrArrayBufferView& data); | 86 ScriptPromise transferOut(ScriptState*, uint8_t endpointNumber, const ArrayB
ufferOrArrayBufferView& data); |
| 84 ScriptPromise isochronousTransferIn(ScriptState*, uint8_t endpointNumber, Ve
ctor<unsigned> packetLengths); | 87 ScriptPromise isochronousTransferIn(ScriptState*, uint8_t endpointNumber, Ve
ctor<unsigned> packetLengths); |
| 85 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); |
| 86 ScriptPromise reset(ScriptState*); | 89 ScriptPromise reset(ScriptState*); |
| 87 | 90 |
| 91 // ContextLifecycleObserver interface. |
| 88 void contextDestroyed() override; | 92 void contextDestroyed() override; |
| 89 | 93 |
| 94 // PageLifecycleObserver interface. |
| 95 void pageVisibilityChanged() override; |
| 96 |
| 90 DECLARE_TRACE(); | 97 DECLARE_TRACE(); |
| 91 | 98 |
| 92 private: | 99 private: |
| 93 int findConfigurationIndex(uint8_t configurationValue) const; | 100 int findConfigurationIndex(uint8_t configurationValue) const; |
| 94 int findInterfaceIndex(uint8_t interfaceNumber) const; | 101 int findInterfaceIndex(uint8_t interfaceNumber) const; |
| 95 int findAlternateIndex(size_t interfaceIndex, uint8_t alternateSetting) cons
t; | 102 int findAlternateIndex(size_t interfaceIndex, uint8_t alternateSetting) cons
t; |
| 103 bool ensurePageVisible(ScriptPromiseResolver*) const; |
| 96 bool ensureNoDeviceOrInterfaceChangeInProgress(ScriptPromiseResolver*) const
; | 104 bool ensureNoDeviceOrInterfaceChangeInProgress(ScriptPromiseResolver*) const
; |
| 97 bool ensureDeviceConfigured(ScriptPromiseResolver*) const; | 105 bool ensureDeviceConfigured(ScriptPromiseResolver*) const; |
| 98 bool ensureInterfaceClaimed(uint8_t interfaceNumber, ScriptPromiseResolver*)
const; | 106 bool ensureInterfaceClaimed(uint8_t interfaceNumber, ScriptPromiseResolver*)
const; |
| 99 bool ensureEndpointAvailable(bool inTransfer, uint8_t endpointNumber, Script
PromiseResolver*) const; | 107 bool ensureEndpointAvailable(bool inTransfer, uint8_t endpointNumber, Script
PromiseResolver*) const; |
| 100 bool anyInterfaceChangeInProgress() const; | 108 bool anyInterfaceChangeInProgress() const; |
| 101 | 109 |
| 102 OwnPtr<WebUSBDevice> m_device; | 110 OwnPtr<WebUSBDevice> m_device; |
| 103 bool m_opened; | 111 bool m_opened; |
| 104 bool m_deviceStateChangeInProgress; | 112 bool m_deviceStateChangeInProgress; |
| 105 int m_configurationIndex; | 113 int m_configurationIndex; |
| 106 WTF::BitVector m_claimedInterfaces; | 114 WTF::BitVector m_claimedInterfaces; |
| 107 WTF::BitVector m_interfaceStateChangeInProgress; | 115 WTF::BitVector m_interfaceStateChangeInProgress; |
| 108 WTF::Vector<size_t> m_selectedAlternates; | 116 WTF::Vector<size_t> m_selectedAlternates; |
| 109 }; | 117 }; |
| 110 | 118 |
| 111 } // namespace blink | 119 } // namespace blink |
| 112 | 120 |
| 113 #endif // USBDevice_h | 121 #endif // USBDevice_h |
| OLD | NEW |