OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> | 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> |
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> | 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> |
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. |
6 * Copyright (C) 2012 Intel Corporation | 6 * Copyright (C) 2012 Intel Corporation |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
11 * version 2 of the License, or (at your option) any later version. | 11 * version 2 of the License, or (at your option) any later version. |
12 * | 12 * |
13 * This library is distributed in the hope that it will be useful, | 13 * This library is distributed in the hope that it will be useful, |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 * Lesser General Public License for more details. | 16 * Lesser General Public License for more details. |
17 * | 17 * |
18 * You should have received a copy of the GNU Lesser General Public | 18 * You should have received a copy of the GNU Lesser General Public |
19 * License along with this library; if not, write to the Free Software | 19 * License along with this library; if not, write to the Free Software |
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U
SA | 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U
SA |
21 */ | 21 */ |
22 | 22 |
23 #include "config.h" | 23 #include "config.h" |
24 #include "core/xml/XMLHttpRequest.h" | 24 #include "core/xml/XMLHttpRequest.h" |
25 | 25 |
26 #include "bindings/core/v8/ExceptionState.h" | 26 #include "bindings/core/v8/ExceptionState.h" |
27 #include "core/FetchInitiatorTypeNames.h" | 27 #include "core/FetchInitiatorTypeNames.h" |
28 #include "core/dom/ContextFeatures.h" | 28 #include "core/dom/ContextFeatures.h" |
| 29 #include "core/dom/DOMArrayBuffer.h" |
29 #include "core/dom/DOMException.h" | 30 #include "core/dom/DOMException.h" |
30 #include "core/dom/DOMImplementation.h" | 31 #include "core/dom/DOMImplementation.h" |
31 #include "core/dom/DocumentParser.h" | 32 #include "core/dom/DocumentParser.h" |
32 #include "core/dom/ExceptionCode.h" | 33 #include "core/dom/ExceptionCode.h" |
33 #include "core/dom/XMLDocument.h" | 34 #include "core/dom/XMLDocument.h" |
34 #include "core/editing/markup.h" | 35 #include "core/editing/markup.h" |
35 #include "core/events/Event.h" | 36 #include "core/events/Event.h" |
36 #include "core/fetch/FetchUtils.h" | 37 #include "core/fetch/FetchUtils.h" |
37 #include "core/fileapi/Blob.h" | 38 #include "core/fileapi/Blob.h" |
38 #include "core/fileapi/File.h" | 39 #include "core/fileapi/File.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 blobData->setContentType(finalResponseMIMETypeWithFallback()); | 333 blobData->setContentType(finalResponseMIMETypeWithFallback()); |
333 m_binaryResponseBuilder.clear(); | 334 m_binaryResponseBuilder.clear(); |
334 } | 335 } |
335 m_responseBlob = Blob::create(BlobDataHandle::create(blobData.releas
e(), size)); | 336 m_responseBlob = Blob::create(BlobDataHandle::create(blobData.releas
e(), size)); |
336 } | 337 } |
337 } | 338 } |
338 | 339 |
339 return m_responseBlob.get(); | 340 return m_responseBlob.get(); |
340 } | 341 } |
341 | 342 |
342 ArrayBuffer* XMLHttpRequest::responseArrayBuffer() | 343 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer() |
343 { | 344 { |
344 ASSERT(m_responseTypeCode == ResponseTypeArrayBuffer); | 345 ASSERT(m_responseTypeCode == ResponseTypeArrayBuffer); |
345 | 346 |
346 if (m_error || m_state != DONE) | 347 if (m_error || m_state != DONE) |
347 return 0; | 348 return 0; |
348 | 349 |
349 if (!m_responseArrayBuffer) { | 350 if (!m_responseArrayBuffer) { |
350 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) { | 351 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) { |
351 m_responseArrayBuffer = m_binaryResponseBuilder->getAsArrayBuffer(); | 352 m_responseArrayBuffer = DOMArrayBuffer::create(m_binaryResponseBuild
er->getAsArrayBuffer()); |
352 if (!m_responseArrayBuffer) { | 353 if (!m_responseArrayBuffer) { |
353 // m_binaryResponseBuilder failed to allocate an ArrayBuffer. | 354 // m_binaryResponseBuilder failed to allocate an ArrayBuffer. |
354 // We need to crash the renderer since there's no way defined in | 355 // We need to crash the renderer since there's no way defined in |
355 // the spec to tell this to the user. | 356 // the spec to tell this to the user. |
356 CRASH(); | 357 CRASH(); |
357 } | 358 } |
358 m_binaryResponseBuilder.clear(); | 359 m_binaryResponseBuilder.clear(); |
359 } else { | 360 } else { |
360 m_responseArrayBuffer = ArrayBuffer::create(static_cast<void*>(0), 0
); | 361 m_responseArrayBuffer = DOMArrayBuffer::create(static_cast<void*>(0)
, 0); |
361 } | 362 } |
362 } | 363 } |
363 | 364 |
364 return m_responseArrayBuffer.get(); | 365 return m_responseArrayBuffer.get(); |
365 } | 366 } |
366 | 367 |
367 Stream* XMLHttpRequest::responseLegacyStream() | 368 Stream* XMLHttpRequest::responseLegacyStream() |
368 { | 369 { |
369 ASSERT(m_responseTypeCode == ResponseTypeLegacyStream); | 370 ASSERT(m_responseTypeCode == ResponseTypeLegacyStream); |
370 | 371 |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1550 // Buffer binary data. | 1551 // Buffer binary data. |
1551 if (!m_binaryResponseBuilder) | 1552 if (!m_binaryResponseBuilder) |
1552 m_binaryResponseBuilder = SharedBuffer::create(); | 1553 m_binaryResponseBuilder = SharedBuffer::create(); |
1553 m_binaryResponseBuilder->append(data, len); | 1554 m_binaryResponseBuilder->append(data, len); |
1554 } else if (m_responseTypeCode == ResponseTypeLegacyStream) { | 1555 } else if (m_responseTypeCode == ResponseTypeLegacyStream) { |
1555 if (!m_responseLegacyStream) | 1556 if (!m_responseLegacyStream) |
1556 m_responseLegacyStream = Stream::create(executionContext(), response
Type()); | 1557 m_responseLegacyStream = Stream::create(executionContext(), response
Type()); |
1557 m_responseLegacyStream->addData(data, len); | 1558 m_responseLegacyStream->addData(data, len); |
1558 } else if (m_responseTypeCode == ResponseTypeStream) { | 1559 } else if (m_responseTypeCode == ResponseTypeStream) { |
1559 if (!m_responseStream) { | 1560 if (!m_responseStream) { |
1560 m_responseStream = new ReadableStreamImpl<ReadableStreamChunkTypeTra
its<ArrayBuffer> >(executionContext(), new ReadableStreamSource(this)); | 1561 m_responseStream = new ReadableStreamImpl<ReadableStreamChunkTypeTra
its<DOMArrayBuffer> >(executionContext(), new ReadableStreamSource(this)); |
1561 m_responseStream->didSourceStart(); | 1562 m_responseStream->didSourceStart(); |
1562 } | 1563 } |
1563 m_responseStream->enqueue(ArrayBuffer::create(data, len)); | 1564 m_responseStream->enqueue(DOMArrayBuffer::create(data, len)); |
1564 } | 1565 } |
1565 | 1566 |
1566 if (m_blobLoader) { | 1567 if (m_blobLoader) { |
1567 // In this case, the data is provided by m_blobLoader. As progress | 1568 // In this case, the data is provided by m_blobLoader. As progress |
1568 // events are already fired, we should return here. | 1569 // events are already fired, we should return here. |
1569 return; | 1570 return; |
1570 } | 1571 } |
1571 trackProgress(len); | 1572 trackProgress(len); |
1572 } | 1573 } |
1573 | 1574 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 visitor->trace(m_streamSource); | 1659 visitor->trace(m_streamSource); |
1659 visitor->trace(m_responseDocument); | 1660 visitor->trace(m_responseDocument); |
1660 visitor->trace(m_responseDocumentParser); | 1661 visitor->trace(m_responseDocumentParser); |
1661 visitor->trace(m_progressEventThrottle); | 1662 visitor->trace(m_progressEventThrottle); |
1662 visitor->trace(m_upload); | 1663 visitor->trace(m_upload); |
1663 visitor->trace(m_blobLoader); | 1664 visitor->trace(m_blobLoader); |
1664 XMLHttpRequestEventTarget::trace(visitor); | 1665 XMLHttpRequestEventTarget::trace(visitor); |
1665 } | 1666 } |
1666 | 1667 |
1667 } // namespace blink | 1668 } // namespace blink |
OLD | NEW |