Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |