[Fetch API] Pass directly FetchRequest fetch options to ThreadableLoader
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Aug 2016 06:46:57 +0000 (06:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Aug 2016 06:46:57 +0000 (06:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160407

Patch by Youenn Fablet <youenn@apple.com> on 2016-08-01
Reviewed by Sam Weinig.

No change of behavior.

Added a ResourceLoaderOptions constructor that takes a FetchOptions as input.
Removed setters and getters of ResourceLoaderOptions as it is a struct.
Updated member fields accordingly.

Updated code accordingly.
Removed explicit option setting if it is the same as the default value.

* Modules/fetch/FetchLoader.cpp:
(WebCore::FetchLoader::start):
* css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::cachedFont):
* css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::cachedImageSet):
* css/CSSImageValue.cpp:
(WebCore::CSSImageValue::cachedImage):
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::requestScript):
* fileapi/FileReaderLoader.cpp:
(WebCore::FileReaderLoader::start):
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::process):
* inspector/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::loadResource):
* loader/CrossOriginPreflightChecker.cpp:
(WebCore::CrossOriginPreflightChecker::validatePreflightResponse):
(WebCore::CrossOriginPreflightChecker::startPreflight):
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
(WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequest):
(WebCore::DocumentThreadableLoader::makeSimpleCrossOriginAccessRequest):
(WebCore::DocumentThreadableLoader::redirectReceived):
(WebCore::DocumentThreadableLoader::didReceiveResponse):
(WebCore::DocumentThreadableLoader::preflightSuccess):
(WebCore::DocumentThreadableLoader::loadRequest):
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement):
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::ResourceLoader):
(WebCore::ResourceLoader::init):
(WebCore::ResourceLoader::start):
(WebCore::ResourceLoader::setDefersLoading):
(WebCore::ResourceLoader::setDataBufferingPolicy):
(WebCore::ResourceLoader::addDataOrBuffer):
(WebCore::ResourceLoader::willSendRequestInternal):
(WebCore::ResourceLoader::didReceiveResponse):
(WebCore::ResourceLoader::didReceiveDataOrBuffer):
(WebCore::ResourceLoader::didFinishLoadingOnePart):
(WebCore::ResourceLoader::cleanupForError):
(WebCore::ResourceLoader::shouldUseCredentialStorage):
(WebCore::ResourceLoader::didReceiveAuthenticationChallenge):
* loader/ResourceLoader.h:
(WebCore::ResourceLoader::shouldSendResourceLoadCallbacks):
(WebCore::ResourceLoader::setSendCallbackPolicy):
(WebCore::ResourceLoader::shouldSniffContent):
(WebCore::ResourceLoader::shouldIncludeCertificateInfo):
* loader/ResourceLoaderOptions.h:
(WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
(WebCore::ResourceLoaderOptions::sendLoadCallbacks): Deleted.
(WebCore::ResourceLoaderOptions::setSendLoadCallbacks): Deleted.
(WebCore::ResourceLoaderOptions::sniffContent): Deleted.
(WebCore::ResourceLoaderOptions::setSniffContent): Deleted.
(WebCore::ResourceLoaderOptions::dataBufferingPolicy): Deleted.
(WebCore::ResourceLoaderOptions::setDataBufferingPolicy): Deleted.
(WebCore::ResourceLoaderOptions::allowCredentials): Deleted.
(WebCore::ResourceLoaderOptions::setAllowCredentials): Deleted.
(WebCore::ResourceLoaderOptions::securityCheck): Deleted.
(WebCore::ResourceLoaderOptions::setSecurityCheck): Deleted.
(WebCore::ResourceLoaderOptions::certificateInfoPolicy): Deleted.
(WebCore::ResourceLoaderOptions::setCertificateInfoPolicy): Deleted.
(WebCore::ResourceLoaderOptions::contentSecurityPolicyImposition): Deleted.
(WebCore::ResourceLoaderOptions::setContentSecurityPolicyImposition): Deleted.
(WebCore::ResourceLoaderOptions::defersLoadingPolicy): Deleted.
(WebCore::ResourceLoaderOptions::setDefersLoadingPolicy): Deleted.
(WebCore::ResourceLoaderOptions::cachingPolicy): Deleted.
(WebCore::ResourceLoaderOptions::setCachingPolicy): Deleted.
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::checkRedirectionCrossOriginAccessControl):
* loader/TextTrackLoader.cpp:
(WebCore::TextTrackLoader::load):
* loader/cache/CachedRawResource.cpp:
(WebCore::CachedRawResource::setDataBufferingPolicy):
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::load):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::shouldSendResourceLoadCallbacks):
(WebCore::CachedResource::dataBufferingPolicy):
(WebCore::CachedResource::allowsCaching):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::canRequest):
* loader/cache/CachedResourceRequest.cpp:
(WebCore::CachedResourceRequest::setAsPotentiallyCrossOrigin):
* loader/cache/CachedResourceRequest.h:
(WebCore::CachedResourceRequest::allowsCaching):
* loader/cache/CachedResourceRequestInitiators.cpp:
(WebCore::CachedResourceRequestInitiators::CachedResourceRequestInitiators):
* loader/cache/CachedResourceRequestInitiators.h:
* loader/mac/ResourceLoaderMac.mm:
(WebCore::ResourceLoader::willCacheResponse):
(WebCore::ResourceLoader::didReceiveDataArray):
* page/EventSource.cpp:
(WebCore::EventSource::connect):
* style/StylePendingResources.cpp:
(WebCore::Style::loadPendingImage):
(WebCore::Style::loadPendingSVGFilters):
* svg/SVGFEImageElement.cpp:
(WebCore::SVGFEImageElement::requestImageResource):
* svg/SVGFontFaceUriElement.cpp:
(WebCore::SVGFontFaceUriElement::loadFont):
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::updateExternalDocument):
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::loadSynchronously):
(WebCore::WorkerScriptLoader::loadAsynchronously):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createRequest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204014 268f45cc-cd09-0410-ab3c-d52691b4dbfc

34 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchLoader.cpp
Source/WebCore/css/CSSFontFaceSrcValue.cpp
Source/WebCore/css/CSSImageSetValue.cpp
Source/WebCore/css/CSSImageValue.cpp
Source/WebCore/dom/ScriptElement.cpp
Source/WebCore/fileapi/FileReaderLoader.cpp
Source/WebCore/html/HTMLLinkElement.cpp
Source/WebCore/inspector/InspectorNetworkAgent.cpp
Source/WebCore/loader/CrossOriginPreflightChecker.cpp
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/ImageLoader.cpp
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/ResourceLoader.h
Source/WebCore/loader/ResourceLoaderOptions.h
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/loader/TextTrackLoader.cpp
Source/WebCore/loader/cache/CachedRawResource.cpp
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedResourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceRequest.cpp
Source/WebCore/loader/cache/CachedResourceRequest.h
Source/WebCore/loader/cache/CachedResourceRequestInitiators.cpp
Source/WebCore/loader/cache/CachedResourceRequestInitiators.h
Source/WebCore/loader/cf/ResourceLoaderCFNet.cpp
Source/WebCore/loader/mac/ResourceLoaderMac.mm
Source/WebCore/page/EventSource.cpp
Source/WebCore/style/StylePendingResources.cpp
Source/WebCore/svg/SVGFEImageElement.cpp
Source/WebCore/svg/SVGFontFaceUriElement.cpp
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/workers/WorkerScriptLoader.cpp
Source/WebCore/xml/XMLHttpRequest.cpp

