Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: Source/core/xml/XMLHttpRequest.cpp

Issue 204983007: Make ThreadableLoader class to use references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Changes per review commets Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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* executionContext = this->executionContext();
796 ASSERT(executionContext);
adamk 2014/04/02 17:16:42 Same here.
797
795 ResourceRequest request(m_url); 798 ResourceRequest request(m_url);
796 request.setHTTPMethod(m_method); 799 request.setHTTPMethod(m_method);
797 request.setTargetType(ResourceRequest::TargetIsXHR); 800 request.setTargetType(ResourceRequest::TargetIsXHR);
798 801
799 InspectorInstrumentation::willLoadXHR(executionContext(), this, this, m_meth od, m_url, m_async, m_requestEntityBody ? m_requestEntityBody->deepCopy() : null ptr, m_requestHeaders, m_includeCredentials); 802 InspectorInstrumentation::willLoadXHR(executionContext, this, this, m_method , m_url, m_async, m_requestEntityBody ? m_requestEntityBody->deepCopy() : nullpt r, m_requestHeaders, m_includeCredentials);
800 803
801 if (m_requestEntityBody) { 804 if (m_requestEntityBody) {
802 ASSERT(m_method != "GET"); 805 ASSERT(m_method != "GET");
803 ASSERT(m_method != "HEAD"); 806 ASSERT(m_method != "HEAD");
804 request.setHTTPBody(m_requestEntityBody.release()); 807 request.setHTTPBody(m_requestEntityBody.release());
805 } 808 }
806 809
807 if (m_requestHeaders.size() > 0) 810 if (m_requestHeaders.size() > 0)
808 request.addHTTPHeaderFields(m_requestHeaders); 811 request.addHTTPHeaderFields(m_requestHeaders);
809 812
810 ThreadableLoaderOptions options; 813 ThreadableLoaderOptions options;
811 options.sniffContent = DoNotSniffContent; 814 options.sniffContent = DoNotSniffContent;
812 options.preflightPolicy = uploadEvents ? ForcePreflight : ConsiderPreflight; 815 options.preflightPolicy = uploadEvents ? ForcePreflight : ConsiderPreflight;
813 options.allowCredentials = (m_sameOriginRequest || m_includeCredentials) ? A llowStoredCredentials : DoNotAllowStoredCredentials; 816 options.allowCredentials = (m_sameOriginRequest || m_includeCredentials) ? A llowStoredCredentials : DoNotAllowStoredCredentials;
814 options.credentialsRequested = m_includeCredentials ? ClientRequestedCredent ials : ClientDidNotRequestCredentials; 817 options.credentialsRequested = m_includeCredentials ? ClientRequestedCredent ials : ClientDidNotRequestCredentials;
815 options.crossOriginRequestPolicy = UseAccessControl; 818 options.crossOriginRequestPolicy = UseAccessControl;
816 options.securityOrigin = securityOrigin(); 819 options.securityOrigin = securityOrigin();
817 options.initiator = FetchInitiatorTypeNames::xmlhttprequest; 820 options.initiator = FetchInitiatorTypeNames::xmlhttprequest;
818 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa ssMainWorld(executionContext()) ? DoNotEnforceContentSecurityPolicy : EnforceCon nectSrcDirective; 821 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa ssMainWorld(executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConne ctSrcDirective;
819 // TODO(tsepez): Specify TreatAsActiveContent per http://crbug.com/305303. 822 // TODO(tsepez): Specify TreatAsActiveContent per http://crbug.com/305303.
820 options.mixedContentBlockingTreatment = TreatAsPassiveContent; 823 options.mixedContentBlockingTreatment = TreatAsPassiveContent;
821 options.timeoutMilliseconds = m_timeoutMilliseconds; 824 options.timeoutMilliseconds = m_timeoutMilliseconds;
822 825
823 m_exceptionCode = 0; 826 m_exceptionCode = 0;
824 m_error = false; 827 m_error = false;
825 828
826 if (m_async) { 829 if (m_async) {
827 if (m_upload) 830 if (m_upload)
828 request.setReportUploadProgress(true); 831 request.setReportUploadProgress(true);
829 832
830 // ThreadableLoader::create can return null here, for example if we're n o longer attached to a page. 833 // 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. 834 // 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>. 835 // 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? 836 // FIXME: Maybe create() can return null for other reasons too?
834 ASSERT(!m_loader); 837 ASSERT(!m_loader);
835 m_loader = ThreadableLoader::create(executionContext(), this, request, o ptions); 838 m_loader = ThreadableLoader::create(*executionContext, this, request, op tions);
836 if (m_loader) { 839 if (m_loader) {
837 // Neither this object nor the JavaScript wrapper should be deleted while 840 // 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, 841 // a request is in progress because we need to keep the listeners al ive,
839 // and they are referenced by the JavaScript wrapper. 842 // and they are referenced by the JavaScript wrapper.
840 setPendingActivity(this); 843 setPendingActivity(this);
841 } 844 }
842 } else { 845 } else {
843 ThreadableLoader::loadResourceSynchronously(executionContext(), request, *this, options); 846 ThreadableLoader::loadResourceSynchronously(*executionContext, request, *this, options);
844 } 847 }
845 848
846 if (!m_exceptionCode && m_error) 849 if (!m_exceptionCode && m_error)
847 m_exceptionCode = NetworkError; 850 m_exceptionCode = NetworkError;
848 if (m_exceptionCode) 851 if (m_exceptionCode)
849 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m _url.elidedString() + "'."); 852 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m _url.elidedString() + "'.");
850 } 853 }
851 854
852 void XMLHttpRequest::abort() 855 void XMLHttpRequest::abort()
853 { 856 {
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 return ActiveDOMObject::executionContext(); 1392 return ActiveDOMObject::executionContext();
1390 } 1393 }
1391 1394
1392 void XMLHttpRequest::trace(Visitor* visitor) 1395 void XMLHttpRequest::trace(Visitor* visitor)
1393 { 1396 {
1394 visitor->trace(m_responseBlob); 1397 visitor->trace(m_responseBlob);
1395 visitor->trace(m_responseStream); 1398 visitor->trace(m_responseStream);
1396 } 1399 }
1397 1400
1398 } // namespace WebCore 1401 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698