Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: third_party/WebKit/Source/core/mojo/MojoHandle.cpp

Issue 2748933003: XMLHttpRequest: return null upon failing responseArrayBuffer allocation. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMArrayBuffer.cpp ('k') | third_party/WebKit/Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698