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