index 64bf9b0..753e1d4 100644 (file)
@@ -1,3 +1,128 @@
+2016-08-01  Youenn Fablet  <youenn@apple.com>
+
+        [Fetch API] Pass directly FetchRequest fetch options to ThreadableLoader
+        https://bugs.webkit.org/show_bug.cgi?id=160407
+
+        Reviewed by Sam Weinig.
+
+        No change of behavior.
+
+        Added a ResourceLoaderOptions constructor that takes a FetchOptions as input.
+        Removed setters and getters of ResourceLoaderOptions as it is a struct.
+        Updated member fields accordingly.
+
+        Updated code accordingly.
+        Removed explicit option setting if it is the same as the default value.
+
+        * Modules/fetch/FetchLoader.cpp:
+        (WebCore::FetchLoader::start):
+        * css/CSSFontFaceSrcValue.cpp:
+        (WebCore::CSSFontFaceSrcValue::cachedFont):
+        * css/CSSImageSetValue.cpp:
+        (WebCore::CSSImageSetValue::cachedImageSet):
+        * css/CSSImageValue.cpp:
+        (WebCore::CSSImageValue::cachedImage):
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::requestScript):
+        * fileapi/FileReaderLoader.cpp:
+        (WebCore::FileReaderLoader::start):
+        * html/HTMLLinkElement.cpp:
+        (WebCore::HTMLLinkElement::process):
+        * inspector/InspectorNetworkAgent.cpp:
+        (WebCore::InspectorNetworkAgent::loadResource):
+        * loader/CrossOriginPreflightChecker.cpp:
+        (WebCore::CrossOriginPreflightChecker::validatePreflightResponse):
+        (WebCore::CrossOriginPreflightChecker::startPreflight):
+        * loader/DocumentThreadableLoader.cpp:
+        (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
+        (WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequest):
+        (WebCore::DocumentThreadableLoader::makeSimpleCrossOriginAccessRequest):
+        (WebCore::DocumentThreadableLoader::redirectReceived):
+        (WebCore::DocumentThreadableLoader::didReceiveResponse):
+        (WebCore::DocumentThreadableLoader::preflightSuccess):
+        (WebCore::DocumentThreadableLoader::loadRequest):
+        * loader/ImageLoader.cpp:
+        (WebCore::ImageLoader::updateFromElement):
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::ResourceLoader):
+        (WebCore::ResourceLoader::init):
+        (WebCore::ResourceLoader::start):
+        (WebCore::ResourceLoader::setDefersLoading):
+        (WebCore::ResourceLoader::setDataBufferingPolicy):
+        (WebCore::ResourceLoader::addDataOrBuffer):
+        (WebCore::ResourceLoader::willSendRequestInternal):
+        (WebCore::ResourceLoader::didReceiveResponse):
+        (WebCore::ResourceLoader::didReceiveDataOrBuffer):
+        (WebCore::ResourceLoader::didFinishLoadingOnePart):
+        (WebCore::ResourceLoader::cleanupForError):
+        (WebCore::ResourceLoader::shouldUseCredentialStorage):
+        (WebCore::ResourceLoader::didReceiveAuthenticationChallenge):
+        * loader/ResourceLoader.h:
+        (WebCore::ResourceLoader::shouldSendResourceLoadCallbacks):
+        (WebCore::ResourceLoader::setSendCallbackPolicy):
+        (WebCore::ResourceLoader::shouldSniffContent):
+        (WebCore::ResourceLoader::shouldIncludeCertificateInfo):
+        * loader/ResourceLoaderOptions.h:
+        (WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
+        (WebCore::ResourceLoaderOptions::sendLoadCallbacks): Deleted.
+        (WebCore::ResourceLoaderOptions::setSendLoadCallbacks): Deleted.
+        (WebCore::ResourceLoaderOptions::sniffContent): Deleted.
+        (WebCore::ResourceLoaderOptions::setSniffContent): Deleted.
+        (WebCore::ResourceLoaderOptions::dataBufferingPolicy): Deleted.
+        (WebCore::ResourceLoaderOptions::setDataBufferingPolicy): Deleted.
+        (WebCore::ResourceLoaderOptions::allowCredentials): Deleted.
+        (WebCore::ResourceLoaderOptions::setAllowCredentials): Deleted.
+        (WebCore::ResourceLoaderOptions::securityCheck): Deleted.
+        (WebCore::ResourceLoaderOptions::setSecurityCheck): Deleted.
+        (WebCore::ResourceLoaderOptions::certificateInfoPolicy): Deleted.
+        (WebCore::ResourceLoaderOptions::setCertificateInfoPolicy): Deleted.
+        (WebCore::ResourceLoaderOptions::contentSecurityPolicyImposition): Deleted.
+        (WebCore::ResourceLoaderOptions::setContentSecurityPolicyImposition): Deleted.
+        (WebCore::ResourceLoaderOptions::defersLoadingPolicy): Deleted.
+        (WebCore::ResourceLoaderOptions::setDefersLoadingPolicy): Deleted.
+        (WebCore::ResourceLoaderOptions::cachingPolicy): Deleted.
+        (WebCore::ResourceLoaderOptions::setCachingPolicy): Deleted.
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::checkRedirectionCrossOriginAccessControl):
+        * loader/TextTrackLoader.cpp:
+        (WebCore::TextTrackLoader::load):
+        * loader/cache/CachedRawResource.cpp:
+        (WebCore::CachedRawResource::setDataBufferingPolicy):
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::load):
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::shouldSendResourceLoadCallbacks):
+        (WebCore::CachedResource::dataBufferingPolicy):
+        (WebCore::CachedResource::allowsCaching):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::canRequest):
+        * loader/cache/CachedResourceRequest.cpp:
+        (WebCore::CachedResourceRequest::setAsPotentiallyCrossOrigin):
+        * loader/cache/CachedResourceRequest.h:
+        (WebCore::CachedResourceRequest::allowsCaching):
+        * loader/cache/CachedResourceRequestInitiators.cpp:
+        (WebCore::CachedResourceRequestInitiators::CachedResourceRequestInitiators):
+        * loader/cache/CachedResourceRequestInitiators.h:
+        * loader/mac/ResourceLoaderMac.mm:
+        (WebCore::ResourceLoader::willCacheResponse):
+        (WebCore::ResourceLoader::didReceiveDataArray):
+        * page/EventSource.cpp:
+        (WebCore::EventSource::connect):
+        * style/StylePendingResources.cpp:
+        (WebCore::Style::loadPendingImage):
+        (WebCore::Style::loadPendingSVGFilters):
+        * svg/SVGFEImageElement.cpp:
+        (WebCore::SVGFEImageElement::requestImageResource):
+        * svg/SVGFontFaceUriElement.cpp:
+        (WebCore::SVGFontFaceUriElement::loadFont):
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::updateExternalDocument):
+        * workers/WorkerScriptLoader.cpp:
+        (WebCore::WorkerScriptLoader::loadSynchronously):
+        (WebCore::WorkerScriptLoader::loadAsynchronously):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::createRequest):
+
 2016-08-01  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Move the redirected XComposite window to the web process
index 77cafd0..78cae7a 100644 (file)
@@ -32,6 +32,7 @@
 #if ENABLE(FETCH_API)
 
 #include "BlobURL.h"
+#include "CachedResourceRequestInitiators.h"
 #include "FetchBody.h"
 #include "FetchLoaderClient.h"
 #include "FetchRequest.h"
