Chromium Code Reviews| Index: Source/core/xml/XMLHttpRequest.cpp |
| diff --git a/Source/core/xml/XMLHttpRequest.cpp b/Source/core/xml/XMLHttpRequest.cpp |
| index d16f22ba0461b37a4d880bd87985db36784dcfee..0b0bde0df1e00c6af72b7d587120eb33dad68a50 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/ExceptionState.h" |
| #include "core/dom/ContextFeatures.h" |
| #include "core/dom/DOMImplementation.h" |
| @@ -34,6 +35,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" |
| @@ -313,6 +315,19 @@ ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionState& es) |
| return m_responseArrayBuffer.get(); |
| } |
| +Stream* XMLHttpRequest::responseStream(ExceptionState& es) |
| +{ |
| + if (m_responseTypeCode != ResponseTypeStream) { |
| + es.throwDOMException(InvalidStateError); |
| + return 0; |
| + } |
| + |
| + 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 |
| @@ -342,35 +357,43 @@ 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 == "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() |
| { |
| switch (m_responseTypeCode) { |
| case ResponseTypeDefault: |
| - return ""; |
| + return ASCIILiteral(""); |
| case ResponseTypeText: |
| - return "text"; |
| + return ASCIILiteral("text"); |
| case ResponseTypeDocument: |
| - return "document"; |
| + return ASCIILiteral("document"); |
| case ResponseTypeBlob: |
| - return "blob"; |
| + return ASCIILiteral("blob"); |
| case ResponseTypeArrayBuffer: |
| - return "arraybuffer"; |
| + return ASCIILiteral("arraybuffer"); |
| + case ResponseTypeStream: |
| + return ASCIILiteral("stream"); |
| } |
| - return ""; |
| + return ASCIILiteral(""); |
|
abarth-chromium
2013/08/06 19:35:55
Don't bother adding ASCIILiteral. It's a no-op an
tyoshino (SeeGerritForStatus)
2013/08/23 03:31:45
Done.
|
| } |
| XMLHttpRequestUpload* XMLHttpRequest::upload() |
| @@ -938,7 +961,7 @@ String XMLHttpRequest::getAllResponseHeaders(ExceptionState& es) const |
| { |
| if (m_state < HEADERS_RECEIVED) { |
| es.throwDOMException(InvalidStateError); |
| - return ""; |
| + return ASCIILiteral(""); |
| } |
| StringBuilder stringBuilder; |
| @@ -1086,6 +1109,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; |
| @@ -1163,6 +1189,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); |
|
abarth-chromium
2013/08/06 19:35:55
Do we have to route the data to the render process
|
| } |
| if (!m_error) { |