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