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/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
9 #include "bindings/core/v8/ToV8.h" | 9 #include "bindings/core/v8/ToV8.h" |
10 #include "core/dom/DOMArrayBuffer.h" | 10 #include "core/dom/DOMArrayBuffer.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 Vector<uint8_t> convertBufferSource( | 80 Vector<uint8_t> convertBufferSource( |
81 const ArrayBufferOrArrayBufferView& buffer) { | 81 const ArrayBufferOrArrayBufferView& buffer) { |
82 ASSERT(!buffer.isNull()); | 82 ASSERT(!buffer.isNull()); |
83 Vector<uint8_t> vector; | 83 Vector<uint8_t> vector; |
84 if (buffer.isArrayBuffer()) | 84 if (buffer.isArrayBuffer()) |
85 vector.append(static_cast<uint8_t*>(buffer.getAsArrayBuffer()->data()), | 85 vector.append(static_cast<uint8_t*>(buffer.getAsArrayBuffer()->data()), |
86 buffer.getAsArrayBuffer()->byteLength()); | 86 buffer.getAsArrayBuffer()->byteLength()); |
87 else | 87 else |
88 vector.append( | 88 vector.append(static_cast<uint8_t*>( |
89 static_cast<uint8_t*>(buffer.getAsArrayBufferView()->baseAddress()), | 89 buffer.getAsArrayBufferView().view()->baseAddress()), |
90 buffer.getAsArrayBufferView()->byteLength()); | 90 buffer.getAsArrayBufferView().view()->byteLength()); |
91 return vector; | 91 return vector; |
92 } | 92 } |
93 | 93 |
94 } // namespace | 94 } // namespace |
95 | 95 |
96 USBDevice::USBDevice(usb::DeviceInfoPtr deviceInfo, | 96 USBDevice::USBDevice(usb::DeviceInfoPtr deviceInfo, |
97 usb::DevicePtr device, | 97 usb::DevicePtr device, |
98 ExecutionContext* context) | 98 ExecutionContext* context) |
99 : ContextLifecycleObserver(context), | 99 : ContextLifecycleObserver(context), |
100 m_deviceInfo(std::move(deviceInfo)), | 100 m_deviceInfo(std::move(deviceInfo)), |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 | 914 |
915 bool USBDevice::markRequestComplete(ScriptPromiseResolver* resolver) { | 915 bool USBDevice::markRequestComplete(ScriptPromiseResolver* resolver) { |
916 auto requestEntry = m_deviceRequests.find(resolver); | 916 auto requestEntry = m_deviceRequests.find(resolver); |
917 if (requestEntry == m_deviceRequests.end()) | 917 if (requestEntry == m_deviceRequests.end()) |
918 return false; | 918 return false; |
919 m_deviceRequests.erase(requestEntry); | 919 m_deviceRequests.erase(requestEntry); |
920 return true; | 920 return true; |
921 } | 921 } |
922 | 922 |
923 } // namespace blink | 923 } // namespace blink |
OLD | NEW |