Remove use of emptySessionID from NetworkLoadParameters
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Aug 2019 17:24:17 +0000 (17:24 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Aug 2019 17:24:17 +0000 (17:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200712

Reviewed by Alex Christensen.

Make NetworkLoadParameters constructor take a session ID.
Update call sites accordingly.

* NetworkProcess/AdClickAttributionManager.cpp:
(WebKit::AdClickAttributionManager::fireConversionRequest):
* NetworkProcess/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::startDownload):
* NetworkProcess/NetworkCORSPreflightChecker.cpp:
(WebKit::NetworkCORSPreflightChecker::startPreflight):
* NetworkProcess/NetworkLoadParameters.h:
(WebKit::NetworkLoadParameters::NetworkLoadParameters):
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::preconnectTo):
* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::encode const):
(WebKit::NetworkResourceLoadParameters::decode):
* NetworkProcess/NetworkResourceLoadParameters.h:
(WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
* NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
(WebKit::NetworkCache::SpeculativeLoad::SpeculativeLoad):
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
(WebKit::WebLoaderStrategy::loadResourceSynchronously):
(WebKit::WebLoaderStrategy::startPingLoad):
(WebKit::WebLoaderStrategy::preconnectTo):

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

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/AdClickAttributionManager.cpp
Source/WebKit/NetworkProcess/Downloads/DownloadManager.cpp
Source/WebKit/NetworkProcess/NetworkCORSPreflightChecker.cpp
Source/WebKit/NetworkProcess/NetworkLoadParameters.h
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp
Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h
Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp

index 0f17825..54b7977 100644 (file)
@@ -1,5 +1,38 @@
 2019-08-14  Youenn Fablet  <youenn@apple.com>
 
+        Remove use of emptySessionID from NetworkLoadParameters
+        https://bugs.webkit.org/show_bug.cgi?id=200712
+
+        Reviewed by Alex Christensen.
+
+        Make NetworkLoadParameters constructor take a session ID.
+        Update call sites accordingly.
+
+        * NetworkProcess/AdClickAttributionManager.cpp:
+        (WebKit::AdClickAttributionManager::fireConversionRequest):
+        * NetworkProcess/Downloads/DownloadManager.cpp:
+        (WebKit::DownloadManager::startDownload):
+        * NetworkProcess/NetworkCORSPreflightChecker.cpp:
+        (WebKit::NetworkCORSPreflightChecker::startPreflight):
+        * NetworkProcess/NetworkLoadParameters.h:
+        (WebKit::NetworkLoadParameters::NetworkLoadParameters):
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::preconnectTo):
+        * NetworkProcess/NetworkResourceLoadParameters.cpp:
+        (WebKit::NetworkResourceLoadParameters::encode const):
+        (WebKit::NetworkResourceLoadParameters::decode):
+        * NetworkProcess/NetworkResourceLoadParameters.h:
+        (WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp:
+        (WebKit::NetworkCache::SpeculativeLoad::SpeculativeLoad):
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
+        (WebKit::WebLoaderStrategy::loadResourceSynchronously):
+        (WebKit::WebLoaderStrategy::startPingLoad):
+        (WebKit::WebLoaderStrategy::preconnectTo):
+
+2019-08-14  Youenn Fablet  <youenn@apple.com>
+
         Remove use of emptySessionID from WebPageCreationParameters
         https://bugs.webkit.org/show_bug.cgi?id=200708
 
index 1d7b133..909ea53 100644 (file)
@@ -163,12 +163,11 @@ void AdClickAttributionManager::fireConversionRequest(const AdClickAttribution&
 
     static uint64_t identifier = 0;
     
-    NetworkResourceLoadParameters loadParameters;
+    NetworkResourceLoadParameters loadParameters { PAL::SessionID::defaultSessionID() };
     loadParameters.identifier = ++identifier;
     loadParameters.request = request;
     loadParameters.sourceOrigin = SecurityOrigin::create(conversionReferrerURL);
     loadParameters.parentPID = presentingApplicationPID();
-    loadParameters.sessionID = PAL::SessionID::defaultSessionID();
     loadParameters.storedCredentialsPolicy = StoredCredentialsPolicy::EphemeralStatelessCookieless;
     loadParameters.options = options;
     loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = true;
index fffb473..f4d75d9 100644 (file)
@@ -49,8 +49,7 @@ void DownloadManager::startDownload(PAL::SessionID sessionID, DownloadID downloa
     if (!networkSession)
         return;
 
-    NetworkLoadParameters parameters;
-    parameters.sessionID = sessionID;
+    NetworkLoadParameters parameters { sessionID };
     parameters.request = request;
     parameters.clientCredentialPolicy = ClientCredentialPolicy::MayAskClientForCredentials;
     if (request.url().protocolIsBlob())
index 94f1277..4adf1d3 100644 (file)
@@ -63,8 +63,7 @@ void NetworkCORSPreflightChecker::startPreflight()
 {
     RELEASE_LOG_IF_ALLOWED("startPreflight");
 
-    NetworkLoadParameters loadParameters;
-    loadParameters.sessionID = m_parameters.sessionID;
+    NetworkLoadParameters loadParameters { m_parameters.sessionID };
     loadParameters.request = createAccessControlPreflightRequest(m_parameters.originalRequest, m_parameters.sourceOrigin, m_parameters.referrer);
     if (!m_parameters.userAgent.isNull())
         loadParameters.request.setHTTPHeaderField(HTTPHeaderName::UserAgent, m_parameters.userAgent);
index cfb2c75..c43e5dc 100644 (file)
@@ -39,10 +39,15 @@ enum class PreconnectOnly { No, Yes };
 
 class NetworkLoadParameters {
 public:
+    explicit NetworkLoadParameters(PAL::SessionID sessionID)
+        : sessionID(sessionID)
+    {
+    }
+
+    PAL::SessionID sessionID;
     WebCore::PageIdentifier webPageID;
     uint64_t webFrameID { 0 };
     WTF::ProcessID parentPID { 0 };
-    PAL::SessionID sessionID { PAL::SessionID::emptySessionID() };
     WebCore::ResourceRequest request;
     WebCore::ContentSniffingPolicy contentSniffingPolicy { WebCore::ContentSniffingPolicy::SniffContent };
     WebCore::ContentEncodingSniffingPolicy contentEncodingSniffingPolicy { WebCore::ContentEncodingSniffingPolicy::Sniff };
index 38aca8d..e54a54f 100644 (file)
@@ -2223,9 +2223,8 @@ void NetworkProcess::setCacheStorageParameters(PAL::SessionID sessionID, String&
 void NetworkProcess::preconnectTo(const URL& url, WebCore::StoredCredentialsPolicy storedCredentialsPolicy)
 {
 #if ENABLE(SERVER_PRECONNECT)
-    NetworkLoadParameters parameters;
+    NetworkLoadParameters parameters { PAL::SessionID::defaultSessionID() };
     parameters.request = ResourceRequest { url };
-    parameters.sessionID = PAL::SessionID::defaultSessionID();
     parameters.storedCredentialsPolicy = storedCredentialsPolicy;
     parameters.shouldPreconnectOnly = PreconnectOnly::Yes;
 
index bf8a0a6..4bf2ac0 100644 (file)
@@ -33,11 +33,11 @@ using namespace WebCore;
 
 void NetworkResourceLoadParameters::encode(IPC::Encoder& encoder) const
 {
+    encoder << sessionID;
     encoder << identifier;
     encoder << webPageID;
     encoder << webFrameID;
     encoder << parentPID;
-    encoder << sessionID;
     encoder << request;
 
     encoder << static_cast<bool>(request.httpBody());
@@ -103,43 +103,48 @@ void NetworkResourceLoadParameters::encode(IPC::Encoder& encoder) const
 #endif
 }
 
-bool NetworkResourceLoadParameters::decode(IPC::Decoder& decoder, NetworkResourceLoadParameters& result)
+Optional<NetworkResourceLoadParameters> NetworkResourceLoadParameters::decode(IPC::Decoder& decoder)
 {
+    Optional<PAL::SessionID> sessionID;
+    decoder >> sessionID;
+
+    if (!sessionID)
+        return WTF::nullopt;
+
+    NetworkResourceLoadParameters result { *sessionID };
+
     if (!decoder.decode(result.identifier))
-        return false;
+        return WTF::nullopt;
 
     Optional<PageIdentifier> webPageID;
     decoder >> webPageID;
     if (!webPageID)
-        return false;
+        return WTF::nullopt;
     result.webPageID = *webPageID;
 
     if (!decoder.decode(result.webFrameID))
-        return false;
+        return WTF::nullopt;
 
     if (!decoder.decode(result.parentPID))
-        return false;
-
-    if (!decoder.decode(result.sessionID))
-        return false;
+        return WTF::nullopt;
 
     if (!decoder.decode(result.request))
-        return false;
+        return WTF::nullopt;
 
     bool hasHTTPBody;
     if (!decoder.decode(hasHTTPBody))
-        return false;
+        return WTF::nullopt;
 
     if (hasHTTPBody) {
         RefPtr<FormData> formData = FormData::decode(decoder);
         if (!formData)
-            return false;
+            return WTF::nullopt;
         result.request.setHTTPBody(WTFMove(formData));
 
         Optional<SandboxExtension::HandleArray> requestBodySandboxExtensionHandles;
         decoder >> requestBodySandboxExtensionHandles;
         if (!requestBodySandboxExtensionHandles)
-            return false;
+            return WTF::nullopt;
         for (size_t i = 0; i < requestBodySandboxExtensionHandles->size(); ++i) {
             if (auto extension = SandboxExtension::create(WTFMove(requestBodySandboxExtensionHandles->at(i))))
                 result.requestBodySandboxExtensions.append(WTFMove(extension));
@@ -150,87 +155,87 @@ bool NetworkResourceLoadParameters::decode(IPC::Decoder& decoder, NetworkResourc
         Optional<SandboxExtension::Handle> resourceSandboxExtensionHandle;
         decoder >> resourceSandboxExtensionHandle;
         if (!resourceSandboxExtensionHandle)
-            return false;
+            return WTF::nullopt;
         result.resourceSandboxExtension = SandboxExtension::create(WTFMove(*resourceSandboxExtensionHandle));
     }
 
     if (!decoder.decodeEnum(result.contentSniffingPolicy))
-        return false;
+        return WTF::nullopt;
     if (!decoder.decodeEnum(result.contentEncodingSniffingPolicy))
-        return false;
+        return WTF::nullopt;
     if (!decoder.decodeEnum(result.storedCredentialsPolicy))
-        return false;
+        return WTF::nullopt;
     if (!decoder.decodeEnum(result.clientCredentialPolicy))
-        return false;
+        return WTF::nullopt;
     if (!decoder.decodeEnum(result.shouldPreconnectOnly))
-        return false;
+        return WTF::nullopt;
     if (!decoder.decode(result.shouldClearReferrerOnHTTPSToHTTPRedirect))
-        return false;
+        return WTF::nullopt;
     if (!decoder.decode(result.needsCertificateInfo))
-        return false;
+        return WTF::nullopt;
     if (!decoder.decode(result.isMainFrameNavigation))
-        return false;
+        return WTF::nullopt;
     if (!decoder.decode(result.isMainResourceNavigationForAnyFrame))
-        return false;
+        return WTF::nullopt;
     if (!decoder.decode(result.maximumBufferingTime))
-        return false;
+        return WTF::nullopt;
 
     bool hasSourceOrigin;
     if (!decoder.decode(hasSourceOrigin))
-        return false;
+        return WTF::nullopt;
     if (hasSourceOrigin) {
         result.sourceOrigin = SecurityOrigin::decode(decoder);
         if (!result.sourceOrigin)
-            return false;
+            return WTF::nullopt;
     }
 
     Optional<FetchOptions> options;
     decoder >> options;
     if (!options)
-        return false;
+        return WTF::nullopt;
     result.options = *options;
 
     if (!decoder.decode(result.cspResponseHeaders))
-        return false;
+        return WTF::nullopt;
     if (!decoder.decode(result.originalRequestHeaders))
-        return false;
+        return WTF::nullopt;
 
     Optional<bool> shouldRestrictHTTPResponseAccess;
     decoder >> shouldRestrictHTTPResponseAccess;
     if (!shouldRestrictHTTPResponseAccess)
-        return false;
+        return WTF::nullopt;
     result.shouldRestrictHTTPResponseAccess = *shouldRestrictHTTPResponseAccess;
 
     if (!decoder.decodeEnum(result.preflightPolicy))
-        return false;
+        return WTF::nullopt;
 
     Optional<bool> shouldEnableCrossOriginResourcePolicy;
     decoder >> shouldEnableCrossOriginResourcePolicy;
     if (!shouldEnableCrossOriginResourcePolicy)
-        return false;
+        return WTF::nullopt;
     result.shouldEnableCrossOriginResourcePolicy = *shouldEnableCrossOriginResourcePolicy;
 
     if (!decoder.decode(result.frameAncestorOrigins))
-        return false;
+        return WTF::nullopt;
 
     Optional<bool> isHTTPSUpgradeEnabled;
     decoder >> isHTTPSUpgradeEnabled;
     if (!isHTTPSUpgradeEnabled)
-        return false;
+        return WTF::nullopt;
     result.isHTTPSUpgradeEnabled = *isHTTPSUpgradeEnabled;
     
 #if ENABLE(CONTENT_EXTENSIONS)
     if (!decoder.decode(result.mainDocumentURL))
-        return false;
+        return WTF::nullopt;
 
     Optional<Optional<UserContentControllerIdentifier>> userContentControllerIdentifier;
     decoder >> userContentControllerIdentifier;
     if (!userContentControllerIdentifier)
-        return false;
+        return WTF::nullopt;
     result.userContentControllerIdentifier = *userContentControllerIdentifier;
 #endif
 
-    return true;
+    return result;
 }
     
 } // namespace WebKit
index b05ff80..fcc8bf5 100644 (file)
@@ -44,8 +44,13 @@ typedef uint64_t ResourceLoadIdentifier;
 
 class NetworkResourceLoadParameters : public NetworkLoadParameters {
 public:
+    explicit NetworkResourceLoadParameters(PAL::SessionID sessionID)
+        : NetworkLoadParameters(sessionID)
+    {
+    }
+
     void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, NetworkResourceLoadParameters&);
+    static Optional<NetworkResourceLoadParameters> decode(IPC::Decoder&);
 
     ResourceLoadIdentifier identifier { 0 };
     Vector<RefPtr<SandboxExtension>> requestBodySandboxExtensions; // Created automatically for the sender.
index e7fc5b8..94b6068 100644 (file)
@@ -52,10 +52,9 @@ SpeculativeLoad::SpeculativeLoad(Cache& cache, const GlobalFrameID& globalFrameI
 {
     ASSERT(!m_cacheEntry || m_cacheEntry->needsValidation());
 
-    NetworkLoadParameters parameters;
+    NetworkLoadParameters parameters { PAL::SessionID::defaultSessionID() };
     parameters.webPageID = globalFrameID.first;
     parameters.webFrameID = globalFrameID.second;
-    parameters.sessionID = PAL::SessionID::defaultSessionID();
     parameters.storedCredentialsPolicy = StoredCredentialsPolicy::Use;
     parameters.contentSniffingPolicy = ContentSniffingPolicy::DoNotSniffContent;
     parameters.contentEncodingSniffingPolicy = ContentEncodingSniffingPolicy::Sniff;
index 5026954..c48cdd8 100644 (file)
@@ -266,12 +266,11 @@ void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceL
     ContentEncodingSniffingPolicy contentEncodingSniffingPolicy = resourceLoader.shouldSniffContentEncoding() ? ContentEncodingSniffingPolicy::Sniff : ContentEncodingSniffingPolicy::DoNotSniff;
     StoredCredentialsPolicy storedCredentialsPolicy = resourceLoader.shouldUseCredentialStorage() ? StoredCredentialsPolicy::Use : StoredCredentialsPolicy::DoNotUse;
 
-    NetworkResourceLoadParameters loadParameters;
+    NetworkResourceLoadParameters loadParameters { sessionID };
     loadParameters.identifier = identifier;
     loadParameters.webPageID = trackingParameters.pageID;
     loadParameters.webFrameID = trackingParameters.frameID;
     loadParameters.parentPID = presentingApplicationPID();
-    loadParameters.sessionID = sessionID;
     loadParameters.request = request;
     loadParameters.contentSniffingPolicy = contentSniffingPolicy;
     loadParameters.contentEncodingSniffingPolicy = contentEncodingSniffingPolicy;
@@ -539,12 +538,11 @@ void WebLoaderStrategy::loadResourceSynchronously(FrameLoader& frameLoader, unsi
         return;
     }
 
-    NetworkResourceLoadParameters loadParameters;
+    NetworkResourceLoadParameters loadParameters { sessionID };
     loadParameters.identifier = resourceLoadIdentifier;
     loadParameters.webPageID = pageID;
     loadParameters.webFrameID = frameID;
     loadParameters.parentPID = presentingApplicationPID();
-    loadParameters.sessionID = sessionID;
     loadParameters.request = request;
     loadParameters.contentSniffingPolicy = ContentSniffingPolicy::SniffContent;
     loadParameters.contentEncodingSniffingPolicy = ContentEncodingSniffingPolicy::Sniff;
@@ -607,12 +605,11 @@ void WebLoaderStrategy::startPingLoad(Frame& frame, ResourceRequest& request, co
         return;
     }
 
-    NetworkResourceLoadParameters loadParameters;
+    NetworkResourceLoadParameters loadParameters { frame.page() ? frame.page()->sessionID() : PAL::SessionID::defaultSessionID() };
     loadParameters.identifier = generateLoadIdentifier();
     loadParameters.request = request;
     loadParameters.sourceOrigin = &document->securityOrigin();
     loadParameters.parentPID = presentingApplicationPID();
-    loadParameters.sessionID = frame.page() ? frame.page()->sessionID() : PAL::SessionID::defaultSessionID();
     loadParameters.storedCredentialsPolicy = options.credentials == FetchOptions::Credentials::Omit ? StoredCredentialsPolicy::DoNotUse : StoredCredentialsPolicy::Use;
     loadParameters.options = options;
     loadParameters.originalRequestHeaders = originalRequestHeaders;
@@ -667,12 +664,11 @@ void WebLoaderStrategy::preconnectTo(FrameLoader& frameLoader, const URL& url, S
         return;
     }
 
-    NetworkResourceLoadParameters parameters;
+    NetworkResourceLoadParameters parameters { webPage->sessionID() };
     parameters.request = ResourceRequest { url };
     parameters.webPageID = webPage->pageID();
     parameters.webFrameID = webFrame->frameID();
     parameters.parentPID = presentingApplicationPID();
-    parameters.sessionID = webPage->sessionID();
     parameters.storedCredentialsPolicy = storedCredentialsPolicy;
     parameters.shouldPreconnectOnly = PreconnectOnly::Yes;
     parameters.shouldRestrictHTTPResponseAccess = shouldPerformSecurityChecks();