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