Changeset 109635 in webkit
- Timestamp:
- Mar 2, 2012 4:57:10 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r109632 r109635 1 2012-03-01 Eric Seidel <eric@webkit.org> 2 3 Chrome 18 fails html5test.com XHR Blob response test 4 https://bugs.webkit.org/show_bug.cgi?id=76760 5 6 Reviewed by Adam Barth. 7 8 * fast/files/script-tests/xhr-response-blob.js: Added. 9 (xhr.onreadystatechange): 10 * fast/files/xhr-response-blob-expected.txt: Added. 11 * fast/files/xhr-response-blob.html: Added. 12 * platform/chromium/fast/files/xhr-response-blob-expected.txt: Added. 13 1 14 2012-03-02 Adam Klein <adamk@chromium.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r109634 r109635 1 2012-03-01 Eric Seidel <eric@webkit.org> 2 3 Chrome 18 fails html5test.com XHR Blob response test 4 https://bugs.webkit.org/show_bug.cgi?id=76760 5 6 Reviewed by Adam Barth. 7 8 Most of the code was already there, this just fixes the FIXME 9 which was causing this feature not to work. Chromium already 10 had this #ifdef enabled, but other ports (at least Mac) do not. 11 12 Test: fast/files/xhr-response-blob.html 13 14 * xml/XMLHttpRequest.cpp: 15 (WebCore::XMLHttpRequest::didFinishLoading): 16 1 17 2012-03-02 Kentaro Hara <haraken@chromium.org> 2 18 -
trunk/Source/WebCore/xml/XMLHttpRequest.cpp
r108506 r109635 24 24 25 25 #include "Blob.h" 26 #include "BlobData.h" 26 27 #include "ContentSecurityPolicy.h" 27 28 #include "CrossOriginAccessControl.h" … … 263 264 264 265 #if ENABLE(XHR_RESPONSE_BLOB) 265 Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) const266 Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) 266 267 { 267 268 if (m_responseTypeCode != ResponseTypeBlob) { … … 269 270 return 0; 270 271 } 272 // We always return null before DONE. 273 if (m_state != DONE) 274 return 0; 275 276 if (!m_responseBlob.get()) { 277 // FIXME: This causes two (or more) unnecessary copies of the data. 278 // Chromium stores blob data in the browser process, so we're pulling the data 279 // from the network only to copy it into the renderer to copy it back to the browser. 280 // Ideally we'd get the blob/file-handle from the ResourceResponse directly 281 // instead of copying the bytes. Embedders who store blob data in the 282 // same process as WebCore would at least to teach BlobData to take 283 // a SharedBuffer, even if they don't get the Blob from the network layer directly. 284 OwnPtr<BlobData> blobData = BlobData::create(); 285 // If we errored out or got no data, we still return a blob, just an empty one. 286 if (m_binaryResponseBuilder.get()) { 287 RefPtr<RawData> rawData = RawData::create(); 288 size_t size = m_binaryResponseBuilder->size(); 289 rawData->mutableData()->append(m_binaryResponseBuilder->data(), size); 290 blobData->appendData(rawData, 0, BlobDataItem::toEndOfFile); 291 blobData->setContentType(responseMIMEType()); // responseMIMEType defaults to text/xml which may be incorrect. 292 m_binaryResponseBuilder.clear(); 293 } 294 m_responseBlob = Blob::create(blobData.release(), m_binaryResponseBuilder.get() ? m_binaryResponseBuilder->size() : 0); 295 } 296 271 297 return m_responseBlob.get(); 272 298 } … … 288 314 } 289 315 290 if (m_responseArrayBuffer.get()) 291 return m_responseArrayBuffer.get(); 292 293 return 0; 316 return m_responseArrayBuffer.get(); 294 317 } 295 318 … … 1034 1057 m_responseBuilder.shrinkToFit(); 1035 1058 1036 #if ENABLE(XHR_RESPONSE_BLOB)1037 // FIXME: Set m_responseBlob to something here in the ResponseTypeBlob case.1038 #endif1039 1040 1059 InspectorInstrumentation::resourceRetrievedByXMLHttpRequest(scriptExecutionContext(), identifier, m_responseBuilder.toStringPreserveCapacity(), m_url, m_lastSendURL, m_lastSendLineNumber); 1041 1060 … … 1107 1126 if (useDecoder) 1108 1127 m_responseBuilder.append(m_decoder->decode(data, len)); 1109 else if (m_responseTypeCode == ResponseTypeArrayBuffer) { 1128 else if (m_responseTypeCode == ResponseTypeArrayBuffer 1129 #if ENABLE(XHR_RESPONSE_BLOB) 1130 || m_responseTypeCode == ResponseTypeBlob 1131 #endif 1132 ) { 1110 1133 // Buffer binary data. 1111 1134 if (!m_binaryResponseBuilder) -
trunk/Source/WebCore/xml/XMLHttpRequest.h
r103502 r109635 107 107 Document* optionalResponseXML() const { return m_responseDocument.get(); } 108 108 #if ENABLE(XHR_RESPONSE_BLOB) 109 Blob* responseBlob(ExceptionCode&) const;109 Blob* responseBlob(ExceptionCode&); 110 110 Blob* optionalResponseBlob() const { return m_responseBlob.get(); } 111 111 #endif
Note: See TracChangeset
for help on using the changeset viewer.