| 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/fetch/Response.h" | 6 #include "modules/fetch/Response.h" |
| 7 | 7 |
| 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 "core/dom/DOMArrayBuffer.h" | 10 #include "core/dom/DOMArrayBuffer.h" |
| 11 #include "core/dom/DOMArrayBufferView.h" | 11 #include "core/dom/DOMArrayBufferView.h" |
| 12 #include "core/fileapi/Blob.h" | 12 #include "core/fileapi/Blob.h" |
| 13 #include "core/html/DOMFormData.h" | 13 #include "core/html/DOMFormData.h" |
| 14 #include "modules/fetch/BodyStreamBuffer.h" | 14 #include "modules/fetch/BodyStreamBuffer.h" |
| 15 #include "modules/fetch/FetchBlobDataConsumerHandle.h" | 15 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
| 16 #include "modules/fetch/ResponseInit.h" | 16 #include "modules/fetch/ResponseInit.h" |
| 17 #include "platform/network/FormData.h" | 17 #include "platform/network/EncodedFormData.h" |
| 18 #include "platform/network/HTTPHeaderMap.h" | 18 #include "platform/network/HTTPHeaderMap.h" |
| 19 #include "public/platform/WebServiceWorkerResponse.h" | 19 #include "public/platform/WebServiceWorkerResponse.h" |
| 20 #include "wtf/RefPtr.h" | 20 #include "wtf/RefPtr.h" |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 FetchResponseData* createFetchResponseDataFromWebResponse(ExecutionContext* exec
utionContext, const WebServiceWorkerResponse& webResponse) | 26 FetchResponseData* createFetchResponseDataFromWebResponse(ExecutionContext* exec
utionContext, const WebServiceWorkerResponse& webResponse) |
| 27 { | 27 { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 OwnPtr<BlobData> blobData = BlobData::create(); | 126 OwnPtr<BlobData> blobData = BlobData::create(); |
| 127 blobData->appendBytes(arrayBufferView->baseAddress(), arrayBufferView->b
yteLength()); | 127 blobData->appendBytes(arrayBufferView->baseAddress(), arrayBufferView->b
yteLength()); |
| 128 const long long length = blobData->length(); | 128 const long long length = blobData->length(); |
| 129 Blob* blob = Blob::create(BlobDataHandle::create(blobData.release(), len
gth)); | 129 Blob* blob = Blob::create(BlobDataHandle::create(blobData.release(), len
gth)); |
| 130 return create(context, blob, ResponseInit(responseInit, exceptionState),
exceptionState); | 130 return create(context, blob, ResponseInit(responseInit, exceptionState),
exceptionState); |
| 131 } | 131 } |
| 132 if (body.isFormData()) { | 132 if (body.isFormData()) { |
| 133 DOMFormData* domFormData = body.getAsFormData(); | 133 DOMFormData* domFormData = body.getAsFormData(); |
| 134 OwnPtr<BlobData> blobData = BlobData::create(); | 134 OwnPtr<BlobData> blobData = BlobData::create(); |
| 135 // FIXME: the same code exist in RequestInit::RequestInit(). | 135 // FIXME: the same code exist in RequestInit::RequestInit(). |
| 136 RefPtr<FormData> httpBody = domFormData->createMultiPartFormData(); | 136 RefPtr<EncodedFormData> httpBody = domFormData->createMultiPartFormData(
); |
| 137 for (size_t i = 0; i < httpBody->elements().size(); ++i) { | 137 for (size_t i = 0; i < httpBody->elements().size(); ++i) { |
| 138 const FormDataElement& element = httpBody->elements()[i]; | 138 const FormDataElement& element = httpBody->elements()[i]; |
| 139 switch (element.m_type) { | 139 switch (element.m_type) { |
| 140 case FormDataElement::data: { | 140 case FormDataElement::data: { |
| 141 blobData->appendBytes(element.m_data.data(), element.m_data.size
()); | 141 blobData->appendBytes(element.m_data.data(), element.m_data.size
()); |
| 142 break; | 142 break; |
| 143 } | 143 } |
| 144 case FormDataElement::encodedFile: | 144 case FormDataElement::encodedFile: |
| 145 blobData->appendFile(element.m_filename, element.m_fileStart, el
ement.m_fileLength, element.m_expectedFileModificationTime); | 145 blobData->appendFile(element.m_filename, element.m_fileStart, el
ement.m_fileLength, element.m_expectedFileModificationTime); |
| 146 break; | 146 break; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 } | 399 } |
| 400 | 400 |
| 401 DEFINE_TRACE(Response) | 401 DEFINE_TRACE(Response) |
| 402 { | 402 { |
| 403 Body::trace(visitor); | 403 Body::trace(visitor); |
| 404 visitor->trace(m_response); | 404 visitor->trace(m_response); |
| 405 visitor->trace(m_headers); | 405 visitor->trace(m_headers); |
| 406 } | 406 } |
| 407 | 407 |
| 408 } // namespace blink | 408 } // namespace blink |
| OLD | NEW |