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" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 if (body.isArrayBufferView()) { | 92 if (body.isArrayBufferView()) { |
93 RefPtr<DOMArrayBufferView> arrayBufferView = body.getAsArrayBufferView()
; | 93 RefPtr<DOMArrayBufferView> arrayBufferView = body.getAsArrayBufferView()
; |
94 OwnPtr<BlobData> blobData = BlobData::create(); | 94 OwnPtr<BlobData> blobData = BlobData::create(); |
95 blobData->appendBytes(arrayBufferView->baseAddress(), arrayBufferView->b
yteLength()); | 95 blobData->appendBytes(arrayBufferView->baseAddress(), arrayBufferView->b
yteLength()); |
96 const long long length = blobData->length(); | 96 const long long length = blobData->length(); |
97 Blob* blob = Blob::create(BlobDataHandle::create(blobData.release(), len
gth)); | 97 Blob* blob = Blob::create(BlobDataHandle::create(blobData.release(), len
gth)); |
98 return create(context, blob, ResponseInit(responseInit, exceptionState),
exceptionState); | 98 return create(context, blob, ResponseInit(responseInit, exceptionState),
exceptionState); |
99 } | 99 } |
100 if (body.isFormData()) { | 100 if (body.isFormData()) { |
101 RefPtr<DOMFormData> domFormData = body.getAsFormData(); | 101 RefPtrWillBeRawPtr<DOMFormData> domFormData = body.getAsFormData(); |
102 OwnPtr<BlobData> blobData = BlobData::create(); | 102 OwnPtr<BlobData> blobData = BlobData::create(); |
103 // FIXME: the same code exist in RequestInit::RequestInit(). | 103 // FIXME: the same code exist in RequestInit::RequestInit(). |
104 RefPtr<FormData> httpBody = domFormData->createMultiPartFormData(); | 104 RefPtr<FormData> httpBody = domFormData->createMultiPartFormData(); |
105 for (size_t i = 0; i < httpBody->elements().size(); ++i) { | 105 for (size_t i = 0; i < httpBody->elements().size(); ++i) { |
106 const FormDataElement& element = httpBody->elements()[i]; | 106 const FormDataElement& element = httpBody->elements()[i]; |
107 switch (element.m_type) { | 107 switch (element.m_type) { |
108 case FormDataElement::data: { | 108 case FormDataElement::data: { |
109 blobData->appendBytes(element.m_data.data(), element.m_data.size
()); | 109 blobData->appendBytes(element.m_data.data(), element.m_data.size
()); |
110 break; | 110 break; |
111 } | 111 } |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 356 } |
357 | 357 |
358 void Response::trace(Visitor* visitor) | 358 void Response::trace(Visitor* visitor) |
359 { | 359 { |
360 Body::trace(visitor); | 360 Body::trace(visitor); |
361 visitor->trace(m_response); | 361 visitor->trace(m_response); |
362 visitor->trace(m_headers); | 362 visitor->trace(m_headers); |
363 } | 363 } |
364 | 364 |
365 } // namespace blink | 365 } // namespace blink |
OLD | NEW |