| 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/RequestInit.h" | 5 #include "modules/fetch/RequestInit.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
| 8 #include "bindings/core/v8/V8ArrayBuffer.h" | 8 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 9 #include "bindings/core/v8/V8ArrayBufferView.h" | 9 #include "bindings/core/v8/V8ArrayBufferView.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| 11 #include "bindings/core/v8/V8Blob.h" | 11 #include "bindings/core/v8/V8Blob.h" |
| 12 #include "bindings/core/v8/V8FormData.h" | 12 #include "bindings/core/v8/V8FormData.h" |
| 13 #include "bindings/core/v8/V8URLSearchParams.h" | 13 #include "bindings/core/v8/V8URLSearchParams.h" |
| 14 #include "bindings/modules/v8/V8PasswordCredential.h" | 14 #include "bindings/modules/v8/V8PasswordCredential.h" |
| 15 #include "core/dom/URLSearchParams.h" | 15 #include "core/dom/URLSearchParams.h" |
| 16 #include "core/fileapi/Blob.h" | 16 #include "core/fileapi/Blob.h" |
| 17 #include "core/html/FormData.h" | 17 #include "core/html/FormData.h" |
| 18 #include "modules/fetch/FetchBlobDataConsumerHandle.h" | 18 #include "modules/fetch/BlobBytesConsumer.h" |
| 19 #include "modules/fetch/FetchFormDataConsumerHandle.h" | 19 #include "modules/fetch/FormDataBytesConsumer.h" |
| 20 #include "modules/fetch/Headers.h" | 20 #include "modules/fetch/Headers.h" |
| 21 #include "platform/RuntimeEnabledFeatures.h" | 21 #include "platform/RuntimeEnabledFeatures.h" |
| 22 #include "platform/blob/BlobData.h" | 22 #include "platform/blob/BlobData.h" |
| 23 #include "platform/network/EncodedFormData.h" | 23 #include "platform/network/EncodedFormData.h" |
| 24 #include "platform/weborigin/ReferrerPolicy.h" | 24 #include "platform/weborigin/ReferrerPolicy.h" |
| 25 | 25 |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 RequestInit::RequestInit(ExecutionContext* context, const Dictionary& options, E
xceptionState& exceptionState) | 28 RequestInit::RequestInit(ExecutionContext* context, const Dictionary& options, E
xceptionState& exceptionState) |
| 29 : areAnyMembersSet(false) | 29 : areAnyMembersSet(false) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 credentials = "password"; | 103 credentials = "password"; |
| 104 } else if (v8Credential->IsString()) { | 104 } else if (v8Credential->IsString()) { |
| 105 credentials = toUSVString(isolate, v8Credential, exceptionState); | 105 credentials = toUSVString(isolate, v8Credential, exceptionState); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 if (attachedCredential.get() || !isBodySet || v8Body->IsUndefined() || v8Bod
y->IsNull()) | 109 if (attachedCredential.get() || !isBodySet || v8Body->IsUndefined() || v8Bod
y->IsNull()) |
| 110 return; | 110 return; |
| 111 | 111 |
| 112 if (v8Body->IsArrayBuffer()) { | 112 if (v8Body->IsArrayBuffer()) { |
| 113 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8Body.
As<v8::Object>())); | 113 body = new FormDataBytesConsumer(V8ArrayBuffer::toImpl(v8Body.As<v8::Obj
ect>())); |
| 114 } else if (v8Body->IsArrayBufferView()) { | 114 } else if (v8Body->IsArrayBufferView()) { |
| 115 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8B
ody.As<v8::Object>())); | 115 body = new FormDataBytesConsumer(V8ArrayBufferView::toImpl(v8Body.As<v8:
:Object>())); |
| 116 } else if (V8Blob::hasInstance(v8Body, isolate)) { | 116 } else if (V8Blob::hasInstance(v8Body, isolate)) { |
| 117 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8Body.As<v8::Obj
ect>())->blobDataHandle(); | 117 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8Body.As<v8::Obj
ect>())->blobDataHandle(); |
| 118 contentType = blobDataHandle->type(); | 118 contentType = blobDataHandle->type(); |
| 119 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea
se()); | 119 body = new BlobBytesConsumer(context, blobDataHandle.release()); |
| 120 } else if (V8FormData::hasInstance(v8Body, isolate)) { | 120 } else if (V8FormData::hasInstance(v8Body, isolate)) { |
| 121 RefPtr<EncodedFormData> formData = V8FormData::toImpl(v8Body.As<v8::Obje
ct>())->encodeMultiPartFormData(); | 121 RefPtr<EncodedFormData> formData = V8FormData::toImpl(v8Body.As<v8::Obje
ct>())->encodeMultiPartFormData(); |
| 122 // Here we handle formData->boundary() as a C-style string. See | 122 // Here we handle formData->boundary() as a C-style string. See |
| 123 // FormDataEncoder::generateUniqueBoundaryString. | 123 // FormDataEncoder::generateUniqueBoundaryString. |
| 124 contentType = AtomicString("multipart/form-data; boundary=") + formData-
>boundary().data(); | 124 contentType = AtomicString("multipart/form-data; boundary=") + formData-
>boundary().data(); |
| 125 body = FetchFormDataConsumerHandle::create(context, formData.release()); | 125 body = new FormDataBytesConsumer(context, formData.release()); |
| 126 } else if (V8URLSearchParams::hasInstance(v8Body, isolate)) { | 126 } else if (V8URLSearchParams::hasInstance(v8Body, isolate)) { |
| 127 RefPtr<EncodedFormData> formData = V8URLSearchParams::toImpl(v8Body.As<v
8::Object>())->toEncodedFormData(); | 127 RefPtr<EncodedFormData> formData = V8URLSearchParams::toImpl(v8Body.As<v
8::Object>())->toEncodedFormData(); |
| 128 contentType = AtomicString("application/x-www-form-urlencoded;charset=UT
F-8"); | 128 contentType = AtomicString("application/x-www-form-urlencoded;charset=UT
F-8"); |
| 129 body = FetchFormDataConsumerHandle::create(context, formData.release()); | 129 body = new FormDataBytesConsumer(context, formData.release()); |
| 130 } else if (v8Body->IsString()) { | 130 } else if (v8Body->IsString()) { |
| 131 contentType = "text/plain;charset=UTF-8"; | 131 contentType = "text/plain;charset=UTF-8"; |
| 132 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body,
exceptionState)); | 132 body = new FormDataBytesConsumer(toUSVString(isolate, v8Body, exceptionS
tate)); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace blink | 136 } // namespace blink |
| OLD | NEW |