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

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

Issue 301243015: Refactor ThreadableLoaderOptions for readability (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 if (m_requestEntityBody) { 829 if (m_requestEntityBody) {
830 ASSERT(m_method != "GET"); 830 ASSERT(m_method != "GET");
831 ASSERT(m_method != "HEAD"); 831 ASSERT(m_method != "HEAD");
832 request.setHTTPBody(m_requestEntityBody.release()); 832 request.setHTTPBody(m_requestEntityBody.release());
833 } 833 }
834 834
835 if (m_requestHeaders.size() > 0) 835 if (m_requestHeaders.size() > 0)
836 request.addHTTPHeaderFields(m_requestHeaders); 836 request.addHTTPHeaderFields(m_requestHeaders);
837 837
838 ThreadableLoaderOptions options; 838 ThreadableLoaderOptions options;
839 options.sniffContent = DoNotSniffContent;
840 options.preflightPolicy = uploadEvents ? ForcePreflight : ConsiderPreflight; 839 options.preflightPolicy = uploadEvents ? ForcePreflight : ConsiderPreflight;
841 options.allowCredentials = (m_sameOriginRequest || m_includeCredentials) ? A llowStoredCredentials : DoNotAllowStoredCredentials;
842 options.credentialsRequested = m_includeCredentials ? ClientRequestedCredent ials : ClientDidNotRequestCredentials;
843 options.crossOriginRequestPolicy = UseAccessControl; 840 options.crossOriginRequestPolicy = UseAccessControl;
844 options.securityOrigin = securityOrigin();
845 options.initiator = FetchInitiatorTypeNames::xmlhttprequest; 841 options.initiator = FetchInitiatorTypeNames::xmlhttprequest;
846 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa ssMainWorld(&executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConn ectSrcDirective; 842 options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypa ssMainWorld(&executionContext) ? DoNotEnforceContentSecurityPolicy : EnforceConn ectSrcDirective;
843 options.timeoutMilliseconds = m_timeoutMilliseconds;
844
845 ResourceLoaderOptions resourceLoaderOptions;
846 resourceLoaderOptions.sniffContent = DoNotSniffContent;
tkent 2014/06/02 08:08:56 Ditto.
tyoshino (SeeGerritForStatus) 2014/06/02 08:21:35 Done.
847 resourceLoaderOptions.allowCredentials = (m_sameOriginRequest || m_includeCr edentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
848 resourceLoaderOptions.credentialsRequested = m_includeCredentials ? ClientRe questedCredentials : ClientDidNotRequestCredentials;
849 resourceLoaderOptions.securityOrigin = securityOrigin();
847 // TODO(tsepez): Specify TreatAsActiveContent per http://crbug.com/305303. 850 // TODO(tsepez): Specify TreatAsActiveContent per http://crbug.com/305303.
848 options.mixedContentBlockingTreatment = TreatAsPassiveContent; 851 resourceLoaderOptions.mixedContentBlockingTreatment = TreatAsPassiveContent;
849 options.timeoutMilliseconds = m_timeoutMilliseconds;
850 852
851 m_exceptionCode = 0; 853 m_exceptionCode = 0;
852 m_error = false; 854 m_error = false;
853 855
854 if (m_async) { 856 if (m_async) {
855 if (m_upload) 857 if (m_upload)
856 request.setReportUploadProgress(true); 858 request.setReportUploadProgress(true);
857 859
858 // ThreadableLoader::create can return null here, for example if we're n o longer attached to a page. 860 // ThreadableLoader::create can return null here, for example if we're n o longer attached to a page.
859 // This is true while running onunload handlers. 861 // This is true while running onunload handlers.
860 // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload , <http://bugs.webkit.org/show_bug.cgi?id=10904>. 862 // FIXME: Maybe we need to be able to send XMLHttpRequests from onunload , <http://bugs.webkit.org/show_bug.cgi?id=10904>.
861 // FIXME: Maybe create() can return null for other reasons too? 863 // FIXME: Maybe create() can return null for other reasons too?
862 ASSERT(!m_loader); 864 ASSERT(!m_loader);
863 m_loader = ThreadableLoader::create(executionContext, this, request, opt ions); 865 m_loader = ThreadableLoader::create(executionContext, this, request, opt ions, resourceLoaderOptions);
864 if (m_loader) { 866 if (m_loader) {
865 // Neither this object nor the JavaScript wrapper should be deleted while 867 // Neither this object nor the JavaScript wrapper should be deleted while
866 // a request is in progress because we need to keep the listeners al ive, 868 // a request is in progress because we need to keep the listeners al ive,
867 // and they are referenced by the JavaScript wrapper. 869 // and they are referenced by the JavaScript wrapper.
868 setPendingActivity(this); 870 setPendingActivity(this);
869 } 871 }
870 } else { 872 } else {
871 ThreadableLoader::loadResourceSynchronously(executionContext, request, * this, options); 873 ThreadableLoader::loadResourceSynchronously(executionContext, request, * this, options, resourceLoaderOptions);
872 } 874 }
873 875
874 if (!m_exceptionCode && m_error) 876 if (!m_exceptionCode && m_error)
875 m_exceptionCode = NetworkError; 877 m_exceptionCode = NetworkError;
876 if (m_exceptionCode) 878 if (m_exceptionCode)
877 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m _url.elidedString() + "'."); 879 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m _url.elidedString() + "'.");
878 } 880 }
879 881
880 void XMLHttpRequest::abort() 882 void XMLHttpRequest::abort()
881 { 883 {
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 { 1412 {
1411 visitor->trace(m_responseBlob); 1413 visitor->trace(m_responseBlob);
1412 visitor->trace(m_responseStream); 1414 visitor->trace(m_responseStream);
1413 visitor->trace(m_responseDocument); 1415 visitor->trace(m_responseDocument);
1414 visitor->trace(m_progressEventThrottle); 1416 visitor->trace(m_progressEventThrottle);
1415 visitor->trace(m_upload); 1417 visitor->trace(m_upload);
1416 XMLHttpRequestEventTarget::trace(visitor); 1418 XMLHttpRequestEventTarget::trace(visitor);
1417 } 1419 }
1418 1420
1419 } // namespace WebCore 1421 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698