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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 m_upload->dispatchEvent(XMLHttpRequestProgressEvent::create(EventTyp
eNames::loadstart)); | 787 m_upload->dispatchEvent(XMLHttpRequestProgressEvent::create(EventTyp
eNames::loadstart)); |
788 } | 788 } |
789 } | 789 } |
790 | 790 |
791 m_sameOriginRequest = securityOrigin()->canRequest(m_url); | 791 m_sameOriginRequest = securityOrigin()->canRequest(m_url); |
792 | 792 |
793 // We also remember whether upload events should be allowed for this request
in case the upload listeners are | 793 // We also remember whether upload events should be allowed for this request
in case the upload listeners are |
794 // added after the request is started. | 794 // added after the request is started. |
795 m_uploadEventsAllowed = m_sameOriginRequest || uploadEvents || !isSimpleCros
sOriginAccessRequest(m_method, m_requestHeaders); | 795 m_uploadEventsAllowed = m_sameOriginRequest || uploadEvents || !isSimpleCros
sOriginAccessRequest(m_method, m_requestHeaders); |
796 | 796 |
| 797 ASSERT(executionContext()); |
| 798 ExecutionContext& executionContext = *this->executionContext(); |
| 799 |
797 ResourceRequest request(m_url); | 800 ResourceRequest request(m_url); |
798 request.setHTTPMethod(m_method); | 801 request.setHTTPMethod(m_method); |
799 request.setTargetType(ResourceRequest::TargetIsXHR); | 802 request.setTargetType(ResourceRequest::TargetIsXHR); |
800 | 803 |
801 InspectorInstrumentation::willLoadXHR(executionContext(), this, this, m_meth
od, m_url, m_async, m_requestEntityBody ? m_requestEntityBody->deepCopy() : null
ptr, m_requestHeaders, m_includeCredentials); | 804 InspectorInstrumentation::willLoadXHR(&executionContext, this, this, m_metho
d, m_url, m_async, m_requestEntityBody ? m_requestEntityBody->deepCopy() : nullp
tr, m_requestHeaders, m_includeCredentials); |
802 | 805 |
803 if (m_requestEntityBody) { | 806 if (m_requestEntityBody) { |
804 ASSERT(m_method != "GET"); | 807 ASSERT(m_method != "GET"); |
805 ASSERT(m_method != "HEAD"); | 808 ASSERT(m_method != "HEAD"); |
806 request.setHTTPBody(m_requestEntityBody.release()); | 809 request.setHTTPBody(m_requestEntityBody.release()); |
807 } | 810 } |
808 | 811 |
809 if (m_requestHeaders.size() > 0) | 812 if (m_requestHeaders.size() > 0) |
810 request.addHTTPHeaderFields(m_requestHeaders); | 813 request.addHTTPHeaderFields(m_requestHeaders); |
811 | 814 |
812 ThreadableLoaderOptions options; | 815 ThreadableLoaderOptions options; |
813 options.sniffContent = DoNotSniffContent; | 816 options.sniffContent = DoNotSniffContent; |
814 options.preflightPolicy = uploadEvents ? ForcePreflight : ConsiderPreflight; | 817 options.preflightPolicy = uploadEvents ? ForcePreflight : ConsiderPreflight; |
815 options.allowCredentials = (m_sameOriginRequest || m_includeCredentials) ? A
llowStoredCredentials : DoNotAllowStoredCredentials; | 818 options.allowCredentials = (m_sameOriginRequest || m_includeCredentials) ? A
llowStoredCredentials : DoNotAllowStoredCredentials; |
816 options.credentialsRequested = m_includeCredentials ? ClientRequestedCredent
ials : ClientDidNotRequestCredentials; | 819 options.credentialsRequested = m_includeCredentials ? ClientRequestedCredent
ials : ClientDidNotRequestCredentials; |
817 options.crossOriginRequestPolicy = UseAccessControl; | 820 options.crossOriginRequestPolicy = UseAccessControl; |
818 options.securityOrigin = securityOrigin(); | 821 options.securityOrigin = securityOrigin(); |
819 options.initiator = FetchInitiatorTypeNames::xmlhttprequest; | 822 options.initiator = FetchInitiatorTypeNames::xmlhttprequest; |
820 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa
ssMainWorld(executionContext()) ? DoNotEnforceContentSecurityPolicy : EnforceCon
nectSrcDirective; | 823 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa
ssMainWorld(&executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConn
ectSrcDirective; |
821 // TODO(tsepez): Specify TreatAsActiveContent per http://crbug.com/305303. | 824 // TODO(tsepez): Specify TreatAsActiveContent per http://crbug.com/305303. |
822 options.mixedContentBlockingTreatment = TreatAsPassiveContent; | 825 options.mixedContentBlockingTreatment = TreatAsPassiveContent; |
823 options.timeoutMilliseconds = m_timeoutMilliseconds; | 826 options.timeoutMilliseconds = m_timeoutMilliseconds; |
824 | 827 |
825 m_exceptionCode = 0; | 828 m_exceptionCode = 0; |
826 m_error = false; | 829 m_error = false; |
827 | 830 |
828 if (m_async) { | 831 if (m_async) { |
829 if (m_upload) | 832 if (m_upload) |
830 request.setReportUploadProgress(true); | 833 request.setReportUploadProgress(true); |
831 | 834 |
832 // ThreadableLoader::create can return null here, for example if we're n
o longer attached to a page. | 835 // ThreadableLoader::create can return null here, for example if we're n
o longer attached to a page. |
833 // This is true while running onunload handlers. | 836 // This is true while running onunload handlers. |
834 // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload
, <http://bugs.webkit.org/show_bug.cgi?id=10904>. | 837 // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload
, <http://bugs.webkit.org/show_bug.cgi?id=10904>. |
835 // FIXME: Maybe create() can return null for other reasons too? | 838 // FIXME: Maybe create() can return null for other reasons too? |
836 ASSERT(!m_loader); | 839 ASSERT(!m_loader); |
837 m_loader = ThreadableLoader::create(executionContext(), this, request, o
ptions); | 840 m_loader = ThreadableLoader::create(executionContext, this, request, opt
ions); |
838 if (m_loader) { | 841 if (m_loader) { |
839 // Neither this object nor the JavaScript wrapper should be deleted
while | 842 // Neither this object nor the JavaScript wrapper should be deleted
while |
840 // a request is in progress because we need to keep the listeners al
ive, | 843 // a request is in progress because we need to keep the listeners al
ive, |
841 // and they are referenced by the JavaScript wrapper. | 844 // and they are referenced by the JavaScript wrapper. |
842 setPendingActivity(this); | 845 setPendingActivity(this); |
843 } | 846 } |
844 } else { | 847 } else { |
845 ThreadableLoader::loadResourceSynchronously(executionContext(), request,
*this, options); | 848 ThreadableLoader::loadResourceSynchronously(executionContext, request, *
this, options); |
846 } | 849 } |
847 | 850 |
848 if (!m_exceptionCode && m_error) | 851 if (!m_exceptionCode && m_error) |
849 m_exceptionCode = NetworkError; | 852 m_exceptionCode = NetworkError; |
850 if (m_exceptionCode) | 853 if (m_exceptionCode) |
851 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m
_url.elidedString() + "'."); | 854 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m
_url.elidedString() + "'."); |
852 } | 855 } |
853 | 856 |
854 void XMLHttpRequest::abort() | 857 void XMLHttpRequest::abort() |
855 { | 858 { |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 } | 1395 } |
1393 | 1396 |
1394 void XMLHttpRequest::trace(Visitor* visitor) | 1397 void XMLHttpRequest::trace(Visitor* visitor) |
1395 { | 1398 { |
1396 visitor->trace(m_responseBlob); | 1399 visitor->trace(m_responseBlob); |
1397 visitor->trace(m_responseStream); | 1400 visitor->trace(m_responseStream); |
1398 visitor->trace(m_progressEventThrottle); | 1401 visitor->trace(m_progressEventThrottle); |
1399 } | 1402 } |
1400 | 1403 |
1401 } // namespace WebCore | 1404 } // namespace WebCore |
OLD | NEW |