| 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 "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/V8ArrayBuffer.h" | 10 #include "bindings/core/v8/V8ArrayBuffer.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "modules/fetch/DataConsumerHandleUtil.h" | 22 #include "modules/fetch/DataConsumerHandleUtil.h" |
| 23 #include "modules/fetch/FetchBlobDataConsumerHandle.h" | 23 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
| 24 #include "modules/fetch/FetchFormDataConsumerHandle.h" | 24 #include "modules/fetch/FetchFormDataConsumerHandle.h" |
| 25 #include "modules/fetch/ReadableStreamDataConsumerHandle.h" | 25 #include "modules/fetch/ReadableStreamDataConsumerHandle.h" |
| 26 #include "modules/fetch/ResponseInit.h" | 26 #include "modules/fetch/ResponseInit.h" |
| 27 #include "platform/RuntimeEnabledFeatures.h" | 27 #include "platform/RuntimeEnabledFeatures.h" |
| 28 #include "platform/network/EncodedFormData.h" | 28 #include "platform/network/EncodedFormData.h" |
| 29 #include "platform/network/HTTPHeaderMap.h" | 29 #include "platform/network/HTTPHeaderMap.h" |
| 30 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h" | 30 #include "public/platform/modules/serviceworker/WebServiceWorkerResponse.h" |
| 31 #include "wtf/RefPtr.h" | 31 #include "wtf/RefPtr.h" |
| 32 #include <memory> |
| 32 | 33 |
| 33 namespace blink { | 34 namespace blink { |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 FetchResponseData* createFetchResponseDataFromWebResponse(ScriptState* scriptSta
te, const WebServiceWorkerResponse& webResponse) | 38 FetchResponseData* createFetchResponseDataFromWebResponse(ScriptState* scriptSta
te, const WebServiceWorkerResponse& webResponse) |
| 38 { | 39 { |
| 39 FetchResponseData* response = nullptr; | 40 FetchResponseData* response = nullptr; |
| 40 if (webResponse.status() > 0) | 41 if (webResponse.status() > 0) |
| 41 response = FetchResponseData::create(); | 42 response = FetchResponseData::create(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } else if (V8FormData::hasInstance(body, isolate)) { | 140 } else if (V8FormData::hasInstance(body, isolate)) { |
| 140 RefPtr<EncodedFormData> formData = V8FormData::toImpl(body.As<v8::Object
>())->encodeMultiPartFormData(); | 141 RefPtr<EncodedFormData> formData = V8FormData::toImpl(body.As<v8::Object
>())->encodeMultiPartFormData(); |
| 141 // Here we handle formData->boundary() as a C-style string. See | 142 // Here we handle formData->boundary() as a C-style string. See |
| 142 // FormDataEncoder::generateUniqueBoundaryString. | 143 // FormDataEncoder::generateUniqueBoundaryString. |
| 143 contentType = AtomicString("multipart/form-data; boundary=") + formData-
>boundary().data(); | 144 contentType = AtomicString("multipart/form-data; boundary=") + formData-
>boundary().data(); |
| 144 bodyBuffer = new BodyStreamBuffer(scriptState, FetchFormDataConsumerHand
le::create(executionContext, formData.release())); | 145 bodyBuffer = new BodyStreamBuffer(scriptState, FetchFormDataConsumerHand
le::create(executionContext, formData.release())); |
| 145 } else if (RuntimeEnabledFeatures::responseConstructedWithReadableStreamEnab
led() && ReadableStreamOperations::isReadableStream(scriptState, bodyValue)) { | 146 } else if (RuntimeEnabledFeatures::responseConstructedWithReadableStreamEnab
led() && ReadableStreamOperations::isReadableStream(scriptState, bodyValue)) { |
| 146 if (RuntimeEnabledFeatures::responseBodyWithV8ExtraStreamEnabled()) { | 147 if (RuntimeEnabledFeatures::responseBodyWithV8ExtraStreamEnabled()) { |
| 147 bodyBuffer = new BodyStreamBuffer(scriptState, bodyValue); | 148 bodyBuffer = new BodyStreamBuffer(scriptState, bodyValue); |
| 148 } else { | 149 } else { |
| 149 OwnPtr<FetchDataConsumerHandle> bodyHandle; | 150 std::unique_ptr<FetchDataConsumerHandle> bodyHandle; |
| 150 reader = ReadableStreamOperations::getReader(scriptState, bodyValue,
exceptionState); | 151 reader = ReadableStreamOperations::getReader(scriptState, bodyValue,
exceptionState); |
| 151 if (exceptionState.hadException()) { | 152 if (exceptionState.hadException()) { |
| 152 reader = ScriptValue(); | 153 reader = ScriptValue(); |
| 153 bodyHandle = createFetchDataConsumerHandleFromWebHandle(createUn
expectedErrorDataConsumerHandle()); | 154 bodyHandle = createFetchDataConsumerHandleFromWebHandle(createUn
expectedErrorDataConsumerHandle()); |
| 154 exceptionState.clearException(); | 155 exceptionState.clearException(); |
| 155 } else { | 156 } else { |
| 156 bodyHandle = ReadableStreamDataConsumerHandle::create(scriptStat
e, reader); | 157 bodyHandle = ReadableStreamDataConsumerHandle::create(scriptStat
e, reader); |
| 157 } | 158 } |
| 158 bodyBuffer = new BodyStreamBuffer(scriptState, std::move(bodyHandle)
); | 159 bodyBuffer = new BodyStreamBuffer(scriptState, std::move(bodyHandle)
); |
| 159 } | 160 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 448 } |
| 448 | 449 |
| 449 DEFINE_TRACE(Response) | 450 DEFINE_TRACE(Response) |
| 450 { | 451 { |
| 451 Body::trace(visitor); | 452 Body::trace(visitor); |
| 452 visitor->trace(m_response); | 453 visitor->trace(m_response); |
| 453 visitor->trace(m_headers); | 454 visitor->trace(m_headers); |
| 454 } | 455 } |
| 455 | 456 |
| 456 } // namespace blink | 457 } // namespace blink |
| OLD | NEW |