| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "core/mojo/MojoHandle.h" | 5 #include "core/mojo/MojoHandle.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ArrayBufferOrArrayBufferView.h" | 7 #include "bindings/core/v8/ArrayBufferOrArrayBufferView.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "core/dom/DOMArrayBuffer.h" | 9 #include "core/dom/DOMArrayBuffer.h" |
| 10 #include "core/dom/DOMArrayBufferView.h" | 10 #include "core/dom/DOMArrayBufferView.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 flags |= MOJO_READ_MESSAGE_FLAG_MAY_DISCARD; | 69 flags |= MOJO_READ_MESSAGE_FLAG_MAY_DISCARD; |
| 70 | 70 |
| 71 uint32_t numBytes = 0, numHandles = 0; | 71 uint32_t numBytes = 0, numHandles = 0; |
| 72 MojoResult result = MojoReadMessage(m_handle->value(), nullptr, &numBytes, | 72 MojoResult result = MojoReadMessage(m_handle->value(), nullptr, &numBytes, |
| 73 nullptr, &numHandles, flags); | 73 nullptr, &numHandles, flags); |
| 74 if (result != MOJO_RESULT_RESOURCE_EXHAUSTED) { | 74 if (result != MOJO_RESULT_RESOURCE_EXHAUSTED) { |
| 75 resultDict.setResult(result); | 75 resultDict.setResult(result); |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 | 78 |
| 79 DOMArrayBuffer* buffer = DOMArrayBuffer::createUninitialized(numBytes, 1); | 79 DOMArrayBuffer* buffer = |
| 80 DOMArrayBuffer::createUninitializedOrNull(numBytes, 1); |
| 81 CHECK(buffer); |
| 80 Vector<::MojoHandle, kHandleVectorInlineCapacity> rawHandles(numHandles); | 82 Vector<::MojoHandle, kHandleVectorInlineCapacity> rawHandles(numHandles); |
| 81 result = MojoReadMessage(m_handle->value(), buffer->data(), &numBytes, | 83 result = MojoReadMessage(m_handle->value(), buffer->data(), &numBytes, |
| 82 rawHandles.data(), &numHandles, flags); | 84 rawHandles.data(), &numHandles, flags); |
| 83 | 85 |
| 84 HeapVector<Member<MojoHandle>> handles(numHandles); | 86 HeapVector<Member<MojoHandle>> handles(numHandles); |
| 85 for (size_t i = 0; i < numHandles; ++i) { | 87 for (size_t i = 0; i < numHandles; ++i) { |
| 86 handles[i] = | 88 handles[i] = |
| 87 MojoHandle::create(mojo::MakeScopedHandle(mojo::Handle(rawHandles[i]))); | 89 MojoHandle::create(mojo::MakeScopedHandle(mojo::Handle(rawHandles[i]))); |
| 88 } | 90 } |
| 89 | 91 |
| 90 resultDict.setResult(result); | 92 resultDict.setResult(result); |
| 91 resultDict.setBuffer(buffer); | 93 resultDict.setBuffer(buffer); |
| 92 resultDict.setHandles(handles); | 94 resultDict.setHandles(handles); |
| 93 } | 95 } |
| 94 | 96 |
| 95 } // namespace blink | 97 } // namespace blink |
| OLD | NEW |