| 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 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 if (!m_responseDocument) | 333 if (!m_responseDocument) |
| 334 return nullptr; | 334 return nullptr; |
| 335 | 335 |
| 336 m_responseDocument->setContent(m_responseText.flattenToString()); | 336 m_responseDocument->setContent(m_responseText.flattenToString()); |
| 337 if (!m_responseDocument->wellFormed()) | 337 if (!m_responseDocument->wellFormed()) |
| 338 m_responseDocument = nullptr; | 338 m_responseDocument = nullptr; |
| 339 | 339 |
| 340 m_parsedResponse = true; | 340 m_parsedResponse = true; |
| 341 } | 341 } |
| 342 | 342 |
| 343 return m_responseDocument.get(); | 343 return m_responseDocument; |
| 344 } | 344 } |
| 345 | 345 |
| 346 Blob* XMLHttpRequest::responseBlob() { | 346 Blob* XMLHttpRequest::responseBlob() { |
| 347 DCHECK_EQ(m_responseTypeCode, ResponseTypeBlob); | 347 DCHECK_EQ(m_responseTypeCode, ResponseTypeBlob); |
| 348 | 348 |
| 349 // We always return null before kDone. | 349 // We always return null before kDone. |
| 350 if (m_error || m_state != kDone) | 350 if (m_error || m_state != kDone) |
| 351 return nullptr; | 351 return nullptr; |
| 352 | 352 |
| 353 if (!m_responseBlob) { | 353 if (!m_responseBlob) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 // the spec to tell this to the user. | 393 // the spec to tell this to the user. |
| 394 CRASH(); | 394 CRASH(); |
| 395 } | 395 } |
| 396 m_responseArrayBuffer = buffer; | 396 m_responseArrayBuffer = buffer; |
| 397 m_binaryResponseBuilder.clear(); | 397 m_binaryResponseBuilder.clear(); |
| 398 } else { | 398 } else { |
| 399 m_responseArrayBuffer = DOMArrayBuffer::create(nullptr, 0); | 399 m_responseArrayBuffer = DOMArrayBuffer::create(nullptr, 0); |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 | 402 |
| 403 return m_responseArrayBuffer.get(); | 403 return m_responseArrayBuffer; |
| 404 } | 404 } |
| 405 | 405 |
| 406 void XMLHttpRequest::setTimeout(unsigned timeout, | 406 void XMLHttpRequest::setTimeout(unsigned timeout, |
| 407 ExceptionState& exceptionState) { | 407 ExceptionState& exceptionState) { |
| 408 // FIXME: Need to trigger or update the timeout Timer here, if needed. | 408 // FIXME: Need to trigger or update the timeout Timer here, if needed. |
| 409 // http://webkit.org/b/98156 | 409 // http://webkit.org/b/98156 |
| 410 // XHR2 spec, 4.7.3. "This implies that the timeout attribute can be set while | 410 // XHR2 spec, 4.7.3. "This implies that the timeout attribute can be set while |
| 411 // fetching is in progress. If that occurs it will still be measured relative | 411 // fetching is in progress. If that occurs it will still be measured relative |
| 412 // to the start of fetching." | 412 // to the start of fetching." |
| 413 if (getExecutionContext() && getExecutionContext()->isDocument() && | 413 if (getExecutionContext() && getExecutionContext()->isDocument() && |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 String XMLHttpRequest::responseURL() { | 489 String XMLHttpRequest::responseURL() { |
| 490 KURL responseURL(m_response.url()); | 490 KURL responseURL(m_response.url()); |
| 491 if (!responseURL.isNull()) | 491 if (!responseURL.isNull()) |
| 492 responseURL.removeFragmentIdentifier(); | 492 responseURL.removeFragmentIdentifier(); |
| 493 return responseURL.getString(); | 493 return responseURL.getString(); |
| 494 } | 494 } |
| 495 | 495 |
| 496 XMLHttpRequestUpload* XMLHttpRequest::upload() { | 496 XMLHttpRequestUpload* XMLHttpRequest::upload() { |
| 497 if (!m_upload) | 497 if (!m_upload) |
| 498 m_upload = XMLHttpRequestUpload::create(this); | 498 m_upload = XMLHttpRequestUpload::create(this); |
| 499 return m_upload.get(); | 499 return m_upload; |
| 500 } | 500 } |
| 501 | 501 |
| 502 void XMLHttpRequest::trackProgress(long long length) { | 502 void XMLHttpRequest::trackProgress(long long length) { |
| 503 m_receivedLength += length; | 503 m_receivedLength += length; |
| 504 | 504 |
| 505 changeState(kLoading); | 505 changeState(kLoading); |
| 506 if (m_async) { | 506 if (m_async) { |
| 507 // readyStateChange event is fired as well. | 507 // readyStateChange event is fired as well. |
| 508 dispatchProgressEventFromSnapshot(EventTypeNames::progress); | 508 dispatchProgressEventFromSnapshot(EventTypeNames::progress); |
| 509 } | 509 } |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 // becomes true by that. We should implement more reliable treatment for | 1084 // becomes true by that. We should implement more reliable treatment for |
| 1085 // nested method invocations at some point. | 1085 // nested method invocations at some point. |
| 1086 if (m_async) { | 1086 if (m_async) { |
| 1087 if ((m_state == kOpened && m_sendFlag) || m_state == kHeadersReceived || | 1087 if ((m_state == kOpened && m_sendFlag) || m_state == kHeadersReceived || |
| 1088 m_state == kLoading) { | 1088 m_state == kLoading) { |
| 1089 DCHECK(!m_loader); | 1089 DCHECK(!m_loader); |
| 1090 handleRequestError(0, EventTypeNames::abort, receivedLength, | 1090 handleRequestError(0, EventTypeNames::abort, receivedLength, |
| 1091 expectedLength); | 1091 expectedLength); |
| 1092 } | 1092 } |
| 1093 } | 1093 } |
| 1094 m_state = kUnsent; | 1094 if (m_state == kDone) |
| 1095 m_state = kUnsent; |
| 1095 } | 1096 } |
| 1096 | 1097 |
| 1097 void XMLHttpRequest::clearVariablesForLoading() { | 1098 void XMLHttpRequest::clearVariablesForLoading() { |
| 1098 if (m_blobLoader) { | 1099 if (m_blobLoader) { |
| 1099 m_blobLoader->cancel(); | 1100 m_blobLoader->cancel(); |
| 1100 m_blobLoader = nullptr; | 1101 m_blobLoader = nullptr; |
| 1101 } | 1102 } |
| 1102 | 1103 |
| 1103 m_decoder.reset(); | 1104 m_decoder.reset(); |
| 1104 | 1105 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1131 // | 1132 // |
| 1132 // If, window.onload contains open() and send(), m_loader will be set to | 1133 // If, window.onload contains open() and send(), m_loader will be set to |
| 1133 // non 0 value. So, we cannot continue the outer open(). In such case, | 1134 // non 0 value. So, we cannot continue the outer open(). In such case, |
| 1134 // just abort the outer open() by returning false. | 1135 // just abort the outer open() by returning false. |
| 1135 ThreadableLoader* loader = m_loader.release(); | 1136 ThreadableLoader* loader = m_loader.release(); |
| 1136 loader->cancel(); | 1137 loader->cancel(); |
| 1137 | 1138 |
| 1138 // If abort() called internalAbort() and a nested open() ended up | 1139 // If abort() called internalAbort() and a nested open() ended up |
| 1139 // clearing the error flag, but didn't send(), make sure the error | 1140 // clearing the error flag, but didn't send(), make sure the error |
| 1140 // flag is still set. | 1141 // flag is still set. |
| 1141 bool newLoadStarted = m_loader.get(); | 1142 bool newLoadStarted = m_loader; |
| 1142 if (!newLoadStarted) | 1143 if (!newLoadStarted) |
| 1143 m_error = true; | 1144 m_error = true; |
| 1144 | 1145 |
| 1145 return !newLoadStarted; | 1146 return !newLoadStarted; |
| 1146 } | 1147 } |
| 1147 | 1148 |
| 1148 void XMLHttpRequest::clearResponse() { | 1149 void XMLHttpRequest::clearResponse() { |
| 1149 // FIXME: when we add the support for multi-part XHR, we will have to | 1150 // FIXME: when we add the support for multi-part XHR, we will have to |
| 1150 // be careful with this initialization. | 1151 // be careful with this initialization. |
| 1151 m_receivedLength = 0; | 1152 m_receivedLength = 0; |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1851 visitor->traceWrappers(m_responseDocument); | 1852 visitor->traceWrappers(m_responseDocument); |
| 1852 visitor->traceWrappers(m_responseArrayBuffer); | 1853 visitor->traceWrappers(m_responseArrayBuffer); |
| 1853 XMLHttpRequestEventTarget::traceWrappers(visitor); | 1854 XMLHttpRequestEventTarget::traceWrappers(visitor); |
| 1854 } | 1855 } |
| 1855 | 1856 |
| 1856 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { | 1857 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { |
| 1857 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); | 1858 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); |
| 1858 } | 1859 } |
| 1859 | 1860 |
| 1860 } // namespace blink | 1861 } // namespace blink |
| OLD | NEW |