| 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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 // Only GET request is supported for blob URL. | 849 // Only GET request is supported for blob URL. |
| 850 if (m_url.protocolIs("blob") && m_method != HTTPNames::GET) { | 850 if (m_url.protocolIs("blob") && m_method != HTTPNames::GET) { |
| 851 handleNetworkError(); | 851 handleNetworkError(); |
| 852 | 852 |
| 853 if (!m_async) { | 853 if (!m_async) { |
| 854 throwForLoadFailureIfNeeded(exceptionState, "'GET' is the only metho
d allowed for 'blob:' URLs."); | 854 throwForLoadFailureIfNeeded(exceptionState, "'GET' is the only metho
d allowed for 'blob:' URLs."); |
| 855 } | 855 } |
| 856 return; | 856 return; |
| 857 } | 857 } |
| 858 | 858 |
| 859 ASSERT(getExecutionContext()); |
| 860 ExecutionContext& executionContext = *this->getExecutionContext(); |
| 861 |
| 859 // The presence of upload event listeners forces us to use preflighting beca
use POSTing to an URL that does not | 862 // The presence of upload event listeners forces us to use preflighting beca
use POSTing to an URL that does not |
| 860 // permit cross origin requests should look exactly like POSTing to an URL t
hat does not respond at all. | 863 // permit cross origin requests should look exactly like POSTing to an URL t
hat does not respond at all. |
| 861 // Also, only async requests support upload progress events. | 864 // Also, only async requests support upload progress events. |
| 862 bool uploadEvents = false; | 865 bool uploadEvents = false; |
| 863 if (m_async) { | 866 if (m_async) { |
| 867 InspectorInstrumentation::asyncTaskScheduled(&executionContext, "XMLHttp
Request.send", this, true); |
| 864 dispatchProgressEvent(EventTypeNames::loadstart, 0, 0); | 868 dispatchProgressEvent(EventTypeNames::loadstart, 0, 0); |
| 865 if (httpBody && m_upload) { | 869 if (httpBody && m_upload) { |
| 866 uploadEvents = m_upload->hasEventListeners(); | 870 uploadEvents = m_upload->hasEventListeners(); |
| 867 m_upload->dispatchEvent(ProgressEvent::create(EventTypeNames::loadst
art, false, 0, 0)); | 871 m_upload->dispatchEvent(ProgressEvent::create(EventTypeNames::loadst
art, false, 0, 0)); |
| 868 } | 872 } |
| 869 } | 873 } |
| 870 | 874 |
| 871 m_sameOriginRequest = getSecurityOrigin()->canRequestNoSuborigin(m_url); | 875 m_sameOriginRequest = getSecurityOrigin()->canRequestNoSuborigin(m_url); |
| 872 | 876 |
| 873 // We also remember whether upload events should be allowed for this request
in case the upload listeners are | 877 // We also remember whether upload events should be allowed for this request
in case the upload listeners are |
| 874 // added after the request is started. | 878 // added after the request is started. |
| 875 m_uploadEventsAllowed = m_sameOriginRequest || uploadEvents || !FetchUtils::
isSimpleRequest(m_method, m_requestHeaders); | 879 m_uploadEventsAllowed = m_sameOriginRequest || uploadEvents || !FetchUtils::
isSimpleRequest(m_method, m_requestHeaders); |
| 876 | 880 |
| 877 ASSERT(getExecutionContext()); | |
| 878 ExecutionContext& executionContext = *this->getExecutionContext(); | |
| 879 | |
| 880 ResourceRequest request(m_url); | 881 ResourceRequest request(m_url); |
| 881 request.setHTTPMethod(m_method); | 882 request.setHTTPMethod(m_method); |
| 882 request.setRequestContext(WebURLRequest::RequestContextXMLHttpRequest); | 883 request.setRequestContext(WebURLRequest::RequestContextXMLHttpRequest); |
| 883 request.setFetchCredentialsMode(m_includeCredentials ? WebURLRequest::FetchC
redentialsModeInclude : WebURLRequest::FetchCredentialsModeSameOrigin); | 884 request.setFetchCredentialsMode(m_includeCredentials ? WebURLRequest::FetchC
redentialsModeInclude : WebURLRequest::FetchCredentialsModeSameOrigin); |
| 884 request.setSkipServiceWorker(m_isolatedWorldSecurityOrigin); | 885 request.setSkipServiceWorker(m_isolatedWorldSecurityOrigin); |
| 885 request.setExternalRequestStateFromRequestorAddressSpace(executionContext.se
curityContext().addressSpace()); | 886 request.setExternalRequestStateFromRequestorAddressSpace(executionContext.se
curityContext().addressSpace()); |
| 886 | 887 |
| 887 InspectorInstrumentation::willLoadXHR(&executionContext, this, this, m_metho
d, m_url, m_async, httpBody ? httpBody->deepCopy() : nullptr, m_requestHeaders,
m_includeCredentials); | 888 InspectorInstrumentation::willLoadXHR(&executionContext, this, this, m_metho
d, m_url, m_async, httpBody ? httpBody->deepCopy() : nullptr, m_requestHeaders,
m_includeCredentials); |
| 888 | 889 |
| 889 if (httpBody) { | 890 if (httpBody) { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 { | 1062 { |
| 1062 m_requestHeaders.clear(); | 1063 m_requestHeaders.clear(); |
| 1063 } | 1064 } |
| 1064 | 1065 |
| 1065 void XMLHttpRequest::dispatchProgressEvent(const AtomicString& type, long long r
eceivedLength, long long expectedLength) | 1066 void XMLHttpRequest::dispatchProgressEvent(const AtomicString& type, long long r
eceivedLength, long long expectedLength) |
| 1066 { | 1067 { |
| 1067 bool lengthComputable = expectedLength > 0 && receivedLength <= expectedLeng
th; | 1068 bool lengthComputable = expectedLength > 0 && receivedLength <= expectedLeng
th; |
| 1068 unsigned long long loaded = receivedLength >= 0 ? static_cast<unsigned long
long>(receivedLength) : 0; | 1069 unsigned long long loaded = receivedLength >= 0 ? static_cast<unsigned long
long>(receivedLength) : 0; |
| 1069 unsigned long long total = lengthComputable ? static_cast<unsigned long long
>(expectedLength) : 0; | 1070 unsigned long long total = lengthComputable ? static_cast<unsigned long long
>(expectedLength) : 0; |
| 1070 | 1071 |
| 1072 ExecutionContext* context = getExecutionContext(); |
| 1073 InspectorInstrumentation::AsyncTask asyncTask(context, this, m_async); |
| 1071 m_progressEventThrottle->dispatchProgressEvent(type, lengthComputable, loade
d, total); | 1074 m_progressEventThrottle->dispatchProgressEvent(type, lengthComputable, loade
d, total); |
| 1072 | 1075 if (m_async && type == EventTypeNames::loadend) |
| 1073 if (type == EventTypeNames::loadend) | 1076 InspectorInstrumentation::asyncTaskCanceled(context, this); |
| 1074 InspectorInstrumentation::didDispatchXHRLoadendEvent(getExecutionContext
(), this); | |
| 1075 } | 1077 } |
| 1076 | 1078 |
| 1077 void XMLHttpRequest::dispatchProgressEventFromSnapshot(const AtomicString& type) | 1079 void XMLHttpRequest::dispatchProgressEventFromSnapshot(const AtomicString& type) |
| 1078 { | 1080 { |
| 1079 dispatchProgressEvent(type, m_receivedLength, m_response.expectedContentLeng
th()); | 1081 dispatchProgressEvent(type, m_receivedLength, m_response.expectedContentLeng
th()); |
| 1080 } | 1082 } |
| 1081 | 1083 |
| 1082 void XMLHttpRequest::handleNetworkError() | 1084 void XMLHttpRequest::handleNetworkError() |
| 1083 { | 1085 { |
| 1084 WTF_LOG(Network, "XMLHttpRequest %p handleNetworkError()", this); | 1086 WTF_LOG(Network, "XMLHttpRequest %p handleNetworkError()", this); |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 visitor->trace(m_responseDocumentParser); | 1703 visitor->trace(m_responseDocumentParser); |
| 1702 visitor->trace(m_progressEventThrottle); | 1704 visitor->trace(m_progressEventThrottle); |
| 1703 visitor->trace(m_upload); | 1705 visitor->trace(m_upload); |
| 1704 visitor->trace(m_blobLoader); | 1706 visitor->trace(m_blobLoader); |
| 1705 XMLHttpRequestEventTarget::trace(visitor); | 1707 XMLHttpRequestEventTarget::trace(visitor); |
| 1706 DocumentParserClient::trace(visitor); | 1708 DocumentParserClient::trace(visitor); |
| 1707 ActiveDOMObject::trace(visitor); | 1709 ActiveDOMObject::trace(visitor); |
| 1708 } | 1710 } |
| 1709 | 1711 |
| 1710 } // namespace blink | 1712 } // namespace blink |
| OLD | NEW |