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/RequestInit.h" | 6 #include "modules/fetch/RequestInit.h" |
7 | 7 |
8 #include "bindings/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
9 #include "bindings/core/v8/V8ArrayBuffer.h" | 9 #include "bindings/core/v8/V8ArrayBuffer.h" |
10 #include "bindings/core/v8/V8ArrayBufferView.h" | 10 #include "bindings/core/v8/V8ArrayBufferView.h" |
11 #include "bindings/core/v8/V8Binding.h" | 11 #include "bindings/core/v8/V8Binding.h" |
12 #include "bindings/core/v8/V8Blob.h" | 12 #include "bindings/core/v8/V8Blob.h" |
13 #include "bindings/core/v8/V8FormData.h" | 13 #include "bindings/core/v8/V8FormData.h" |
14 #include "core/fileapi/Blob.h" | 14 #include "core/fileapi/Blob.h" |
| 15 #include "core/html/DOMFormData.h" |
15 #include "modules/fetch/FetchBlobDataConsumerHandle.h" | 16 #include "modules/fetch/FetchBlobDataConsumerHandle.h" |
16 #include "modules/fetch/FetchFormDataConsumerHandle.h" | 17 #include "modules/fetch/FetchFormDataConsumerHandle.h" |
17 #include "modules/fetch/Headers.h" | 18 #include "modules/fetch/Headers.h" |
18 #include "platform/blob/BlobData.h" | 19 #include "platform/blob/BlobData.h" |
19 #include "platform/network/FormData.h" | 20 #include "platform/network/FormData.h" |
20 | 21 |
21 namespace blink { | 22 namespace blink { |
22 | 23 |
23 RequestInit::RequestInit(ExecutionContext* context, const Dictionary& options, E
xceptionState& exceptionState) | 24 RequestInit::RequestInit(ExecutionContext* context, const Dictionary& options, E
xceptionState& exceptionState) |
24 { | 25 { |
(...skipping 17 matching lines...) Expand all Loading... |
42 v8::Isolate* isolate = toIsolate(context); | 43 v8::Isolate* isolate = toIsolate(context); |
43 if (v8Body->IsArrayBuffer()) { | 44 if (v8Body->IsArrayBuffer()) { |
44 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8::Loc
al<v8::Object>::Cast(v8Body))); | 45 body = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(v8::Loc
al<v8::Object>::Cast(v8Body))); |
45 } else if (v8Body->IsArrayBufferView()) { | 46 } else if (v8Body->IsArrayBufferView()) { |
46 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8:
:Local<v8::Object>::Cast(v8Body))); | 47 body = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(v8:
:Local<v8::Object>::Cast(v8Body))); |
47 } else if (V8Blob::hasInstance(v8Body, isolate)) { | 48 } else if (V8Blob::hasInstance(v8Body, isolate)) { |
48 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj
ect>::Cast(v8Body))->blobDataHandle(); | 49 RefPtr<BlobDataHandle> blobDataHandle = V8Blob::toImpl(v8::Local<v8::Obj
ect>::Cast(v8Body))->blobDataHandle(); |
49 contentType = blobDataHandle->type(); | 50 contentType = blobDataHandle->type(); |
50 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea
se()); | 51 body = FetchBlobDataConsumerHandle::create(context, blobDataHandle.relea
se()); |
51 } else if (V8FormData::hasInstance(v8Body, isolate)) { | 52 } else if (V8FormData::hasInstance(v8Body, isolate)) { |
52 RefPtr<FormData> formData = V8FormData::toImpl(v8::Local<v8::Object>::Ca
st(v8Body))->createMultiPartFormData(); | 53 DOMFormData* domFormData = V8FormData::toImpl(v8::Local<v8::Object>::Cas
t(v8Body)); |
| 54 opaque = domFormData->opaque(); |
| 55 |
| 56 RefPtr<FormData> formData = domFormData->createMultiPartFormData(); |
53 // Here we handle formData->boundary() as a C-style string. See | 57 // Here we handle formData->boundary() as a C-style string. See |
54 // FormDataBuilder::generateUniqueBoundaryString. | 58 // FormDataBuilder::generateUniqueBoundaryString. |
55 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin
g::ConstructFromLiteral) + formData->boundary().data(); | 59 contentType = AtomicString("multipart/form-data; boundary=", AtomicStrin
g::ConstructFromLiteral) + formData->boundary().data(); |
56 body = FetchFormDataConsumerHandle::create(context, formData.release()); | 60 body = FetchFormDataConsumerHandle::create(context, formData.release()); |
57 } else if (v8Body->IsString()) { | 61 } else if (v8Body->IsString()) { |
58 contentType = "text/plain;charset=UTF-8"; | 62 contentType = "text/plain;charset=UTF-8"; |
59 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body,
exceptionState)); | 63 body = FetchFormDataConsumerHandle::create(toUSVString(isolate, v8Body,
exceptionState)); |
60 } | 64 } |
61 } | 65 } |
62 | 66 |
63 } | 67 } |
OLD | NEW |