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

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: Rebase 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
« no previous file with comments | « Source/core/workers/WorkerScriptLoader.cpp ('k') | Source/platform/CrossThreadCopier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.allowCredentials = (m_sameOriginRequest || m_includeCr edentials) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
847 resourceLoaderOptions.credentialsRequested = m_includeCredentials ? ClientRe questedCredentials : ClientDidNotRequestCredentials;
848 resourceLoaderOptions.securityOrigin = securityOrigin();
847 // TODO(tsepez): Specify TreatAsActiveContent per http://crbug.com/305303. 849 // TODO(tsepez): Specify TreatAsActiveContent per http://crbug.com/305303.
848 options.mixedContentBlockingTreatment = TreatAsPassiveContent; 850 resourceLoaderOptions.mixedContentBlockingTreatment = TreatAsPassiveContent;
849 options.timeoutMilliseconds = m_timeoutMilliseconds;
850 851
851 m_exceptionCode = 0; 852 m_exceptionCode = 0;
852 m_error = false; 853 m_error = false;
853 854
854 if (m_async) { 855 if (m_async) {
855 if (m_upload) 856 if (m_upload)
856 request.setReportUploadProgress(true); 857 request.setReportUploadProgress(true);
857 858
858 // ThreadableLoader::create can return null here, for example if we're n o longer attached to a page. 859 // 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. 860 // 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>. 861 // 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? 862 // FIXME: Maybe create() can return null for other reasons too?
862 ASSERT(!m_loader); 863 ASSERT(!m_loader);
863 m_loader = ThreadableLoader::create(executionContext, this, request, opt ions); 864 m_loader = ThreadableLoader::create(executionContext, this, request, opt ions, resourceLoaderOptions);
864 if (m_loader) { 865 if (m_loader) {
865 // Neither this object nor the JavaScript wrapper should be deleted while 866 // 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, 867 // a request is in progress because we need to keep the listeners al ive,
867 // and they are referenced by the JavaScript wrapper. 868 // and they are referenced by the JavaScript wrapper.
868 setPendingActivity(this); 869 setPendingActivity(this);
869 } 870 }
870 } else { 871 } else {
871 ThreadableLoader::loadResourceSynchronously(executionContext, request, * this, options); 872 ThreadableLoader::loadResourceSynchronously(executionContext, request, * this, options, resourceLoaderOptions);
872 } 873 }
873 874
874 if (!m_exceptionCode && m_error) 875 if (!m_exceptionCode && m_error)
875 m_exceptionCode = NetworkError; 876 m_exceptionCode = NetworkError;
876 if (m_exceptionCode) 877 if (m_exceptionCode)
877 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m _url.elidedString() + "'."); 878 exceptionState.throwDOMException(m_exceptionCode, "Failed to load '" + m _url.elidedString() + "'.");
878 } 879 }
879 880
880 void XMLHttpRequest::abort() 881 void XMLHttpRequest::abort()
881 { 882 {
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 { 1411 {
1411 visitor->trace(m_responseBlob); 1412 visitor->trace(m_responseBlob);
1412 visitor->trace(m_responseStream); 1413 visitor->trace(m_responseStream);
1413 visitor->trace(m_responseDocument); 1414 visitor->trace(m_responseDocument);
1414 visitor->trace(m_progressEventThrottle); 1415 visitor->trace(m_progressEventThrottle);
1415 visitor->trace(m_upload); 1416 visitor->trace(m_upload);
1416 XMLHttpRequestEventTarget::trace(visitor); 1417 XMLHttpRequestEventTarget::trace(visitor);
1417 } 1418 }
1418 1419
1419 } // namespace WebCore 1420 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerScriptLoader.cpp ('k') | Source/platform/CrossThreadCopier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698