Chromium Code Reviews| Index: Source/core/xml/XMLHttpRequest.cpp |
| diff --git a/Source/core/xml/XMLHttpRequest.cpp b/Source/core/xml/XMLHttpRequest.cpp |
| index cc6d559f71327a67760ae612ff3a9361b804d8c8..459a3a81b735c721f697002ccfce9b73baa47f2e 100644 |
| --- a/Source/core/xml/XMLHttpRequest.cpp |
| +++ b/Source/core/xml/XMLHttpRequest.cpp |
| @@ -23,12 +23,7 @@ |
| #include "config.h" |
| #include "core/xml/XMLHttpRequest.h" |
| -#include <wtf/ArrayBuffer.h> |
| -#include <wtf/ArrayBufferView.h> |
| -#include <wtf/RefCountedLeakCounter.h> |
| -#include <wtf/StdLibExtras.h> |
| -#include <wtf/text/CString.h> |
| -#include <wtf/UnusedParam.h> |
| +#include "RuntimeEnabledFeatures.h" |
| #include "core/dom/ContextFeatures.h" |
| #include "core/dom/DOMImplementation.h" |
| #include "core/dom/Event.h" |
| @@ -39,6 +34,7 @@ |
| #include "core/editing/markup.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" |
| @@ -58,6 +54,12 @@ |
| #include "core/xml/XMLHttpRequestProgressEvent.h" |
| #include "core/xml/XMLHttpRequestUpload.h" |
| #include "weborigin/SecurityOrigin.h" |
| +#include "wtf/ArrayBuffer.h" |
| +#include "wtf/ArrayBufferView.h" |
| +#include "wtf/RefCountedLeakCounter.h" |
| +#include "wtf/StdLibExtras.h" |
| +#include "wtf/UnusedParam.h" |
| +#include "wtf/text/CString.h" |
| namespace WebCore { |
| @@ -313,6 +315,19 @@ ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionCode& ec) |
| return m_responseArrayBuffer.get(); |
| } |
| +Stream* XMLHttpRequest::responseStream(ExceptionCode& ec) |
| +{ |
| + if (m_responseTypeCode != ResponseTypeStream) { |
| + ec = InvalidStateError; |
| + return 0; |
| + } |
| + |
| + if (m_error || (m_state != LOADING && m_state != DONE)) |
| + return 0; |
| + |
| + return m_responseStream.get(); |
| +} |
| + |
| void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec) |
| { |
| // FIXME: Need to trigger or update the timeout Timer here, if needed. http://webkit.org/b/98156 |
| @@ -352,6 +367,8 @@ void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode& |
| m_responseTypeCode = ResponseTypeBlob; |
| else if (responseType == "arraybuffer") |
| m_responseTypeCode = ResponseTypeArrayBuffer; |
| + else if (RuntimeEnabledFeatures::streamEnabled() && responseType == "stream") |
| + m_responseTypeCode = ResponseTypeStream; |
| else |
| ASSERT_NOT_REACHED(); |
|
abarth-chromium
2013/07/09 17:58:21
Can this ASSERT be reached if RuntimeEnabledFeatur
tyoshino (SeeGerritForStatus)
2013/07/09 19:48:22
Oh, right. As I added "stream" to the enum in the
|
| } |
| @@ -369,6 +386,8 @@ String XMLHttpRequest::responseType() |
| return "blob"; |
| case ResponseTypeArrayBuffer: |
| return "arraybuffer"; |
| + case ResponseTypeStream: |
| + return "stream"; |
| } |
| return ""; |
|
abarth-chromium
2013/07/09 17:58:21
Can you wrap all these strings in ASCIILiteral(..)
tyoshino (SeeGerritForStatus)
2013/07/09 19:48:22
Done.
|
| } |
| @@ -1086,6 +1105,9 @@ void XMLHttpRequest::didFinishLoading(unsigned long identifier, double) |
| InspectorInstrumentation::didFinishXHRLoading(scriptExecutionContext(), this, identifier, m_responseText, m_url, m_lastSendURL, m_lastSendLineNumber); |
| + if (m_responseStream) |
| + m_responseStream->finalize(); |
| + |
| bool hadLoader = m_loader; |
| m_loader = 0; |
| @@ -1162,6 +1184,10 @@ void XMLHttpRequest::didReceiveData(const char* data, int len) |
| 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) { |