| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 flags |= MOJO_READ_MESSAGE_FLAG_MAY_DISCARD; | 72 flags |= MOJO_READ_MESSAGE_FLAG_MAY_DISCARD; |
| 73 | 73 |
| 74 uint32_t numBytes = 0, numHandles = 0; | 74 uint32_t numBytes = 0, numHandles = 0; |
| 75 MojoResult result = MojoReadMessage(m_handle->value(), nullptr, &numBytes, | 75 MojoResult result = MojoReadMessage(m_handle->value(), nullptr, &numBytes, |
| 76 nullptr, &numHandles, flags); | 76 nullptr, &numHandles, flags); |
| 77 if (result != MOJO_RESULT_RESOURCE_EXHAUSTED) { | 77 if (result != MOJO_RESULT_RESOURCE_EXHAUSTED) { |
| 78 resultDict.setResult(result); | 78 resultDict.setResult(result); |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 | 81 |
| 82 DOMArrayBuffer* buffer = DOMArrayBuffer::createUninitialized(numBytes, 1); | 82 DOMArrayBuffer* buffer = |
| 83 DOMArrayBuffer::createUninitializedOrNull(numBytes, 1); |
| 84 CHECK(buffer); |
| 83 Vector<::MojoHandle, kHandleVectorInlineCapacity> rawHandles(numHandles); | 85 Vector<::MojoHandle, kHandleVectorInlineCapacity> rawHandles(numHandles); |
| 84 result = MojoReadMessage(m_handle->value(), buffer->data(), &numBytes, | 86 result = MojoReadMessage(m_handle->value(), buffer->data(), &numBytes, |
| 85 rawHandles.data(), &numHandles, flags); | 87 rawHandles.data(), &numHandles, flags); |
| 86 | 88 |
| 87 HeapVector<Member<MojoHandle>> handles(numHandles); | 89 HeapVector<Member<MojoHandle>> handles(numHandles); |
| 88 for (size_t i = 0; i < numHandles; ++i) { | 90 for (size_t i = 0; i < numHandles; ++i) { |
| 89 handles[i] = | 91 handles[i] = |
| 90 MojoHandle::create(mojo::MakeScopedHandle(mojo::Handle(rawHandles[i]))); | 92 MojoHandle::create(mojo::MakeScopedHandle(mojo::Handle(rawHandles[i]))); |
| 91 } | 93 } |
| 92 | 94 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 mojo::Handle handle; | 126 mojo::Handle handle; |
| 125 MojoResult result = MojoDuplicateBufferHandle(m_handle->value(), &options, | 127 MojoResult result = MojoDuplicateBufferHandle(m_handle->value(), &options, |
| 126 handle.mutable_value()); | 128 handle.mutable_value()); |
| 127 resultDict.setResult(result); | 129 resultDict.setResult(result); |
| 128 if (result == MOJO_RESULT_OK) { | 130 if (result == MOJO_RESULT_OK) { |
| 129 resultDict.setHandle(MojoHandle::create(mojo::MakeScopedHandle(handle))); | 131 resultDict.setHandle(MojoHandle::create(mojo::MakeScopedHandle(handle))); |
| 130 } | 132 } |
| 131 } | 133 } |
| 132 | 134 |
| 133 } // namespace blink | 135 } // namespace blink |
| OLD | NEW |