| 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(static_cast<uint8_t*>( | 88 vector.Append( |
| 89 buffer.getAsArrayBufferView().View()->BaseAddress()), | 89 static_cast<uint8_t*>(buffer.getAsArrayBufferView()->BaseAddress()), |
| 90 buffer.getAsArrayBufferView().View()->byteLength()); | 90 buffer.getAsArrayBufferView()->byteLength()); |
| 91 return vector; | 91 return vector; |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace | 94 } // namespace |
| 95 | 95 |
| 96 USBDevice::USBDevice(usb::DeviceInfoPtr device_info, | 96 USBDevice::USBDevice(usb::DeviceInfoPtr device_info, |
| 97 usb::DevicePtr device, | 97 usb::DevicePtr device, |
| 98 ExecutionContext* context) | 98 ExecutionContext* context) |
| 99 : ContextLifecycleObserver(context), | 99 : ContextLifecycleObserver(context), |
| 100 device_info_(std::move(device_info)), | 100 device_info_(std::move(device_info)), |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 | 917 |
| 918 bool USBDevice::MarkRequestComplete(ScriptPromiseResolver* resolver) { | 918 bool USBDevice::MarkRequestComplete(ScriptPromiseResolver* resolver) { |
| 919 auto request_entry = device_requests_.Find(resolver); | 919 auto request_entry = device_requests_.Find(resolver); |
| 920 if (request_entry == device_requests_.end()) | 920 if (request_entry == device_requests_.end()) |
| 921 return false; | 921 return false; |
| 922 device_requests_.erase(request_entry); | 922 device_requests_.erase(request_entry); |
| 923 return true; | 923 return true; |
| 924 } | 924 } |
| 925 | 925 |
| 926 } // namespace blink | 926 } // namespace blink |
| OLD | NEW |