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 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1561 // Buffer binary data. | 1562 // Buffer binary data. |
1562 if (!m_binaryResponseBuilder) | 1563 if (!m_binaryResponseBuilder) |
1563 m_binaryResponseBuilder = SharedBuffer::create(); | 1564 m_binaryResponseBuilder = SharedBuffer::create(); |
1564 m_binaryResponseBuilder->append(data, len); | 1565 m_binaryResponseBuilder->append(data, len); |
1565 } else if (m_responseTypeCode == ResponseTypeLegacyStream) { | 1566 } else if (m_responseTypeCode == ResponseTypeLegacyStream) { |
1566 if (!m_responseLegacyStream) | 1567 if (!m_responseLegacyStream) |
1567 m_responseLegacyStream = Stream::create(executionContext(), response
Type()); | 1568 m_responseLegacyStream = Stream::create(executionContext(), response
Type()); |
1568 m_responseLegacyStream->addData(data, len); | 1569 m_responseLegacyStream->addData(data, len); |
1569 } else if (m_responseTypeCode == ResponseTypeStream) { | 1570 } else if (m_responseTypeCode == ResponseTypeStream) { |
1570 if (!m_responseStream) { | 1571 if (!m_responseStream) { |
1571 m_responseStream = new ReadableStreamImpl<ReadableStreamChunkTypeTra
its<ArrayBuffer> >(executionContext(), new ReadableStreamSource(this)); | 1572 m_responseStream = new ReadableStreamImpl<ReadableStreamChunkTypeTra
its<DOMArrayBuffer> >(executionContext(), new ReadableStreamSource(this)); |
1572 m_responseStream->didSourceStart(); | 1573 m_responseStream->didSourceStart(); |
1573 } | 1574 } |
1574 m_responseStream->enqueue(ArrayBuffer::create(data, len)); | 1575 m_responseStream->enqueue(DOMArrayBuffer::create(data, len)); |
1575 } | 1576 } |
1576 | 1577 |
1577 if (m_blobLoader) { | 1578 if (m_blobLoader) { |
1578 // In this case, the data is provided by m_blobLoader. As progress | 1579 // In this case, the data is provided by m_blobLoader. As progress |
1579 // events are already fired, we should return here. | 1580 // events are already fired, we should return here. |
1580 return; | 1581 return; |
1581 } | 1582 } |
1582 trackProgress(len); | 1583 trackProgress(len); |
1583 } | 1584 } |
1584 | 1585 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 visitor->trace(m_responseDocument); | 1675 visitor->trace(m_responseDocument); |
1675 visitor->trace(m_responseDocumentParser); | 1676 visitor->trace(m_responseDocumentParser); |
1676 visitor->trace(m_progressEventThrottle); | 1677 visitor->trace(m_progressEventThrottle); |
1677 visitor->trace(m_upload); | 1678 visitor->trace(m_upload); |
1678 visitor->trace(m_blobLoader); | 1679 visitor->trace(m_blobLoader); |
1679 XMLHttpRequestEventTarget::trace(visitor); | 1680 XMLHttpRequestEventTarget::trace(visitor); |
1680 DocumentParserClient::trace(visitor); | 1681 DocumentParserClient::trace(visitor); |
1681 } | 1682 } |
1682 | 1683 |
1683 } // namespace blink | 1684 } // namespace blink |
OLD | NEW |