@@ -59,11 +60,10 @@ void FetchLoader::start(ScriptExecutionContext& context, Blob& blob)
     request.setHTTPMethod("GET");
 
     ThreadableLoaderOptions options;
-    options.setSendLoadCallbacks(SendCallbacks);
-    options.setSniffContent(DoNotSniffContent);
-    options.setDataBufferingPolicy(DoNotBufferData);
+    options.sendLoadCallbacks = SendCallbacks;
+    options.dataBufferingPolicy = DoNotBufferData;
     options.preflightPolicy = ConsiderPreflight;
-    options.setAllowCredentials(AllowStoredCredentials);
+    options.credentials = FetchOptions::Credentials::Include;
     options.mode = FetchOptions::Mode::SameOrigin;
     options.contentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement::DoNotEnforce;
 
@@ -73,17 +73,9 @@ void FetchLoader::start(ScriptExecutionContext& context, Blob& blob)
 
 void FetchLoader::start(ScriptExecutionContext& context, const FetchRequest& request)
 {
-    ThreadableLoaderOptions options;
-    options.setSendLoadCallbacks(SendCallbacks);
-    options.setSniffContent(DoNotSniffContent);
-    options.setDataBufferingPolicy(DoNotBufferData);
-    options.preflightPolicy = ConsiderPreflight;
-    options.contentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement::DoNotEnforce;
-
-    // FIXME: Pass directly all fetch options to loader options.
-    options.redirect = request.fetchOptions().redirect;
-    options.mode = request.fetchOptions().mode;
-    options.credentials = request.fetchOptions().credentials;
+    ThreadableLoaderOptions options(request.fetchOptions(), ConsiderPreflight, ContentSecurityPolicyEnforcement::DoNotEnforce, String(cachedResourceRequestInitiators().fetch));
+    options.sendLoadCallbacks = SendCallbacks;
+    options.dataBufferingPolicy = DoNotBufferData;
 
     m_loader = ThreadableLoader::create(&context, this, request.internalRequest(), options);
     m_isStarted = m_loader;
index 14f2b16..7e56355 100644 (file)
@@ -104,7 +104,7 @@ CachedFont* CSSFontFaceSrcValue::cachedFont(Document* document, bool isSVG, bool
         return m_cachedFont.get();
 
     ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-    options.setContentSecurityPolicyImposition(isInitiatingElementInUserAgentShadowTree ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+    options.contentSecurityPolicyImposition = isInitiatingElementInUserAgentShadowTree ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
 
     CachedResourceRequest request(ResourceRequest(document->completeURL(m_resource)), options);
     request.setInitiator(cachedResourceRequestInitiators().css);
index 282c0ad..9d87419 100644 (file)
@@ -120,7 +120,7 @@ StyleCachedImageSet* CSSImageSetValue::cachedImageSet(CachedResourceLoader& load
         request.setInitiator(cachedResourceRequestInitiators().css);
         if (options.mode == FetchOptions::Mode::Cors) {
             ASSERT(document->securityOrigin());
-            updateRequestForAccessControl(request.mutableResourceRequest(), *document->securityOrigin(), options.allowCredentials());
+            updateRequestForAccessControl(request.mutableResourceRequest(), *document->securityOrigin(), options.allowCredentials);
         }
         if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) {
             detachPendingImage();
index 2253e5e..73058ef 100644 (file)
@@ -84,7 +84,7 @@ StyleCachedImage* CSSImageValue::cachedImage(CachedResourceLoader& loader, const
 
         if (options.mode == FetchOptions::Mode::Cors) {
             ASSERT(loader.document()->securityOrigin());
-            updateRequestForAccessControl(request.mutableResourceRequest(), *loader.document()->securityOrigin(), options.allowCredentials());
+            updateRequestForAccessControl(request.mutableResourceRequest(), *loader.document()->securityOrigin(), options.allowCredentials);
         }
         if (CachedResourceHandle<CachedImage> cachedImage = loader.requestImage(request)) {
             detachPendingImage();
index ca986a7..69ddb35 100644 (file)
@@ -261,7 +261,7 @@ bool ScriptElement::requestScript(const String& sourceUrl)
     if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) {
         bool hasKnownNonce = m_element.document().contentSecurityPolicy()->allowScriptWithNonce(m_element.attributeWithoutSynchronization(HTMLNames::nonceAttr), m_element.isInUserAgentShadowTree());
         ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-        options.setContentSecurityPolicyImposition(hasKnownNonce ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+        options.contentSecurityPolicyImposition = hasKnownNonce ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
 
         CachedResourceRequest request(ResourceRequest(m_element.document().completeURL(sourceUrl)), options);
 
index ae681e5..32641de 100644 (file)
@@ -86,10 +86,8 @@ void FileReaderLoader::start(ScriptExecutionContext* scriptExecutionContext, Blo
     request.setHTTPMethod("GET");
 
     ThreadableLoaderOptions options;
-    options.setSendLoadCallbacks(SendCallbacks);
-    options.setSniffContent(DoNotSniffContent);
-    options.setDataBufferingPolicy(DoNotBufferData);
-    options.preflightPolicy = ConsiderPreflight;
+    options.sendLoadCallbacks = SendCallbacks;
+    options.dataBufferingPolicy = DoNotBufferData;
     options.credentials = FetchOptions::Credentials::Include;
     options.mode = FetchOptions::Mode::SameOrigin;
     options.contentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement::DoNotEnforce;
index e3bbf5d..cdaa317 100644 (file)
@@ -259,7 +259,7 @@ void HTMLLinkElement::process()
 
         if (document().contentSecurityPolicy()->allowStyleWithNonce(attributeWithoutSynchronization(HTMLNames::nonceAttr))) {
             ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-            options.setContentSecurityPolicyImposition(ContentSecurityPolicyImposition::SkipPolicyCheck);
+            options.contentSecurityPolicyImposition = ContentSecurityPolicyImposition::SkipPolicyCheck;
             request.setOptions(options);
         }
         request.setAsPotentiallyCrossOrigin(crossOrigin(), document());
index 811ccba..e17469a 100644 (file)
@@ -670,8 +670,8 @@ void InspectorNetworkAgent::loadResource(ErrorString& errorString, const String&
     request.setHiddenFromInspector(true);
 
     ThreadableLoaderOptions options;
-    options.setSendLoadCallbacks(SendCallbacks); // So we remove this from m_hiddenRequestIdentifiers on completion.
-    options.setDefersLoadingPolicy(DefersLoadingPolicy::DisallowDefersLoading); // So the request is never deferred.
+    options.sendLoadCallbacks = SendCallbacks; // So we remove this from m_hiddenRequestIdentifiers on completion.
+    options.defersLoadingPolicy = DefersLoadingPolicy::DisallowDefersLoading; // So the request is never deferred.
     options.mode = FetchOptions::Mode::NoCors;
     options.credentials = FetchOptions::Credentials::SameOrigin;
     options.contentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement::DoNotEnforce;
index 78cb74f..9f6f1f3 100644 (file)
@@ -69,12 +69,12 @@ void CrossOriginPreflightChecker::validatePreflightResponse(DocumentThreadableLo
     }
 
     String description;
-    if (!passesAccessControlCheck(response, loader.options().allowCredentials(), loader.securityOrigin(), description)) {
+    if (!passesAccessControlCheck(response, loader.options().allowCredentials, loader.securityOrigin(), description)) {
         loader.preflightFailure(identifier, ResourceError(errorDomainWebKitInternal, 0, request.url(), description, ResourceError::Type::AccessControl));
         return;
     }
 
-    auto result = std::make_unique<CrossOriginPreflightResultCacheItem>(loader.options().allowCredentials());
+    auto result = std::make_unique<CrossOriginPreflightResultCacheItem>(loader.options().allowCredentials);
     if (!result->parse(response, description)
         || !result->allowsCrossOriginMethod(request.httpMethod(), description)
         || !result->allowsCrossOriginHeaders(request.httpHeaderFields(), description)) {
@@ -100,15 +100,8 @@ void CrossOriginPreflightChecker::notifyFinished(CachedResource* resource)
 
 void CrossOriginPreflightChecker::startPreflight()
 {
-    auto options = m_loader.options();
+    ResourceLoaderOptions options = static_cast<FetchOptions>(m_loader.options());
     options.credentials = FetchOptions::Credentials::Omit;
-    options.setSecurityCheck(DoSecurityCheck);
-    // Don't sniff content or send load callbacks for the preflight request.
-    options.setSendLoadCallbacks(DoNotSendCallbacks);
-    options.setSniffContent(DoNotSniffContent);
-    // Keep buffering the data for the preflight request.
-    options.setDataBufferingPolicy(BufferData);
-
     options.redirect = FetchOptions::Redirect::Manual;
 
     CachedResourceRequest preflightRequest(createAccessControlPreflightRequest(m_request, m_loader.securityOrigin()), options);
index 4b72af7..2a53745 100644 (file)
@@ -96,7 +96,7 @@ DocumentThreadableLoader::DocumentThreadableLoader(Document& document, Threadabl
 
     ASSERT_WITH_SECURITY_IMPLICATION(isAllowedByContentSecurityPolicy(request.url()));
 
-    m_options.setAllowCredentials((m_options.credentials == FetchOptions::Credentials::Include || (m_options.credentials == FetchOptions::Credentials::SameOrigin && m_sameOriginRequest)) ? AllowStoredCredentials : DoNotAllowStoredCredentials);
+    m_options.allowCredentials = (m_options.credentials == FetchOptions::Credentials::Include || (m_options.credentials == FetchOptions::Credentials::SameOrigin && m_sameOriginRequest)) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
 
     if (m_sameOriginRequest || m_options.mode == FetchOptions::Mode::NoCors) {
         loadRequest(WTFMove(request), DoSecurityCheck);
@@ -119,7 +119,7 @@ void DocumentThreadableLoader::makeCrossOriginAccessRequest(ResourceRequest&& re
         makeSimpleCrossOriginAccessRequest(WTFMove(request));
     else {
         m_simpleRequest = false;
-        if (CrossOriginPreflightResultCache::singleton().canSkipPreflight(securityOrigin().toString(), request.url(), m_options.allowCredentials(), request.httpMethod(), request.httpHeaderFields()))
+        if (CrossOriginPreflightResultCache::singleton().canSkipPreflight(securityOrigin().toString(), request.url(), m_options.allowCredentials, request.httpMethod(), request.httpHeaderFields()))
             preflightSuccess(WTFMove(request));
         else
             makeCrossOriginAccessRequestWithPreflight(WTFMove(request));
@@ -137,7 +137,7 @@ void DocumentThreadableLoader::makeSimpleCrossOriginAccessRequest(ResourceReques
         return;
     }
 
-    updateRequestForAccessControl(request, securityOrigin(), m_options.allowCredentials());
+    updateRequestForAccessControl(request, securityOrigin(), m_options.allowCredentials);
     loadRequest(WTFMove(request), DoSecurityCheck);
 }
 
@@ -227,7 +227,7 @@ void DocumentThreadableLoader::redirectReceived(CachedResource* resource, Resour
         if (m_simpleRequest) {
             String accessControlErrorDescription;
             allowRedirect = isValidCrossOriginRedirectionURL(request.url())
-                            && (m_sameOriginRequest || passesAccessControlCheck(redirectResponse, m_options.allowCredentials(), securityOrigin(), accessControlErrorDescription));
+                && (m_sameOriginRequest || passesAccessControlCheck(redirectResponse, m_options.allowCredentials, securityOrigin(), accessControlErrorDescription));
         }
 
         if (allowRedirect) {
@@ -245,7 +245,7 @@ void DocumentThreadableLoader::redirectReceived(CachedResource* resource, Resour
             m_sameOriginRequest = false;
 
             if (m_options.credentials == FetchOptions::Credentials::SameOrigin)
-                m_options.setAllowCredentials(DoNotAllowStoredCredentials);
+                m_options.allowCredentials = DoNotAllowStoredCredentials;
 
             cleanRedirectedRequestForAccessControl(request);
 
@@ -277,7 +277,7 @@ void DocumentThreadableLoader::didReceiveResponse(unsigned long identifier, cons
 
     String accessControlErrorDescription;
     if (!m_sameOriginRequest && m_options.mode == FetchOptions::Mode::Cors) {
-        if (!passesAccessControlCheck(response, m_options.allowCredentials(), securityOrigin(), accessControlErrorDescription)) {
+        if (!passesAccessControlCheck(response, m_options.allowCredentials, securityOrigin(), accessControlErrorDescription)) {
             m_client->didFail(ResourceError(errorDomainWebKitInternal, 0, response.url(), accessControlErrorDescription, ResourceError::Type::AccessControl));
             return;
         }
@@ -334,7 +334,7 @@ void DocumentThreadableLoader::didFail(unsigned long, const ResourceError& error
 void DocumentThreadableLoader::preflightSuccess(ResourceRequest&& request)
 {
     ResourceRequest actualRequest(WTFMove(request));
-    updateRequestForAccessControl(actualRequest, securityOrigin(), m_options.allowCredentials());
+    updateRequestForAccessControl(actualRequest, securityOrigin(), m_options.allowCredentials);
 
     m_preflightChecker = Nullopt;
 
@@ -357,7 +357,7 @@ void DocumentThreadableLoader::loadRequest(ResourceRequest&& request, SecurityCh
 {
     // Any credential should have been removed from the cross-site requests.
     const URL& requestURL = request.url();
-    m_options.setSecurityCheck(securityCheck);
+    m_options.securityCheck = securityCheck;
     ASSERT(m_sameOriginRequest || requestURL.user().isEmpty());
     ASSERT(m_sameOriginRequest || requestURL.pass().isEmpty());
 
@@ -371,7 +371,7 @@ void DocumentThreadableLoader::loadRequest(ResourceRequest&& request, SecurityCh
         CachedResourceRequest newRequest(WTFMove(request), options);
         if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled())
             newRequest.setInitiator(m_options.initiator);
-        newRequest.mutableResourceRequest().setAllowCookies(m_options.allowCredentials() == AllowStoredCredentials);
+        newRequest.mutableResourceRequest().setAllowCookies(m_options.allowCredentials == AllowStoredCredentials);
 
         ASSERT(!m_resource);
         m_resource = m_document.cachedResourceLoader().requestRawResource(newRequest);
@@ -393,7 +393,7 @@ void DocumentThreadableLoader::loadRequest(ResourceRequest&& request, SecurityCh
         auto& frameLoader = m_document.frame()->loader();
         if (!frameLoader.mixedContentChecker().canRunInsecureContent(m_document.securityOrigin(), requestURL))
             return;
-        identifier = frameLoader.loadResourceSynchronously(request, m_options.allowCredentials(), m_options.clientCredentialPolicy, error, response, data);
+        identifier = frameLoader.loadResourceSynchronously(request, m_options.allowCredentials, m_options.clientCredentialPolicy, error, response, data);
     }
 
     if (!error.isNull() && response.httpStatusCode() <= 0) {
index 76020e3..d616ff8 100644 (file)
@@ -174,7 +174,7 @@ void ImageLoader::updateFromElement()
     CachedResourceHandle<CachedImage> newImage = nullptr;
     if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) {
         ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-        options.setContentSecurityPolicyImposition(element().isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+        options.contentSecurityPolicyImposition = element().isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
 
         CachedResourceRequest request(ResourceRequest(document.completeURL(sourceURI(attr))), options);
         request.setInitiator(&element());
index c377c08..656020a 100644 (file)
@@ -61,7 +61,7 @@ namespace WebCore {
 ResourceLoader::ResourceLoader(Frame& frame, ResourceLoaderOptions options)
     : m_frame(&frame)
     , m_documentLoader(frame.loader().activeDocumentLoader())
-    , m_defersLoading(options.defersLoadingPolicy() == DefersLoadingPolicy::AllowDefersLoading && frame.page()->defersLoading())
+    , m_defersLoading(options.defersLoadingPolicy == DefersLoadingPolicy::AllowDefersLoading && frame.page()->defersLoading())
     , m_options(options)
 {
 }
@@ -125,9 +125,9 @@ bool ResourceLoader::init(const ResourceRequest& r)
     }
 #endif
     
-    m_defersLoading = m_options.defersLoadingPolicy() == DefersLoadingPolicy::AllowDefersLoading && m_frame->page()->defersLoading();
+    m_defersLoading = m_options.defersLoadingPolicy == DefersLoadingPolicy::AllowDefersLoading && m_frame->page()->defersLoading();
 
-    if (m_options.securityCheck() == DoSecurityCheck && !m_frame->document()->securityOrigin()->canDisplay(clientRequest.url())) {
+    if (m_options.securityCheck == DoSecurityCheck && !m_frame->document()->securityOrigin()->canDisplay(clientRequest.url())) {
         FrameLoader::reportLocalLoadFailed(m_frame.get(), clientRequest.url().string());
         releaseResources();
         return false;
@@ -206,12 +206,12 @@ void ResourceLoader::start()
         return;
     }
 
-    m_handle = ResourceHandle::create(frameLoader()->networkingContext(), m_request, this, m_defersLoading, m_options.sniffContent() == SniffContent);
+    m_handle = ResourceHandle::create(frameLoader()->networkingContext(), m_request, this, m_defersLoading, m_options.sniffContent == SniffContent);
 }
 
 void ResourceLoader::setDefersLoading(bool defers)
 {
-    if (m_options.defersLoadingPolicy() == DefersLoadingPolicy::DisallowDefersLoading)
+    if (m_options.defersLoadingPolicy == DefersLoadingPolicy::DisallowDefersLoading)
         return;
 
     m_defersLoading = defers;
@@ -268,14 +268,14 @@ void ResourceLoader::loadDataURL()
 }
 
 void ResourceLoader::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy)
-{ 
-    m_options.setDataBufferingPolicy(dataBufferingPolicy); 
+{
+    m_options.dataBufferingPolicy = dataBufferingPolicy;
 
     // Reset any already buffered data
     if (dataBufferingPolicy == DoNotBufferData)
         m_resourceData = nullptr;
 }
-    
+
 void ResourceLoader::willSwitchToSubstituteResource()
 {
     ASSERT(!m_documentLoader->isSubstituteLoadPending(this));
@@ -286,7 +286,7 @@ void ResourceLoader::willSwitchToSubstituteResource()
 
 void ResourceLoader::addDataOrBuffer(const char* data, unsigned length, SharedBuffer* buffer, DataPayloadType dataPayloadType)
 {
-    if (m_options.dataBufferingPolicy() == DoNotBufferData)
+    if (m_options.dataBufferingPolicy == DoNotBufferData)
         return;
 
     if (!m_resourceData || dataPayloadType == DataPayloadWholeResource) {
@@ -350,7 +350,7 @@ void ResourceLoader::willSendRequestInternal(ResourceRequest& request, const Res
         return;
     }
 
-    if (m_options.sendLoadCallbacks() == SendCallbacks) {
+    if (m_options.sendLoadCallbacks == SendCallbacks) {
         if (createdResourceIdentifier)
             frameLoader()->notifier().assignIdentifierToInitialRequest(m_identifier, documentLoader(), request);
 
@@ -458,8 +458,8 @@ void ResourceLoader::didReceiveResponse(const ResourceResponse& r)
 
     if (FormData* data = m_request.httpBody())
         data->removeGeneratedFilesIfNeeded();
-        
-    if (m_options.sendLoadCallbacks() == SendCallbacks)
+
+    if (m_options.sendLoadCallbacks == SendCallbacks)
         frameLoader()->notifier().didReceiveResponse(this, m_response);
 }
 
@@ -489,11 +489,11 @@ void ResourceLoader::didReceiveDataOrBuffer(const char* data, unsigned length, R
     Ref<ResourceLoader> protectedThis(*this);
 
     addDataOrBuffer(data, length, buffer.get(), dataPayloadType);
-    
+
     // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
     // However, with today's computers and networking speeds, this won't happen in practice.
     // Could be an issue with a giant local file.
-    if (m_options.sendLoadCallbacks() == SendCallbacks && m_frame)
+    if (m_options.sendLoadCallbacks == SendCallbacks && m_frame)
         frameLoader()->notifier().didReceiveData(this, buffer ? buffer->data() : data, buffer ? buffer->size() : length, static_cast<int>(encodedDataLength));
 }
 
@@ -519,7 +519,7 @@ void ResourceLoader::didFinishLoadingOnePart(double finishTime)
     if (m_notifiedLoadComplete)
         return;
     m_notifiedLoadComplete = true;
-    if (m_options.sendLoadCallbacks() == SendCallbacks)
+    if (m_options.sendLoadCallbacks == SendCallbacks)
         frameLoader()->notifier().didFinishLoad(this, finishTime);
 }
 
@@ -545,7 +545,7 @@ void ResourceLoader::cleanupForError(const ResourceError& error)
     if (m_notifiedLoadComplete)
         return;
     m_notifiedLoadComplete = true;
-    if (m_options.sendLoadCallbacks() == SendCallbacks && m_identifier)
+    if (m_options.sendLoadCallbacks == SendCallbacks && m_identifier)
         frameLoader()->notifier().didFailToLoad(this, error);
 }
 
@@ -678,9 +678,9 @@ void ResourceLoader::cannotShowURL(ResourceHandle*)
 
 bool ResourceLoader::shouldUseCredentialStorage()
 {
-    if (m_options.allowCredentials() == DoNotAllowStoredCredentials)
+    if (m_options.allowCredentials == DoNotAllowStoredCredentials)
         return false;
-    
+
     Ref<ResourceLoader> protectedThis(*this);
     return frameLoader()->client().shouldUseCredentialStorage(documentLoader(), identifier());
 }
@@ -700,7 +700,7 @@ void ResourceLoader::didReceiveAuthenticationChallenge(const AuthenticationChall
     // anything including possibly derefing this; one example of this is Radar 3266216.
     Ref<ResourceLoader> protectedThis(*this);
 
-    if (m_options.allowCredentials() == AllowStoredCredentials) {
+    if (m_options.allowCredentials == AllowStoredCredentials) {
         if (isAllowedToAskUserForCredentials()) {
             frameLoader()->notifier().didReceiveAuthenticationChallenge(this, challenge);
             return;
index ec7e4d2..8c738a2 100644 (file)
@@ -125,11 +125,11 @@ public:
 
     const URL& url() const { return m_request.url(); }
     ResourceHandle* handle() const { return m_handle.get(); }
-    bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks() == SendCallbacks; }
-    void setSendCallbackPolicy(SendCallbackPolicy sendLoadCallbacks) { m_options.setSendLoadCallbacks(sendLoadCallbacks); }
-    bool shouldSniffContent() const { return m_options.sniffContent() == SniffContent; }
+    bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks == SendCallbacks; }
+    void setSendCallbackPolicy(SendCallbackPolicy sendLoadCallbacks) { m_options.sendLoadCallbacks = sendLoadCallbacks; }
+    bool shouldSniffContent() const { return m_options.sniffContent == SniffContent; }
     WEBCORE_EXPORT bool isAllowedToAskUserForCredentials() const;
-    bool shouldIncludeCertificateInfo() const { return m_options.certificateInfoPolicy() == IncludeCertificateInfo; }
+    bool shouldIncludeCertificateInfo() const { return m_options.certificateInfoPolicy == IncludeCertificateInfo; }
 
     bool reachedTerminalState() const { return m_reachedTerminalState; }
 
index c779fbd..ac93425 100644 (file)
@@ -81,60 +81,35 @@ enum class ClientCredentialPolicy {
 };
 
 struct ResourceLoaderOptions : public FetchOptions {
-    ResourceLoaderOptions()
-        : m_sendLoadCallbacks(DoNotSendCallbacks)
-        , m_sniffContent(DoNotSniffContent)
-        , m_dataBufferingPolicy(BufferData)
-        , m_allowCredentials(DoNotAllowStoredCredentials)
-        , m_securityCheck(DoSecurityCheck)
-        , m_certificateInfoPolicy(DoNotIncludeCertificateInfo)
-    {
-    }
+    ResourceLoaderOptions() { }
+
+    ResourceLoaderOptions(const FetchOptions& options) : FetchOptions(options) { }
 
     ResourceLoaderOptions(SendCallbackPolicy sendLoadCallbacks, ContentSniffingPolicy sniffContent, DataBufferingPolicy dataBufferingPolicy, StoredCredentials allowCredentials, ClientCredentialPolicy credentialPolicy, FetchOptions::Credentials credentials, SecurityCheckPolicy securityCheck, FetchOptions::Mode mode, CertificateInfoPolicy certificateInfoPolicy, ContentSecurityPolicyImposition contentSecurityPolicyImposition, DefersLoadingPolicy defersLoadingPolicy, CachingPolicy cachingPolicy)
-        : m_sendLoadCallbacks(sendLoadCallbacks)
-        , m_sniffContent(sniffContent)
-        , m_dataBufferingPolicy(dataBufferingPolicy)
-        , m_allowCredentials(allowCredentials)
-        , m_securityCheck(securityCheck)
-        , m_certificateInfoPolicy(certificateInfoPolicy)
-        , m_contentSecurityPolicyImposition(contentSecurityPolicyImposition)
-        , m_defersLoadingPolicy(defersLoadingPolicy)
-        , m_cachingPolicy(cachingPolicy)
+        : sendLoadCallbacks(sendLoadCallbacks)
+        , sniffContent(sniffContent)
+        , dataBufferingPolicy(dataBufferingPolicy)
+        , allowCredentials(allowCredentials)
+        , securityCheck(securityCheck)
+        , certificateInfoPolicy(certificateInfoPolicy)
+        , contentSecurityPolicyImposition(contentSecurityPolicyImposition)
+        , defersLoadingPolicy(defersLoadingPolicy)
+        , cachingPolicy(cachingPolicy)
         , clientCredentialPolicy(credentialPolicy)
     {
         this->credentials = credentials;
         this->mode = mode;
     }
 
-    SendCallbackPolicy sendLoadCallbacks() const { return static_cast<SendCallbackPolicy>(m_sendLoadCallbacks); }
-    void setSendLoadCallbacks(SendCallbackPolicy allow) { m_sendLoadCallbacks = allow; }
-    ContentSniffingPolicy sniffContent() const { return static_cast<ContentSniffingPolicy>(m_sniffContent); }
-    void setSniffContent(ContentSniffingPolicy policy) { m_sniffContent = policy; }
-    DataBufferingPolicy dataBufferingPolicy() const { return static_cast<DataBufferingPolicy>(m_dataBufferingPolicy); }
-    void setDataBufferingPolicy(DataBufferingPolicy policy) { m_dataBufferingPolicy = policy; }
-    StoredCredentials allowCredentials() const { return static_cast<StoredCredentials>(m_allowCredentials); }
-    void setAllowCredentials(StoredCredentials allow) { m_allowCredentials = allow; }
-    SecurityCheckPolicy securityCheck() const { return static_cast<SecurityCheckPolicy>(m_securityCheck); }
-    void setSecurityCheck(SecurityCheckPolicy check) { m_securityCheck = check; }
-    CertificateInfoPolicy certificateInfoPolicy() const { return static_cast<CertificateInfoPolicy>(m_certificateInfoPolicy); }
-    void setCertificateInfoPolicy(CertificateInfoPolicy policy) { m_certificateInfoPolicy = policy; }
-    ContentSecurityPolicyImposition contentSecurityPolicyImposition() const { return m_contentSecurityPolicyImposition; }
-    void setContentSecurityPolicyImposition(ContentSecurityPolicyImposition imposition) { m_contentSecurityPolicyImposition = imposition; }
-    DefersLoadingPolicy defersLoadingPolicy() const { return m_defersLoadingPolicy; }
-    void setDefersLoadingPolicy(DefersLoadingPolicy defersLoadingPolicy) { m_defersLoadingPolicy = defersLoadingPolicy; }
-    CachingPolicy cachingPolicy() const { return m_cachingPolicy; }
-    void setCachingPolicy(CachingPolicy cachingPolicy) { m_cachingPolicy = cachingPolicy; }
-
-    unsigned m_sendLoadCallbacks : 1;
-    unsigned m_sniffContent : 1;
-    unsigned m_dataBufferingPolicy : 1;
-    unsigned m_allowCredentials : 1; // Whether HTTP credentials and cookies are sent with the request.
-    unsigned m_securityCheck : 1;
-    unsigned m_certificateInfoPolicy : 1; // Whether the response should include certificate info.
-    ContentSecurityPolicyImposition m_contentSecurityPolicyImposition { ContentSecurityPolicyImposition::DoPolicyCheck };
-    DefersLoadingPolicy m_defersLoadingPolicy { DefersLoadingPolicy::AllowDefersLoading };
-    CachingPolicy m_cachingPolicy { CachingPolicy::AllowCaching };
+    SendCallbackPolicy sendLoadCallbacks { DoNotSendCallbacks };
+    ContentSniffingPolicy sniffContent { DoNotSniffContent };
+    DataBufferingPolicy dataBufferingPolicy { BufferData };
+    StoredCredentials allowCredentials { DoNotAllowStoredCredentials };
+    SecurityCheckPolicy securityCheck { DoSecurityCheck };
+    CertificateInfoPolicy certificateInfoPolicy { DoNotIncludeCertificateInfo };
+    ContentSecurityPolicyImposition contentSecurityPolicyImposition { ContentSecurityPolicyImposition::DoPolicyCheck };
+    DefersLoadingPolicy defersLoadingPolicy { DefersLoadingPolicy::AllowDefersLoading };
+    CachingPolicy cachingPolicy { CachingPolicy::AllowCaching };
 
     ClientCredentialPolicy clientCredentialPolicy { ClientCredentialPolicy::CannotAskClientForCredentials };
 };
index 676a239..9faecba 100644 (file)
@@ -415,7 +415,7 @@ bool SubresourceLoader::checkRedirectionCrossOriginAccessControl(const ResourceR
     ASSERT(m_origin);
     String errorDescription;
     bool responsePassesCORS = m_origin->canRequest(previousRequest.url())
-        || passesAccessControlCheck(redirectResponse, options().allowCredentials(), *m_origin, errorDescription);
+        || passesAccessControlCheck(redirectResponse, options().allowCredentials, *m_origin, errorDescription);
     if (!responsePassesCORS || !isValidCrossOriginRedirectionURL(newRequest.url())) {
         if (m_frame && m_frame->document()) {
             String errorMessage = "Cross-origin redirection denied by Cross-Origin Resource Sharing policy: " +
@@ -428,7 +428,7 @@ bool SubresourceLoader::checkRedirectionCrossOriginAccessControl(const ResourceR
     // If the request URL origin is not the same as the original origin, the request origin should be set to a globally unique identifier.
     m_origin = SecurityOrigin::createUnique();
     cleanRedirectedRequestForAccessControl(newRequest);
-    updateRequestForAccessControl(newRequest, *m_origin, options().allowCredentials());
+    updateRequestForAccessControl(newRequest, *m_origin, options().allowCredentials);
 
     return true;
 }
index 6c0e59f..c8010c6 100644 (file)
@@ -153,7 +153,7 @@ bool TextTrackLoader::load(const URL& url, const String& crossOriginMode, bool i
     Document* document = downcast<Document>(m_scriptExecutionContext);
 
     ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-    options.setContentSecurityPolicyImposition(isInitiatingElementInUserAgentShadowTree ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+    options.contentSecurityPolicyImposition = isInitiatingElementInUserAgentShadowTree ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
 
     CachedResourceRequest cueRequest(ResourceRequest(document->completeURL(url)), options);
 
index b66d54f..c806051 100644 (file)
@@ -220,7 +220,7 @@ void CachedRawResource::setDefersLoading(bool defers)
 
 void CachedRawResource::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPolicy)
 {
-    m_options.setDataBufferingPolicy(dataBufferingPolicy);
+    m_options.dataBufferingPolicy = dataBufferingPolicy;
 }
 
 static bool shouldIgnoreHeaderForCacheReuse(HTTPHeaderName name)
index dd57875..7db7ed2 100644 (file)
@@ -237,7 +237,7 @@ void CachedResource::load(CachedResourceLoader& cachedResourceLoader, const Reso
     }
 
     FrameLoader& frameLoader = frame.loader();
-    if (options.securityCheck() == DoSecurityCheck && (frameLoader.state() == FrameStateProvisional || !frameLoader.activeDocumentLoader() || frameLoader.activeDocumentLoader()->isStopping())) {
+    if (options.securityCheck == DoSecurityCheck && (frameLoader.state() == FrameStateProvisional || !frameLoader.activeDocumentLoader() || frameLoader.activeDocumentLoader()->isStopping())) {
         failBeforeStarting();
         return;
     }
index 254dd2b..69a8ff5 100644 (file)
@@ -226,10 +226,10 @@ public:
     bool errorOccurred() const { return m_status == LoadError || m_status == DecodeError; }
     bool loadFailedOrCanceled() const { return !m_error.isNull(); }
 
-    bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks() == SendCallbacks; }
-    DataBufferingPolicy dataBufferingPolicy() const { return m_options.dataBufferingPolicy(); }
+    bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks == SendCallbacks; }
+    DataBufferingPolicy dataBufferingPolicy() const { return m_options.dataBufferingPolicy; }
 
-    bool allowsCaching() const { return m_options.cachingPolicy() == CachingPolicy::AllowCaching; }
+    bool allowsCaching() const { return m_options.cachingPolicy == CachingPolicy::AllowCaching; }
 
     virtual void destroyDecodedData() { }
 
index 85b309f..c3409b2 100644 (file)
@@ -390,7 +390,7 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url,
         return false;
     }
 
-    bool skipContentSecurityPolicyCheck = options.contentSecurityPolicyImposition() == ContentSecurityPolicyImposition::SkipPolicyCheck;
+    bool skipContentSecurityPolicyCheck = options.contentSecurityPolicyImposition == ContentSecurityPolicyImposition::SkipPolicyCheck;
     ContentSecurityPolicy::RedirectResponseReceived redirectResponseReceived = didReceiveRedirectResponse ? ContentSecurityPolicy::RedirectResponseReceived::Yes : ContentSecurityPolicy::RedirectResponseReceived::No;
 
     // Some types of resources can be loaded only from the same origin.  Other
index e0fe7c4..60d7000 100644 (file)
@@ -100,10 +100,10 @@ void CachedResourceRequest::setAsPotentiallyCrossOrigin(const String& mode, Docu
         return;
     m_options.mode = FetchOptions::Mode::Cors;
     m_options.credentials = equalLettersIgnoringASCIICase(mode, "use-credentials") ? FetchOptions::Credentials::Include : FetchOptions::Credentials::SameOrigin;
-    m_options.setAllowCredentials(equalLettersIgnoringASCIICase(mode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials);
+    m_options.allowCredentials = equalLettersIgnoringASCIICase(mode, "use-credentials") ? AllowStoredCredentials : DoNotAllowStoredCredentials;
 
     ASSERT(document.securityOrigin());
-    updateRequestForAccessControl(m_resourceRequest, *document.securityOrigin(), m_options.allowCredentials());
+    updateRequestForAccessControl(m_resourceRequest, *document.securityOrigin(), m_options.allowCredentials);
 }
 
 } // namespace WebCore
index 63ff8c4..f3f5685 100644 (file)
@@ -60,7 +60,7 @@ public:
     void setInitiator(PassRefPtr<Element>);
     void setInitiator(const AtomicString& name);
     const AtomicString& initiatorName() const;
-    bool allowsCaching() const { return m_options.cachingPolicy() == CachingPolicy::AllowCaching; }
+    bool allowsCaching() const { return m_options.cachingPolicy == CachingPolicy::AllowCaching; }
 
     void setInitiator(DocumentLoader&);
     DocumentLoader* initiatingDocumentLoader() const { return m_initiatingDocumentLoader.get(); }
index 338701b..b339a8e 100644 (file)
@@ -30,6 +30,7 @@ namespace WebCore {
 
 CachedResourceRequestInitiators::CachedResourceRequestInitiators()
     : css("css", AtomicString::ConstructFromLiteral)
+    , fetch("fetch", AtomicString::ConstructFromLiteral)
     , icon("icon", AtomicString::ConstructFromLiteral)
     , xmlhttprequest("xmlhttprequest", AtomicString::ConstructFromLiteral)
 {
index 26573bb..d7cfe01 100644 (file)
@@ -35,6 +35,7 @@ struct CachedResourceRequestInitiators {
     CachedResourceRequestInitiators();
 
     const AtomicString css;
+    const AtomicString fetch;
     const AtomicString icon;
     const AtomicString xmlhttprequest;
     WTF_MAKE_NONCOPYABLE(CachedResourceRequestInitiators); WTF_MAKE_FAST_ALLOCATED;
index 551484b..317b6ed 100644 (file)
@@ -37,7 +37,7 @@ namespace WebCore {
 
 bool ResourceLoader::shouldCacheResponse(ResourceHandle*, CFCachedURLResponseRef cachedResponse)
 {
-    if (m_options.sendLoadCallbacks() == DoNotSendCallbacks)
+    if (m_options.sendLoadCallbacks == DoNotSendCallbacks)
         return false;
 
     CFURLResponseRef response = CFCachedURLResponseGetWrappedResponse(cachedResponse);
index 5620c90..15e5904 100644 (file)
@@ -51,7 +51,7 @@ CFCachedURLResponseRef ResourceLoader::willCacheResponse(ResourceHandle*, CFCach
 
 NSCachedURLResponse* ResourceLoader::willCacheResponse(ResourceHandle*, NSCachedURLResponse* response)
 {
-    if (m_options.sendLoadCallbacks() == DoNotSendCallbacks)
+    if (m_options.sendLoadCallbacks == DoNotSendCallbacks)
         return nullptr;
     return frameLoader()->client().willCacheResponse(documentLoader(), identifier(), response);
 }
@@ -71,7 +71,7 @@ void ResourceLoader::didReceiveDataArray(CFArrayRef dataArray)
         CFDataRef data = static_cast<CFDataRef>(CFArrayGetValueAtIndex(dataArray, i));
         unsigned dataLen = static_cast<unsigned>(CFDataGetLength(data));
 
-        if (m_options.dataBufferingPolicy() == BufferData) {
+        if (m_options.dataBufferingPolicy == BufferData) {
             if (!m_resourceData)
                 m_resourceData = SharedBuffer::create();
             m_resourceData->append(data);
@@ -80,7 +80,7 @@ void ResourceLoader::didReceiveDataArray(CFArrayRef dataArray)
         // FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
         // However, with today's computers and networking speeds, this won't happen in practice.
         // Could be an issue with a giant local file.
-        if (m_options.sendLoadCallbacks() == SendCallbacks && m_frame)
+        if (m_options.sendLoadCallbacks == SendCallbacks && m_frame)
             frameLoader()->notifier().didReceiveData(this, reinterpret_cast<const char*>(CFDataGetBytePtr(data)), dataLen, dataLen);
     }
 }
index 6552883..817e594 100644 (file)
@@ -104,12 +104,11 @@ void EventSource::connect()
         request.setHTTPHeaderField(HTTPHeaderName::LastEventID, m_lastEventId);
 
     ThreadableLoaderOptions options;
-    options.setSendLoadCallbacks(SendCallbacks);
-    options.setSniffContent(DoNotSniffContent);
+    options.sendLoadCallbacks = SendCallbacks;
     options.credentials = m_withCredentials ? FetchOptions::Credentials::Include : FetchOptions::Credentials::SameOrigin;
     options.preflightPolicy = PreventPreflight;
     options.mode = FetchOptions::Mode::Cors;
-    options.setDataBufferingPolicy(DoNotBufferData);
+    options.dataBufferingPolicy = DoNotBufferData;
     options.contentSecurityPolicyEnforcement = scriptExecutionContext()->shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective;
 
     m_loader = ThreadableLoader::create(scriptExecutionContext(), this, WTFMove(request), options);
index efcd5f5..040bc03 100644 (file)
@@ -48,12 +48,12 @@ static RefPtr<StyleImage> loadPendingImage(Document& document, const StyleImage&
 {
     auto& pendingImage = downcast<StylePendingImage>(image);
     ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-    options.setContentSecurityPolicyImposition(element && element->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+    options.contentSecurityPolicyImposition = element && element->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
 
     // FIXME: Why does shape-outside have different policy than other properties?
     if (loadPolicy == LoadPolicy::ShapeOutside) {
         options.mode = FetchOptions::Mode::Cors;
-        options.setAllowCredentials(DoNotAllowStoredCredentials);
+        options.allowCredentials = DoNotAllowStoredCredentials;
     }
 
     if (auto imageValue = pendingImage.cssImageValue())
@@ -171,7 +171,7 @@ static void loadPendingSVGFilters(const PendingResources& pendingResources, Docu
         return;
 
     ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-    options.setContentSecurityPolicyImposition(element && element->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+    options.contentSecurityPolicyImposition = element && element->isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
 
     for (auto& filterOperation : pendingResources.pendingSVGFilters)
         filterOperation->getOrCreateCachedSVGDocumentReference()->load(document.cachedResourceLoader(), options);
index b67e2e8..ef2aed8 100644 (file)
@@ -86,7 +86,7 @@ void SVGFEImageElement::clearResourceReferences()
 void SVGFEImageElement::requestImageResource()
 {
     ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-    options.setContentSecurityPolicyImposition(isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+    options.contentSecurityPolicyImposition = isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
 
     CachedResourceRequest request(ResourceRequest(document().completeURL(href())), options);
     request.setInitiator(this);
index e38dbe3..e747961 100644 (file)
@@ -101,7 +101,7 @@ void SVGFontFaceUriElement::loadFont()
     const AtomicString& href = getAttribute(XLinkNames::hrefAttr);
     if (!href.isNull()) {
         ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-        options.setContentSecurityPolicyImposition(isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+        options.contentSecurityPolicyImposition = isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
 
         CachedResourceLoader& cachedResourceLoader = document().cachedResourceLoader();
         CachedResourceRequest request(ResourceRequest(document().completeURL(href)), options);
index 395000b..26d9293 100644 (file)
@@ -569,7 +569,7 @@ void SVGUseElement::updateExternalDocument()
         m_externalDocument = nullptr;
     else {
         ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
-        options.setContentSecurityPolicyImposition(isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck);
+        options.contentSecurityPolicyImposition = isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
 
         CachedResourceRequest request { ResourceRequest { externalDocumentURL }, options };
         request.setInitiator(this);
index 3bfd60d..67f9cca 100644 (file)
@@ -70,7 +70,7 @@ void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecuti
     ThreadableLoaderOptions options;
     options.credentials = FetchOptions::Credentials::Include;
     options.mode = mode;
-    options.setSendLoadCallbacks(SendCallbacks);
+    options.sendLoadCallbacks = SendCallbacks;
     options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement;
 
     WorkerThreadableLoader::loadResourceSynchronously(downcast<WorkerGlobalScope>(scriptExecutionContext), WTFMove(*request), *this, options);
@@ -93,7 +93,7 @@ void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecut
     ThreadableLoaderOptions options;
     options.credentials = FetchOptions::Credentials::SameOrigin;
     options.mode = mode;
-    options.setSendLoadCallbacks(SendCallbacks);
+    options.sendLoadCallbacks = SendCallbacks;
     options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement;
 
     // During create, callbacks may happen which remove the last reference to this object.
index e25b080..7dfeb6f 100644 (file)
@@ -687,8 +687,7 @@ void XMLHttpRequest::createRequest(ExceptionCode& ec)
         request.setHTTPHeaderFields(m_requestHeaders);
 
     ThreadableLoaderOptions options;
-    options.setSendLoadCallbacks(SendCallbacks);
-    options.setSniffContent(DoNotSniffContent);
+    options.sendLoadCallbacks = SendCallbacks;
     options.preflightPolicy = uploadEvents ? ForcePreflight : ConsiderPreflight;
     options.credentials = m_includeCredentials ? FetchOptions::Credentials::Include : FetchOptions::Credentials::SameOrigin;
     options.mode = FetchOptions::Mode::Cors;