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

Side by Side Diff: third_party/WebKit/Source/modules/fetch/Response.cpp

Issue 2871143002: BodyStreamBuffer: Avoid calling into V8 during construction (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/fetch/Response.h" 5 #include "modules/fetch/Response.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/Dictionary.h" 8 #include "bindings/core/v8/Dictionary.h"
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/V8ArrayBuffer.h" 10 #include "bindings/core/v8/V8ArrayBuffer.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 if (body_value.IsUndefined() || body_value.IsNull()) { 141 if (body_value.IsUndefined() || body_value.IsNull()) {
142 // Note: The IDL processor cannot handle this situation. See 142 // Note: The IDL processor cannot handle this situation. See
143 // https://crbug.com/335871. 143 // https://crbug.com/335871.
144 } else if (V8Blob::hasInstance(body, isolate)) { 144 } else if (V8Blob::hasInstance(body, isolate)) {
145 Blob* blob = V8Blob::toImpl(body.As<v8::Object>()); 145 Blob* blob = V8Blob::toImpl(body.As<v8::Object>());
146 body_buffer = new BodyStreamBuffer( 146 body_buffer = new BodyStreamBuffer(
147 script_state, 147 script_state,
148 new BlobBytesConsumer(execution_context, blob->GetBlobDataHandle())); 148 new BlobBytesConsumer(execution_context, blob->GetBlobDataHandle()));
149 content_type = blob->type(); 149 content_type = blob->type();
150 } else if (body->IsArrayBuffer()) { 150 } else if (body->IsArrayBuffer()) {
151 // Avoid calling into V8 from the following constructor parameters, which
152 // is potentially unsafe.
153 DOMArrayBuffer* array_buffer = V8ArrayBuffer::toImpl(body.As<v8::Object>());
154 body_buffer = new BodyStreamBuffer(script_state,
155 new FormDataBytesConsumer(array_buffer));
156 } else if (body->IsArrayBufferView()) {
157 // Avoid calling into V8 from the following constructor parameters, which
158 // is potentially unsafe.
159 DOMArrayBufferView* array_buffer_view =
160 V8ArrayBufferView::toImpl(body.As<v8::Object>());
151 body_buffer = new BodyStreamBuffer( 161 body_buffer = new BodyStreamBuffer(
152 script_state, new FormDataBytesConsumer( 162 script_state, new FormDataBytesConsumer(array_buffer_view));
153 V8ArrayBuffer::toImpl(body.As<v8::Object>())));
haraken 2017/05/10 09:05:16 Isn't it guaranteed that V8ArrayBuffer::toImpl(bod
Michael Lippautz 2017/05/10 10:51:25 My C++ foo is not strong enough to answer this by
154 } else if (body->IsArrayBufferView()) {
155 body_buffer = new BodyStreamBuffer(
156 script_state, new FormDataBytesConsumer(
157 V8ArrayBufferView::toImpl(body.As<v8::Object>())));
158 } else if (V8FormData::hasInstance(body, isolate)) { 163 } else if (V8FormData::hasInstance(body, isolate)) {
159 RefPtr<EncodedFormData> form_data = 164 RefPtr<EncodedFormData> form_data =
160 V8FormData::toImpl(body.As<v8::Object>())->EncodeMultiPartFormData(); 165 V8FormData::toImpl(body.As<v8::Object>())->EncodeMultiPartFormData();
161 // Here we handle formData->boundary() as a C-style string. See 166 // Here we handle formData->boundary() as a C-style string. See
162 // FormDataEncoder::generateUniqueBoundaryString. 167 // FormDataEncoder::generateUniqueBoundaryString.
163 content_type = AtomicString("multipart/form-data; boundary=") + 168 content_type = AtomicString("multipart/form-data; boundary=") +
164 form_data->Boundary().data(); 169 form_data->Boundary().data();
165 body_buffer = new BodyStreamBuffer( 170 body_buffer = new BodyStreamBuffer(
166 script_state, 171 script_state,
167 new FormDataBytesConsumer(execution_context, form_data.Release())); 172 new FormDataBytesConsumer(execution_context, form_data.Release()));
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 .Set(response.As<v8::Object>(), body_buffer); 459 .Set(response.As<v8::Object>(), body_buffer);
455 } 460 }
456 461
457 DEFINE_TRACE(Response) { 462 DEFINE_TRACE(Response) {
458 Body::Trace(visitor); 463 Body::Trace(visitor);
459 visitor->Trace(response_); 464 visitor->Trace(response_);
460 visitor->Trace(headers_); 465 visitor->Trace(headers_);
461 } 466 }
462 467
463 } // namespace blink 468 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698