| 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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 m_error = false; | 744 m_error = false; |
| 745 | 745 |
| 746 if (m_async) { | 746 if (m_async) { |
| 747 if (m_upload) | 747 if (m_upload) |
| 748 request.setReportUploadProgress(true); | 748 request.setReportUploadProgress(true); |
| 749 | 749 |
| 750 // ThreadableLoader::create can return null here, for example if we're n
o longer attached to a page. | 750 // ThreadableLoader::create can return null here, for example if we're n
o longer attached to a page. |
| 751 // This is true while running onunload handlers. | 751 // This is true while running onunload handlers. |
| 752 // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload
, <http://bugs.webkit.org/show_bug.cgi?id=10904>. | 752 // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload
, <http://bugs.webkit.org/show_bug.cgi?id=10904>. |
| 753 // FIXME: Maybe create() can return null for other reasons too? | 753 // FIXME: Maybe create() can return null for other reasons too? |
| 754 ASSERT(!m_loader); | |
| 755 m_loader = ThreadableLoader::create(scriptExecutionContext(), this, requ
est, options); | 754 m_loader = ThreadableLoader::create(scriptExecutionContext(), this, requ
est, options); |
| 756 if (m_loader) { | 755 if (m_loader) { |
| 757 // Neither this object nor the JavaScript wrapper should be deleted
while | 756 // Neither this object nor the JavaScript wrapper should be deleted
while |
| 758 // a request is in progress because we need to keep the listeners al
ive, | 757 // a request is in progress because we need to keep the listeners al
ive, |
| 759 // and they are referenced by the JavaScript wrapper. | 758 // and they are referenced by the JavaScript wrapper. |
| 760 | |
| 761 // m_loader was null, so there should be no pending activity at this
point. | |
| 762 ASSERT(!hasPendingActivity()); | |
| 763 setPendingActivity(this); | 759 setPendingActivity(this); |
| 764 } | 760 } |
| 765 } else { | 761 } else { |
| 766 request.setPriority(ResourceLoadPriorityVeryHigh); | 762 request.setPriority(ResourceLoadPriorityVeryHigh); |
| 767 InspectorInstrumentation::willLoadXHRSynchronously(scriptExecutionContex
t()); | 763 InspectorInstrumentation::willLoadXHRSynchronously(scriptExecutionContex
t()); |
| 768 ThreadableLoader::loadResourceSynchronously(scriptExecutionContext(), re
quest, *this, options); | 764 ThreadableLoader::loadResourceSynchronously(scriptExecutionContext(), re
quest, *this, options); |
| 769 InspectorInstrumentation::didLoadXHRSynchronously(scriptExecutionContext
()); | 765 InspectorInstrumentation::didLoadXHRSynchronously(scriptExecutionContext
()); |
| 770 } | 766 } |
| 771 | 767 |
| 772 if (!m_exceptionCode && m_error) | 768 if (!m_exceptionCode && m_error) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 798 } | 794 } |
| 799 | 795 |
| 800 m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent:
:create(eventNames().abortEvent)); | 796 m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent:
:create(eventNames().abortEvent)); |
| 801 if (!m_uploadComplete) { | 797 if (!m_uploadComplete) { |
| 802 m_uploadComplete = true; | 798 m_uploadComplete = true; |
| 803 if (m_upload && m_uploadEventsAllowed) | 799 if (m_upload && m_uploadEventsAllowed) |
| 804 m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::creat
e(eventNames().abortEvent)); | 800 m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::creat
e(eventNames().abortEvent)); |
| 805 } | 801 } |
| 806 } | 802 } |
| 807 | 803 |
| 808 void XMLHttpRequest::internalAbort(DropProtection async) | 804 void XMLHttpRequest::internalAbort() |
| 809 { | 805 { |
| 810 bool hadLoader = m_loader; | 806 bool hadLoader = m_loader; |
| 811 | 807 |
| 812 m_error = true; | 808 m_error = true; |
| 813 | 809 |
| 814 // FIXME: when we add the support for multi-part XHR, we will have to think
be careful with this initialization. | 810 // FIXME: when we add the support for multi-part XHR, we will have to think
be careful with this initialization. |
| 815 m_receivedLength = 0; | 811 m_receivedLength = 0; |
| 816 | 812 |
| 817 if (hadLoader) { | 813 if (hadLoader) { |
| 818 m_loader->cancel(); | 814 m_loader->cancel(); |
| 819 m_loader = 0; | 815 m_loader = 0; |
| 820 } | 816 } |
| 821 | 817 |
| 822 m_decoder = 0; | 818 m_decoder = 0; |
| 823 | 819 |
| 824 InspectorInstrumentation::didFailXHRLoading(scriptExecutionContext(), this); | 820 InspectorInstrumentation::didFailXHRLoading(scriptExecutionContext(), this); |
| 825 | 821 |
| 826 if (hadLoader) { | 822 if (hadLoader) |
| 827 if (async == DropProtectionAsync) | 823 dropProtectionSoon(); |
| 828 dropProtectionSoon(); | |
| 829 else | |
| 830 dropProtection(); | |
| 831 } | |
| 832 } | 824 } |
| 833 | 825 |
| 834 void XMLHttpRequest::clearResponse() | 826 void XMLHttpRequest::clearResponse() |
| 835 { | 827 { |
| 836 m_response = ResourceResponse(); | 828 m_response = ResourceResponse(); |
| 837 clearResponseBuffers(); | 829 clearResponseBuffers(); |
| 838 } | 830 } |
| 839 | 831 |
| 840 void XMLHttpRequest::clearResponseBuffers() | 832 void XMLHttpRequest::clearResponseBuffers() |
| 841 { | 833 { |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 m_progressEventThrottle.suspend(); | 1215 m_progressEventThrottle.suspend(); |
| 1224 } | 1216 } |
| 1225 | 1217 |
| 1226 void XMLHttpRequest::resume() | 1218 void XMLHttpRequest::resume() |
| 1227 { | 1219 { |
| 1228 m_progressEventThrottle.resume(); | 1220 m_progressEventThrottle.resume(); |
| 1229 } | 1221 } |
| 1230 | 1222 |
| 1231 void XMLHttpRequest::stop() | 1223 void XMLHttpRequest::stop() |
| 1232 { | 1224 { |
| 1233 internalAbort(DropProtectionAsync); | 1225 internalAbort(); |
| 1234 } | 1226 } |
| 1235 | 1227 |
| 1236 void XMLHttpRequest::contextDestroyed() | 1228 void XMLHttpRequest::contextDestroyed() |
| 1237 { | 1229 { |
| 1238 ASSERT(!m_loader); | 1230 ASSERT(!m_loader); |
| 1239 ActiveDOMObject::contextDestroyed(); | 1231 ActiveDOMObject::contextDestroyed(); |
| 1240 } | 1232 } |
| 1241 | 1233 |
| 1242 const AtomicString& XMLHttpRequest::interfaceName() const | 1234 const AtomicString& XMLHttpRequest::interfaceName() const |
| 1243 { | 1235 { |
| 1244 return eventNames().interfaceForXMLHttpRequest; | 1236 return eventNames().interfaceForXMLHttpRequest; |
| 1245 } | 1237 } |
| 1246 | 1238 |
| 1247 ScriptExecutionContext* XMLHttpRequest::scriptExecutionContext() const | 1239 ScriptExecutionContext* XMLHttpRequest::scriptExecutionContext() const |
| 1248 { | 1240 { |
| 1249 return ActiveDOMObject::scriptExecutionContext(); | 1241 return ActiveDOMObject::scriptExecutionContext(); |
| 1250 } | 1242 } |
| 1251 | 1243 |
| 1252 EventTargetData* XMLHttpRequest::eventTargetData() | 1244 EventTargetData* XMLHttpRequest::eventTargetData() |
| 1253 { | 1245 { |
| 1254 return &m_eventTargetData; | 1246 return &m_eventTargetData; |
| 1255 } | 1247 } |
| 1256 | 1248 |
| 1257 EventTargetData* XMLHttpRequest::ensureEventTargetData() | 1249 EventTargetData* XMLHttpRequest::ensureEventTargetData() |
| 1258 { | 1250 { |
| 1259 return &m_eventTargetData; | 1251 return &m_eventTargetData; |
| 1260 } | 1252 } |
| 1261 | 1253 |
| 1262 } // namespace WebCore | 1254 } // namespace WebCore |
| OLD | NEW |