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 #include "modules/webusb/USBDevice.h" | 5 #include "modules/webusb/USBDevice.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "bindings/core/v8/ToV8.h" | 10 #include "bindings/core/v8/ToV8.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 class IsochronousInputTransferResult { | 209 class IsochronousInputTransferResult { |
210 WTF_MAKE_NONCOPYABLE(IsochronousInputTransferResult); | 210 WTF_MAKE_NONCOPYABLE(IsochronousInputTransferResult); |
211 | 211 |
212 public: | 212 public: |
213 using WebType = OwnPtr<WebUSBTransferInfo>; | 213 using WebType = OwnPtr<WebUSBTransferInfo>; |
214 | 214 |
215 static USBIsochronousInTransferResult* take(ScriptPromiseResolver*, PassOwnP
tr<WebUSBTransferInfo> webTransferInfo) | 215 static USBIsochronousInTransferResult* take(ScriptPromiseResolver*, PassOwnP
tr<WebUSBTransferInfo> webTransferInfo) |
216 { | 216 { |
217 ASSERT(webTransferInfo->status.size() == webTransferInfo->packetLength.s
ize() && webTransferInfo->packetLength.size() == webTransferInfo->bytesTransferr
ed.size()); | 217 ASSERT(webTransferInfo->status.size() == webTransferInfo->packetLength.s
ize() && webTransferInfo->packetLength.size() == webTransferInfo->bytesTransferr
ed.size()); |
218 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::create(webTransferInfo->
data.data(), webTransferInfo->data.size()); | 218 DOMArrayBuffer* buffer = DOMArrayBuffer::create(webTransferInfo->data.da
ta(), webTransferInfo->data.size()); |
219 HeapVector<Member<USBIsochronousInTransferPacket>> packets(webTransferIn
fo->status.size()); | 219 HeapVector<Member<USBIsochronousInTransferPacket>> packets(webTransferIn
fo->status.size()); |
220 size_t byteOffset = 0; | 220 size_t byteOffset = 0; |
221 for (size_t i = 0; i < webTransferInfo->status.size(); ++i) { | 221 for (size_t i = 0; i < webTransferInfo->status.size(); ++i) { |
222 packets[i] = USBIsochronousInTransferPacket::create(convertTransferS
tatus(webTransferInfo->status[i]), DOMDataView::create(buffer, byteOffset, webTr
ansferInfo->bytesTransferred[i])); | 222 packets[i] = USBIsochronousInTransferPacket::create(convertTransferS
tatus(webTransferInfo->status[i]), DOMDataView::create(buffer, byteOffset, webTr
ansferInfo->bytesTransferred[i])); |
223 byteOffset += webTransferInfo->packetLength[i]; | 223 byteOffset += webTransferInfo->packetLength[i]; |
224 } | 224 } |
225 return USBIsochronousInTransferResult::create(buffer, packets); | 225 return USBIsochronousInTransferResult::create(buffer, packets); |
226 } | 226 } |
227 }; | 227 }; |
228 | 228 |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 continue; // Ignore endpoints with invalid indices. | 741 continue; // Ignore endpoints with invalid indices. |
742 auto& bitVector = endpoint.direction == WebUSBDevice::TransferDirection:
:In ? m_inEndpoints : m_outEndpoints; | 742 auto& bitVector = endpoint.direction == WebUSBDevice::TransferDirection:
:In ? m_inEndpoints : m_outEndpoints; |
743 if (set) | 743 if (set) |
744 bitVector.set(endpoint.endpointNumber - 1); | 744 bitVector.set(endpoint.endpointNumber - 1); |
745 else | 745 else |
746 bitVector.clear(endpoint.endpointNumber - 1); | 746 bitVector.clear(endpoint.endpointNumber - 1); |
747 } | 747 } |
748 } | 748 } |
749 | 749 |
750 } // namespace blink | 750 } // namespace blink |
OLD | NEW |