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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 script_state, new FormDataBytesConsumer(array_buffer_view)); | 162 script_state, new FormDataBytesConsumer(array_buffer_view)); |
163 } else if (V8FormData::hasInstance(body, isolate)) { | 163 } else if (V8FormData::hasInstance(body, isolate)) { |
164 RefPtr<EncodedFormData> form_data = | 164 RefPtr<EncodedFormData> form_data = |
165 V8FormData::toImpl(body.As<v8::Object>())->EncodeMultiPartFormData(); | 165 V8FormData::toImpl(body.As<v8::Object>())->EncodeMultiPartFormData(); |
166 // Here we handle formData->boundary() as a C-style string. See | 166 // Here we handle formData->boundary() as a C-style string. See |
167 // FormDataEncoder::generateUniqueBoundaryString. | 167 // FormDataEncoder::generateUniqueBoundaryString. |
168 content_type = AtomicString("multipart/form-data; boundary=") + | 168 content_type = AtomicString("multipart/form-data; boundary=") + |
169 form_data->Boundary().data(); | 169 form_data->Boundary().data(); |
170 body_buffer = new BodyStreamBuffer( | 170 body_buffer = new BodyStreamBuffer( |
171 script_state, | 171 script_state, |
172 new FormDataBytesConsumer(execution_context, form_data.Release())); | 172 new FormDataBytesConsumer(execution_context, std::move(form_data))); |
173 } else if (V8URLSearchParams::hasInstance(body, isolate)) { | 173 } else if (V8URLSearchParams::hasInstance(body, isolate)) { |
174 RefPtr<EncodedFormData> form_data = | 174 RefPtr<EncodedFormData> form_data = |
175 V8URLSearchParams::toImpl(body.As<v8::Object>())->ToEncodedFormData(); | 175 V8URLSearchParams::toImpl(body.As<v8::Object>())->ToEncodedFormData(); |
176 body_buffer = new BodyStreamBuffer( | 176 body_buffer = new BodyStreamBuffer( |
177 script_state, | 177 script_state, |
178 new FormDataBytesConsumer(execution_context, form_data.Release())); | 178 new FormDataBytesConsumer(execution_context, std::move(form_data))); |
179 content_type = "application/x-www-form-urlencoded;charset=UTF-8"; | 179 content_type = "application/x-www-form-urlencoded;charset=UTF-8"; |
180 } else if (ReadableStreamOperations::IsReadableStream(script_state, | 180 } else if (ReadableStreamOperations::IsReadableStream(script_state, |
181 body_value)) { | 181 body_value)) { |
182 UseCounter::Count(execution_context, | 182 UseCounter::Count(execution_context, |
183 UseCounter::kFetchResponseConstructionWithStream); | 183 UseCounter::kFetchResponseConstructionWithStream); |
184 body_buffer = new BodyStreamBuffer(script_state, body_value); | 184 body_buffer = new BodyStreamBuffer(script_state, body_value); |
185 } else { | 185 } else { |
186 String string = ToUSVString(isolate, body, exception_state); | 186 String string = ToUSVString(isolate, body, exception_state); |
187 if (exception_state.HadException()) | 187 if (exception_state.HadException()) |
188 return nullptr; | 188 return nullptr; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 .Set(response.As<v8::Object>(), body_buffer); | 465 .Set(response.As<v8::Object>(), body_buffer); |
466 } | 466 } |
467 | 467 |
468 DEFINE_TRACE(Response) { | 468 DEFINE_TRACE(Response) { |
469 Body::Trace(visitor); | 469 Body::Trace(visitor); |
470 visitor->Trace(response_); | 470 visitor->Trace(response_); |
471 visitor->Trace(headers_); | 471 visitor->Trace(headers_); |
472 } | 472 } |
473 | 473 |
474 } // namespace blink | 474 } // namespace blink |
OLD | NEW |