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 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 DCHECK(!m_loader); | 1087 DCHECK(!m_loader); |
1088 handleRequestError(0, EventTypeNames::abort, receivedLength, | 1088 handleRequestError(0, EventTypeNames::abort, receivedLength, |
1089 expectedLength); | 1089 expectedLength); |
1090 } | 1090 } |
1091 } | 1091 } |
1092 if (m_state == kDone) | 1092 if (m_state == kDone) |
1093 m_state = kUnsent; | 1093 m_state = kUnsent; |
1094 } | 1094 } |
1095 | 1095 |
1096 void XMLHttpRequest::dispose() { | 1096 void XMLHttpRequest::dispose() { |
1097 if (m_loader) { | 1097 contextDestroyed(getExecutionContext()); |
1098 m_error = true; | |
1099 m_loader->cancel(); | |
1100 } | |
1101 } | 1098 } |
1102 | 1099 |
1103 void XMLHttpRequest::clearVariablesForLoading() { | 1100 void XMLHttpRequest::clearVariablesForLoading() { |
1104 if (m_blobLoader) { | 1101 if (m_blobLoader) { |
1105 m_blobLoader->cancel(); | 1102 m_blobLoader->cancel(); |
1106 m_blobLoader = nullptr; | 1103 m_blobLoader = nullptr; |
1107 } | 1104 } |
1108 | 1105 |
1109 m_decoder.reset(); | 1106 m_decoder.reset(); |
1110 | 1107 |
1111 if (m_responseDocumentParser) { | 1108 if (m_responseDocumentParser) { |
1112 m_responseDocumentParser->removeClient(this); | 1109 m_responseDocumentParser->removeClient(this); |
1113 m_responseDocumentParser->detach(); | 1110 m_responseDocumentParser->detach(); |
1114 m_responseDocumentParser = nullptr; | 1111 m_responseDocumentParser = nullptr; |
1115 } | 1112 } |
1116 | 1113 |
1117 m_finalResponseCharset = String(); | 1114 m_finalResponseCharset = String(); |
1118 } | 1115 } |
1119 | 1116 |
1120 bool XMLHttpRequest::internalAbort() { | 1117 bool XMLHttpRequest::internalAbort() { |
| 1118 // Fast path for repeated internalAbort()s; this |
| 1119 // will happen if an XHR object is notified of context |
| 1120 // destruction followed by finalization. |
| 1121 if (m_error && !m_loader) |
| 1122 return true; |
| 1123 |
1121 m_error = true; | 1124 m_error = true; |
1122 | 1125 |
1123 if (m_responseDocumentParser && !m_responseDocumentParser->isStopped()) | 1126 if (m_responseDocumentParser && !m_responseDocumentParser->isStopped()) |
1124 m_responseDocumentParser->stopParsing(); | 1127 m_responseDocumentParser->stopParsing(); |
1125 | 1128 |
1126 clearVariablesForLoading(); | 1129 clearVariablesForLoading(); |
1127 | 1130 |
1128 clearResponse(); | 1131 clearResponse(); |
1129 clearRequest(); | 1132 clearRequest(); |
1130 | 1133 |
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 } | 1803 } |
1801 | 1804 |
1802 void XMLHttpRequest::suspend() { | 1805 void XMLHttpRequest::suspend() { |
1803 m_progressEventThrottle->suspend(); | 1806 m_progressEventThrottle->suspend(); |
1804 } | 1807 } |
1805 | 1808 |
1806 void XMLHttpRequest::resume() { | 1809 void XMLHttpRequest::resume() { |
1807 m_progressEventThrottle->resume(); | 1810 m_progressEventThrottle->resume(); |
1808 } | 1811 } |
1809 | 1812 |
1810 void XMLHttpRequest::contextDestroyed(ExecutionContext*) { | 1813 void XMLHttpRequest::contextDestroyed(ExecutionContext* context) { |
1811 InspectorInstrumentation::didFailXHRLoading(getExecutionContext(), this, this, | 1814 InspectorInstrumentation::detachClientRequest(context, this); |
1812 m_method, m_url); | |
1813 m_progressEventThrottle->stop(); | 1815 m_progressEventThrottle->stop(); |
1814 internalAbort(); | 1816 internalAbort(); |
1815 | 1817 |
1816 // In case we are in the middle of send() function, unset the send flag to | 1818 // In case we are in the middle of send() function, unset the send flag to |
1817 // stop the operation. | 1819 // stop the operation. |
1818 m_sendFlag = false; | 1820 m_sendFlag = false; |
1819 } | 1821 } |
1820 | 1822 |
1821 bool XMLHttpRequest::hasPendingActivity() const { | 1823 bool XMLHttpRequest::hasPendingActivity() const { |
1822 // Neither this object nor the JavaScript wrapper should be deleted while | 1824 // Neither this object nor the JavaScript wrapper should be deleted while |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 visitor->traceWrappers(m_responseDocument); | 1859 visitor->traceWrappers(m_responseDocument); |
1858 visitor->traceWrappers(m_responseArrayBuffer); | 1860 visitor->traceWrappers(m_responseArrayBuffer); |
1859 XMLHttpRequestEventTarget::traceWrappers(visitor); | 1861 XMLHttpRequestEventTarget::traceWrappers(visitor); |
1860 } | 1862 } |
1861 | 1863 |
1862 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { | 1864 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { |
1863 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); | 1865 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); |
1864 } | 1866 } |
1865 | 1867 |
1866 } // namespace blink | 1868 } // namespace blink |
OLD | NEW |