| Index: Source/core/xml/XMLHttpRequest.cpp
|
| diff --git a/Source/core/xml/XMLHttpRequest.cpp b/Source/core/xml/XMLHttpRequest.cpp
|
| index 71627ee6f45e57e2cc2395ef4415db2cb27693a3..402491b01e679dc5a3deee0069fb3726463d41be 100644
|
| --- a/Source/core/xml/XMLHttpRequest.cpp
|
| +++ b/Source/core/xml/XMLHttpRequest.cpp
|
| @@ -24,6 +24,7 @@
|
| #include "core/xml/XMLHttpRequest.h"
|
|
|
| #include "FetchInitiatorTypeNames.h"
|
| +#include "RuntimeEnabledFeatures.h"
|
| #include "bindings/v8/ExceptionMessages.h"
|
| #include "bindings/v8/ExceptionState.h"
|
| #include "core/dom/ContextFeatures.h"
|
| @@ -36,6 +37,7 @@
|
| #include "core/fetch/TextResourceDecoder.h"
|
| #include "core/fileapi/Blob.h"
|
| #include "core/fileapi/File.h"
|
| +#include "core/fileapi/Stream.h"
|
| #include "core/html/DOMFormData.h"
|
| #include "core/html/HTMLDocument.h"
|
| #include "core/inspector/InspectorInstrumentation.h"
|
| @@ -318,6 +320,16 @@ ArrayBuffer* XMLHttpRequest::responseArrayBuffer()
|
| return m_responseArrayBuffer.get();
|
| }
|
|
|
| +Stream* XMLHttpRequest::responseStream()
|
| +{
|
| + ASSERT(m_responseTypeCode == ResponseTypeStream);
|
| +
|
| + if (m_error || (m_state != LOADING && m_state != DONE))
|
| + return 0;
|
| +
|
| + return m_responseStream.get();
|
| +}
|
| +
|
| void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionState& es)
|
| {
|
| // FIXME: Need to trigger or update the timeout Timer here, if needed. http://webkit.org/b/98156
|
| @@ -345,20 +357,26 @@ void XMLHttpRequest::setResponseType(const String& responseType, ExceptionState&
|
| return;
|
| }
|
|
|
| - if (responseType == "")
|
| + if (responseType == "") {
|
| m_responseTypeCode = ResponseTypeDefault;
|
| - else if (responseType == "text")
|
| + } else if (responseType == "text") {
|
| m_responseTypeCode = ResponseTypeText;
|
| - else if (responseType == "json")
|
| + } else if (responseType == "json") {
|
| m_responseTypeCode = ResponseTypeJSON;
|
| - else if (responseType == "document")
|
| + } else if (responseType == "document") {
|
| m_responseTypeCode = ResponseTypeDocument;
|
| - else if (responseType == "blob")
|
| + } else if (responseType == "blob") {
|
| m_responseTypeCode = ResponseTypeBlob;
|
| - else if (responseType == "arraybuffer")
|
| + } else if (responseType == "arraybuffer") {
|
| m_responseTypeCode = ResponseTypeArrayBuffer;
|
| - else
|
| + } else if (responseType == "stream") {
|
| + if (RuntimeEnabledFeatures::streamEnabled())
|
| + m_responseTypeCode = ResponseTypeStream;
|
| + else
|
| + return;
|
| + } else {
|
| ASSERT_NOT_REACHED();
|
| + }
|
| }
|
|
|
| String XMLHttpRequest::responseType()
|
| @@ -376,6 +394,8 @@ String XMLHttpRequest::responseType()
|
| return "blob";
|
| case ResponseTypeArrayBuffer:
|
| return "arraybuffer";
|
| + case ResponseTypeStream:
|
| + return "stream";
|
| }
|
| return "";
|
| }
|
| @@ -825,15 +845,19 @@ void XMLHttpRequest::internalAbort(DropProtection async)
|
|
|
| InspectorInstrumentation::didFailXHRLoading(scriptExecutionContext(), this);
|
|
|
| - if (m_loader) {
|
| - m_loader->cancel();
|
| - m_loader = 0;
|
| + if (m_responseStream && m_state != DONE)
|
| + m_responseStream->abort();
|
|
|
| - if (async == DropProtectionAsync)
|
| - dropProtectionSoon();
|
| - else
|
| - dropProtection();
|
| - }
|
| + if (!m_loader)
|
| + return;
|
| +
|
| + m_loader->cancel();
|
| + m_loader = 0;
|
| +
|
| + if (async == DropProtectionAsync)
|
| + dropProtectionSoon();
|
| + else
|
| + dropProtection();
|
| }
|
|
|
| void XMLHttpRequest::clearResponse()
|
| @@ -849,6 +873,7 @@ void XMLHttpRequest::clearResponseBuffers()
|
| m_createdDocument = false;
|
| m_responseDocument = 0;
|
| m_responseBlob = 0;
|
| + m_responseStream = 0;
|
| m_binaryResponseBuilder.clear();
|
| m_responseArrayBuffer.clear();
|
| }
|
| @@ -1096,6 +1121,9 @@ void XMLHttpRequest::didFinishLoading(unsigned long identifier, double)
|
| if (m_decoder)
|
| m_responseText = m_responseText.concatenateWith(m_decoder->flush());
|
|
|
| + if (m_responseStream)
|
| + m_responseStream->finalize();
|
| +
|
| InspectorInstrumentation::didFinishXHRLoading(scriptExecutionContext(), this, identifier, m_responseText, m_url, m_lastSendURL, m_lastSendLineNumber);
|
|
|
| // Prevent dropProtection releasing the last reference, and retain |this| until the end of this method.
|
| @@ -1172,13 +1200,17 @@ void XMLHttpRequest::didReceiveData(const char* data, int len)
|
| if (len == -1)
|
| len = strlen(data);
|
|
|
| - if (useDecoder)
|
| + if (useDecoder) {
|
| m_responseText = m_responseText.concatenateWith(m_decoder->decode(data, len));
|
| - else if (m_responseTypeCode == ResponseTypeArrayBuffer || m_responseTypeCode == ResponseTypeBlob) {
|
| + } else if (m_responseTypeCode == ResponseTypeArrayBuffer || m_responseTypeCode == ResponseTypeBlob) {
|
| // Buffer binary data.
|
| if (!m_binaryResponseBuilder)
|
| m_binaryResponseBuilder = SharedBuffer::create();
|
| m_binaryResponseBuilder->append(data, len);
|
| + } else if (m_responseTypeCode == ResponseTypeStream) {
|
| + if (!m_responseStream)
|
| + m_responseStream = Stream::create(responseMIMEType());
|
| + m_responseStream->addData(data, len);
|
| }
|
|
|
| if (!m_error) {
|
|
|