Title: [275116] trunk/Source/WebKit
Revision
275116
Author
[email protected]
Date
2021-03-26 15:05:35 -0700 (Fri, 26 Mar 2021)

Log Message

Refactor NetworkSessionCocoa to prepare for per-WebPageProxy sessions
https://bugs.webkit.org/show_bug.cgi?id=223776

Reviewed by Alex Christensen.

No new tests (No behavior change refactor)

A NetworkSessionCocoa has (n) NSURLSessions associated with it.

When a network load needs to happen - based on the context for that load - the appropriate
NSURLSession is chosen (or created).

In a future patch, there will be an additional bit of context used for choosing the appropriate
NSURLSession - The WKWebView the load was triggered from.

This patch takes those (n) NSURLSessions and wraps them in a SessionSet object.
It also adds the concept of looking up the appropriate SessionSet based on the WebPageProxyIdentifier
triggering the load.

This patch by itself should not be a behavior change, but allows the followup to be much simpler.

* NetworkProcess/Downloads/cocoa/DownloadCocoa.mm:
(WebKit::Download::resume):

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::createSocketChannel):
(WebKit::NetworkConnectionToWebProcess::establishSWContextConnection):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:

* NetworkProcess/NetworkDataTask.cpp:
(WebKit::NetworkDataTask::create):

* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::createWebSocketTask):
* NetworkProcess/NetworkSession.h:
(WebKit::NetworkSession::removeWebSocketTask):
(WebKit::NetworkSession::addWebSocketTask):

* NetworkProcess/NetworkSocketChannel.cpp:
(WebKit::NetworkSocketChannel::create):
(WebKit::NetworkSocketChannel::NetworkSocketChannel):
(WebKit::NetworkSocketChannel::~NetworkSocketChannel):
* NetworkProcess/NetworkSocketChannel.h:

* NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
(WebKit::WebSWServerToContextConnection::WebSWServerToContextConnection):
* NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:

* NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):

* NetworkProcess/cocoa/NetworkSessionCocoa.h:
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::NetworkSessionCocoa::hstsStorage const):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
(WebKit::NetworkSessionCocoa::initializeStandardSessionsInSet):
(WebKit::NetworkSessionCocoa::sessionSetForPage):
(WebKit::NetworkSessionCocoa::sessionSetForPage const):
(WebKit::NetworkSessionCocoa::initializeEphemeralStatelessSessionIfNeeded):
(WebKit::NetworkSessionCocoa::SessionSet::initializeEphemeralStatelessSessionIfNeeded):
(WebKit::NetworkSessionCocoa::sessionWrapperForTask):
(WebKit::NetworkSessionCocoa::appBoundSession):
(WebKit::NetworkSessionCocoa::hasAppBoundSession const):
(WebKit::NetworkSessionCocoa::clearAppBoundSession):
(WebKit::NetworkSessionCocoa::isolatedSession):
(WebKit::NetworkSessionCocoa::SessionSet::isolatedSession):
(WebKit::NetworkSessionCocoa::hasIsolatedSession const):
(WebKit::NetworkSessionCocoa::clearIsolatedSessions):
(WebKit::NetworkSessionCocoa::invalidateAndCancelSessionSet):
(WebKit::NetworkSessionCocoa::invalidateAndCancel):
(WebKit::NetworkSessionCocoa::createWebSocketTask):
(WebKit::NetworkSessionCocoa::addWebSocketTask):
(WebKit::NetworkSessionCocoa::removeWebSocketTask):
(WebKit::NetworkSessionCocoa::hostNamesWithAlternativeServices const):
(WebKit::NetworkSessionCocoa::deleteAlternativeServicesForHostNames):
(WebKit::NetworkSessionCocoa::clearAlternativeServices):
(WebKit::NetworkSessionCocoa::initializeEphemeralStatelessSession): Deleted.

* NetworkProcess/soup/NetworkSessionSoup.cpp:
(WebKit::NetworkSessionSoup::createWebSocketTask):
* NetworkProcess/soup/NetworkSessionSoup.h:

* Shared/AuxiliaryProcess.cpp:
(WebKit::AuxiliaryProcess::initialize):

* WebProcess/Network/WebSocketChannel.cpp:
(WebKit::WebSocketChannel::create):
(WebKit::WebSocketChannel::WebSocketChannel):
(WebKit::WebSocketChannel::connect):
* WebProcess/Network/WebSocketChannel.h:

* WebProcess/Network/WebSocketProvider.cpp:
(WebKit::WebSocketProvider::createWebSocketChannel):
* WebProcess/Network/WebSocketProvider.h:

* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::establishConnection):
(WebKit::WebSWContextManagerConnection::installServiceWorker):

* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_lastNavigationWasAppBound):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (275115 => 275116)


--- trunk/Source/WebKit/ChangeLog	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/ChangeLog	2021-03-26 22:05:35 UTC (rev 275116)
@@ -1,3 +1,109 @@
+2021-03-26  Brady Eidson  <[email protected]>
+
+        Refactor NetworkSessionCocoa to prepare for per-WebPageProxy sessions
+        https://bugs.webkit.org/show_bug.cgi?id=223776
+
+        Reviewed by Alex Christensen.
+
+        No new tests (No behavior change refactor)
+
+        A NetworkSessionCocoa has (n) NSURLSessions associated with it.
+        
+        When a network load needs to happen - based on the context for that load - the appropriate
+        NSURLSession is chosen (or created).
+        
+        In a future patch, there will be an additional bit of context used for choosing the appropriate
+        NSURLSession - The WKWebView the load was triggered from.
+        
+        This patch takes those (n) NSURLSessions and wraps them in a SessionSet object.
+        It also adds the concept of looking up the appropriate SessionSet based on the WebPageProxyIdentifier
+        triggering the load.
+        
+        This patch by itself should not be a behavior change, but allows the followup to be much simpler.
+        
+        * NetworkProcess/Downloads/cocoa/DownloadCocoa.mm:
+        (WebKit::Download::resume):
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::createSocketChannel):
+        (WebKit::NetworkConnectionToWebProcess::establishSWContextConnection):
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+
+        * NetworkProcess/NetworkDataTask.cpp:
+        (WebKit::NetworkDataTask::create):
+
+        * NetworkProcess/NetworkSession.cpp:
+        (WebKit::NetworkSession::createWebSocketTask):
+        * NetworkProcess/NetworkSession.h:
+        (WebKit::NetworkSession::removeWebSocketTask):
+        (WebKit::NetworkSession::addWebSocketTask):
+
+        * NetworkProcess/NetworkSocketChannel.cpp:
+        (WebKit::NetworkSocketChannel::create):
+        (WebKit::NetworkSocketChannel::NetworkSocketChannel):
+        (WebKit::NetworkSocketChannel::~NetworkSocketChannel):
+        * NetworkProcess/NetworkSocketChannel.h:
+
+        * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
+        (WebKit::WebSWServerToContextConnection::WebSWServerToContextConnection):
+        * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:
+
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::NetworkDataTaskCocoa::NetworkDataTaskCocoa):
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.h:
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (WebKit::NetworkSessionCocoa::hstsStorage const):
+        (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
+        (WebKit::NetworkSessionCocoa::initializeStandardSessionsInSet):
+        (WebKit::NetworkSessionCocoa::sessionSetForPage):
+        (WebKit::NetworkSessionCocoa::sessionSetForPage const):
+        (WebKit::NetworkSessionCocoa::initializeEphemeralStatelessSessionIfNeeded):
+        (WebKit::NetworkSessionCocoa::SessionSet::initializeEphemeralStatelessSessionIfNeeded):
+        (WebKit::NetworkSessionCocoa::sessionWrapperForTask):
+        (WebKit::NetworkSessionCocoa::appBoundSession):
+        (WebKit::NetworkSessionCocoa::hasAppBoundSession const):
+        (WebKit::NetworkSessionCocoa::clearAppBoundSession):
+        (WebKit::NetworkSessionCocoa::isolatedSession):
+        (WebKit::NetworkSessionCocoa::SessionSet::isolatedSession):
+        (WebKit::NetworkSessionCocoa::hasIsolatedSession const):
+        (WebKit::NetworkSessionCocoa::clearIsolatedSessions):
+        (WebKit::NetworkSessionCocoa::invalidateAndCancelSessionSet):
+        (WebKit::NetworkSessionCocoa::invalidateAndCancel):
+        (WebKit::NetworkSessionCocoa::createWebSocketTask):
+        (WebKit::NetworkSessionCocoa::addWebSocketTask):
+        (WebKit::NetworkSessionCocoa::removeWebSocketTask):
+        (WebKit::NetworkSessionCocoa::hostNamesWithAlternativeServices const):
+        (WebKit::NetworkSessionCocoa::deleteAlternativeServicesForHostNames):
+        (WebKit::NetworkSessionCocoa::clearAlternativeServices):
+        (WebKit::NetworkSessionCocoa::initializeEphemeralStatelessSession): Deleted.
+        
+        * NetworkProcess/soup/NetworkSessionSoup.cpp:
+        (WebKit::NetworkSessionSoup::createWebSocketTask):
+        * NetworkProcess/soup/NetworkSessionSoup.h:
+        
+        * Shared/AuxiliaryProcess.cpp:
+        (WebKit::AuxiliaryProcess::initialize):
+        
+        * WebProcess/Network/WebSocketChannel.cpp:
+        (WebKit::WebSocketChannel::create):
+        (WebKit::WebSocketChannel::WebSocketChannel):
+        (WebKit::WebSocketChannel::connect):
+        * WebProcess/Network/WebSocketChannel.h:
+        
+        * WebProcess/Network/WebSocketProvider.cpp:
+        (WebKit::WebSocketProvider::createWebSocketChannel):
+        * WebProcess/Network/WebSocketProvider.h:
+        
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::WebSWContextManagerConnection::establishConnection):
+        (WebKit::WebSWContextManagerConnection::installServiceWorker):
+        
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_lastNavigationWasAppBound):
+
 2021-03-26  Wenson Hsieh  <[email protected]>
 
         Allow some image overlay content to render in fully transparent image elements

Modified: trunk/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/Downloads/cocoa/DownloadCocoa.mm	2021-03-26 22:05:35 UTC (rev 275116)
@@ -73,10 +73,10 @@
 
     // FIXME: Use nsData instead of updatedData once we've migrated from _WKDownload to WKDownload
     // because there's no reason to set the local path we got from the data back into the data.
-    m_downloadTask = [cocoaSession.sessionWrapperForDownloads().session downloadTaskWithResumeData:updatedData];
+    m_downloadTask = [cocoaSession.sessionWrapperForDownloadResume().session downloadTaskWithResumeData:updatedData];
     auto taskIdentifier = [m_downloadTask taskIdentifier];
-    ASSERT(!cocoaSession.sessionWrapperForDownloads().downloadMap.contains(taskIdentifier));
-    cocoaSession.sessionWrapperForDownloads().downloadMap.add(taskIdentifier, m_downloadID);
+    ASSERT(!cocoaSession.sessionWrapperForDownloadResume().downloadMap.contains(taskIdentifier));
+    cocoaSession.sessionWrapperForDownloadResume().downloadMap.add(taskIdentifier, m_downloadID);
     m_downloadTask.get()._pathToDownloadTaskFile = path;
 
     [m_downloadTask resume];

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -404,10 +404,10 @@
     m_networkSocketStreams.add(identifier, NetworkSocketStream::create(m_networkProcess.get(), WTFMove(url), m_sessionID, cachePartition, identifier, m_connection, WTFMove(token)));
 }
 
-void NetworkConnectionToWebProcess::createSocketChannel(const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier)
+void NetworkConnectionToWebProcess::createSocketChannel(const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier,  WebPageProxyIdentifier webPageProxyID)
 {
     ASSERT(!m_networkSocketChannels.contains(identifier));
-    if (auto channel = NetworkSocketChannel::create(*this, m_sessionID, request, protocol, identifier))
+    if (auto channel = NetworkSocketChannel::create(*this, m_sessionID, request, protocol, identifier, webPageProxyID))
         m_networkSocketChannels.add(identifier, WTFMove(channel));
 }
 
@@ -1092,10 +1092,10 @@
     server.addConnection(WTFMove(connection));
 }
 
-void NetworkConnectionToWebProcess::establishSWContextConnection(RegistrableDomain&& registrableDomain, CompletionHandler<void()>&& completionHandler)
+void NetworkConnectionToWebProcess::establishSWContextConnection(WebPageProxyIdentifier webPageProxyID, RegistrableDomain&& registrableDomain, CompletionHandler<void()>&& completionHandler)
 {
     if (auto* server = m_networkProcess->swServerForSessionIfExists(m_sessionID))
-        m_swContextConnection = makeUnique<WebSWServerToContextConnection>(*this, WTFMove(registrableDomain), *server);
+        m_swContextConnection = makeUnique<WebSWServerToContextConnection>(*this, webPageProxyID, WTFMove(registrableDomain), *server);
     completionHandler();
 }
 

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2021-03-26 22:05:35 UTC (rev 275116)
@@ -240,12 +240,12 @@
 
     void createSocketStream(URL&&, String cachePartition, WebCore::WebSocketIdentifier);
 
-    void createSocketChannel(const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier);
+    void createSocketChannel(const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier, WebPageProxyIdentifier);
     void updateQuotaBasedOnSpaceUsageForTesting(const WebCore::ClientOrigin&);
 
 #if ENABLE(SERVICE_WORKER)
     void establishSWServerConnection();
-    void establishSWContextConnection(WebCore::RegistrableDomain&&, CompletionHandler<void()>&&);
+    void establishSWContextConnection(WebPageProxyIdentifier, WebCore::RegistrableDomain&&, CompletionHandler<void()>&&);
     void closeSWContextConnection();
     void unregisterSWConnection();
 #endif

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in	2021-03-26 22:05:35 UTC (rev 275116)
@@ -60,7 +60,7 @@
     SetCaptureExtraNetworkLoadMetricsEnabled(bool enabled)
 
     CreateSocketStream(URL url, String cachePartition, WebCore::WebSocketIdentifier identifier)
-    CreateSocketChannel(WebCore::ResourceRequest request, String protocol, WebCore::WebSocketIdentifier identifier)
+    CreateSocketChannel(WebCore::ResourceRequest request, String protocol, WebCore::WebSocketIdentifier identifier, WebKit::WebPageProxyIdentifier webPageProxyID)
 
     ClearPageSpecificData(WebCore::PageIdentifier pageID);
 
@@ -82,7 +82,7 @@
     TakeNetworkLoadInformationMetrics(uint64_t resourceLoadIdentifier) -> (WebCore::NetworkLoadMetrics networkMetrics) Synchronous
 
 #if ENABLE(SERVICE_WORKER)
-    EstablishSWContextConnection(WebCore::RegistrableDomain domain) -> () Async
+    EstablishSWContextConnection(WebKit::WebPageProxyIdentifier webPageProxyID, WebCore::RegistrableDomain domain) -> () Async
     CloseSWContextConnection()
 #endif
 

Modified: trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -54,7 +54,7 @@
     ASSERT(!parameters.request.url().protocolIsBlob());
 #if PLATFORM(COCOA)
     // FIXME: Just pass parameters to the NetworkDataTaskCocoa constructor.
-    return NetworkDataTaskCocoa::create(session, client, parameters.request, parameters.webFrameID, parameters.webPageID, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.shouldPreconnectOnly, parameters.isMainFrameNavigation, parameters.isMainResourceNavigationForAnyFrame, parameters.networkActivityTracker, parameters.isNavigatingToAppBoundDomain, parameters.shouldRelaxThirdPartyCookieBlocking, parameters.pcmDataCarried);
+    return NetworkDataTaskCocoa::create(session, client, parameters.request, parameters.webFrameID, parameters.webPageID, parameters.webPageProxyID,  parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.shouldPreconnectOnly, parameters.isMainFrameNavigation, parameters.isMainResourceNavigationForAnyFrame, parameters.networkActivityTracker, parameters.isNavigatingToAppBoundDomain, parameters.shouldRelaxThirdPartyCookieBlocking, parameters.pcmDataCarried);
 #endif
 #if USE(SOUP)
     return NetworkDataTaskSoup::create(session, client, parameters.request, parameters.webFrameID, parameters.webPageID, parameters.storedCredentialsPolicy, parameters.contentSniffingPolicy, parameters.contentEncodingSniffingPolicy, parameters.shouldClearReferrerOnHTTPSToHTTPRedirect, parameters.isMainFrameNavigation);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -383,7 +383,7 @@
     m_keptAliveLoads.remove(loader);
 }
 
-std::unique_ptr<WebSocketTask> NetworkSession::createWebSocketTask(NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol)
+std::unique_ptr<WebSocketTask> NetworkSession::createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol)
 {
     return nullptr;
 }

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSession.h (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSession.h	2021-03-26 22:05:35 UTC (rev 275116)
@@ -139,9 +139,9 @@
     PrefetchCache& prefetchCache() { return m_prefetchCache; }
     void clearPrefetchCache() { m_prefetchCache.clear(); }
 
-    virtual std::unique_ptr<WebSocketTask> createWebSocketTask(NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol);
-    virtual void removeWebSocketTask(WebSocketTask&) { }
-    virtual void addWebSocketTask(WebSocketTask&) { }
+    virtual std::unique_ptr<WebSocketTask> createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol);
+    virtual void removeWebSocketTask(WebPageProxyIdentifier, WebSocketTask&) { }
+    virtual void addWebSocketTask(WebPageProxyIdentifier, WebSocketTask&) { }
 
     WebCore::BlobRegistryImpl& blobRegistry() { return m_blobRegistry; }
 

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -36,9 +36,9 @@
 namespace WebKit {
 using namespace WebCore;
 
-std::unique_ptr<NetworkSocketChannel> NetworkSocketChannel::create(NetworkConnectionToWebProcess& connection, PAL::SessionID sessionID, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier)
+std::unique_ptr<NetworkSocketChannel> NetworkSocketChannel::create(NetworkConnectionToWebProcess& connection, PAL::SessionID sessionID, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier, WebPageProxyIdentifier webPageProxyID)
 {
-    auto result = makeUnique<NetworkSocketChannel>(connection, connection.networkProcess().networkSession(sessionID), request, protocol, identifier);
+    auto result = makeUnique<NetworkSocketChannel>(connection, connection.networkProcess().networkSession(sessionID), request, protocol, identifier, webPageProxyID);
     if (!result->m_socket) {
         result->didClose(0, "Cannot create a web socket task"_s);
         return nullptr;
@@ -46,18 +46,19 @@
     return result;
 }
 
-NetworkSocketChannel::NetworkSocketChannel(NetworkConnectionToWebProcess& connection, NetworkSession* session, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier)
+NetworkSocketChannel::NetworkSocketChannel(NetworkConnectionToWebProcess& connection, NetworkSession* session, const ResourceRequest& request, const String& protocol, WebSocketIdentifier identifier, WebPageProxyIdentifier webPageProxyID)
     : m_connectionToWebProcess(connection)
     , m_identifier(identifier)
     , m_session(makeWeakPtr(session))
     , m_errorTimer(*this, &NetworkSocketChannel::sendDelayedError)
+    , m_webPageProxyID(webPageProxyID)
 {
     if (!m_session)
         return;
 
-    m_socket = m_session->createWebSocketTask(*this, request, protocol);
+    m_socket = m_session->createWebSocketTask(webPageProxyID, *this, request, protocol);
     if (m_socket) {
-        m_session->addWebSocketTask(*m_socket);
+        m_session->addWebSocketTask(webPageProxyID, *m_socket);
         m_socket->resume();
     }
 }
@@ -65,7 +66,7 @@
 NetworkSocketChannel::~NetworkSocketChannel()
 {
     if (m_session)
-        m_session->removeWebSocketTask(*m_socket);
+        m_session->removeWebSocketTask(m_webPageProxyID, *m_socket);
 
     if (m_socket)
         m_socket->cancel();

Modified: trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/NetworkSocketChannel.h	2021-03-26 22:05:35 UTC (rev 275116)
@@ -28,6 +28,7 @@
 #include "DataReference.h"
 #include "MessageReceiver.h"
 #include "MessageSender.h"
+#include "WebPageProxyIdentifier.h"
 #include <WebCore/Timer.h>
 #include <WebCore/WebSocketIdentifier.h>
 #include <pal/SessionID.h>
@@ -54,9 +55,9 @@
 class NetworkSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static std::unique_ptr<NetworkSocketChannel> create(NetworkConnectionToWebProcess&, PAL::SessionID, const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier);
+    static std::unique_ptr<NetworkSocketChannel> create(NetworkConnectionToWebProcess&, PAL::SessionID, const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier, WebPageProxyIdentifier);
 
-    NetworkSocketChannel(NetworkConnectionToWebProcess&, NetworkSession*, const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier);
+    NetworkSocketChannel(NetworkConnectionToWebProcess&, NetworkSession*, const WebCore::ResourceRequest&, const String& protocol, WebCore::WebSocketIdentifier, WebPageProxyIdentifier);
     ~NetworkSocketChannel();
 
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
@@ -94,6 +95,7 @@
     WebCore::Timer m_errorTimer;
     String m_errorMessage;
     Optional<std::pair<unsigned short, String>> m_closeInfo;
+    WebPageProxyIdentifier m_webPageProxyID;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -44,10 +44,11 @@
 namespace WebKit {
 using namespace WebCore;
 
-WebSWServerToContextConnection::WebSWServerToContextConnection(NetworkConnectionToWebProcess& connection, RegistrableDomain&& registrableDomain, SWServer& server)
+WebSWServerToContextConnection::WebSWServerToContextConnection(NetworkConnectionToWebProcess& connection, WebPageProxyIdentifier webPageProxyID, RegistrableDomain&& registrableDomain, SWServer& server)
     : SWServerToContextConnection(WTFMove(registrableDomain))
     , m_connection(connection)
     , m_server(makeWeakPtr(server))
+    , m_webPageProxyID(webPageProxyID)
 {
     server.addContextConnection(*this);
 }

Modified: trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h	2021-03-26 22:05:35 UTC (rev 275116)
@@ -30,6 +30,7 @@
 #include "MessageReceiver.h"
 #include "MessageSender.h"
 #include "ServiceWorkerFetchTask.h"
+#include "WebPageProxyIdentifier.h"
 #include <WebCore/SWServerToContextConnection.h>
 #include <wtf/WeakPtr.h>
 
@@ -54,7 +55,7 @@
 
 class WebSWServerToContextConnection: public WebCore::SWServerToContextConnection, public IPC::MessageSender, public IPC::MessageReceiver {
 public:
-    WebSWServerToContextConnection(NetworkConnectionToWebProcess&, WebCore::RegistrableDomain&&, WebCore::SWServer&);
+    WebSWServerToContextConnection(NetworkConnectionToWebProcess&, WebPageProxyIdentifier, WebCore::RegistrableDomain&&, WebCore::SWServer&);
     ~WebSWServerToContextConnection();
 
     IPC::Connection& ipcConnection() const;
@@ -99,6 +100,7 @@
     WeakPtr<WebCore::SWServer> m_server;
     HashMap<WebCore::FetchIdentifier, WeakPtr<ServiceWorkerFetchTask>> m_ongoingFetches;
     bool m_isThrottleable { true };
+    WebPageProxyIdentifier m_webPageProxyID;
 }; // class WebSWServerToContextConnection
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h	2021-03-26 22:05:35 UTC (rev 275116)
@@ -46,9 +46,9 @@
 
 class NetworkDataTaskCocoa final : public NetworkDataTask {
 public:
-    static Ref<NetworkDataTask> create(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& request, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker> networkActivityTracker, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain, WebCore::ShouldRelaxThirdPartyCookieBlocking shouldRelaxThirdPartyCookieBlocking, Optional<WebCore::PrivateClickMeasurement::PcmDataCarried> pcmDataCarried)
+    static Ref<NetworkDataTask> create(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& request, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID, WebPageProxyIdentifier webPageProxyID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker> networkActivityTracker, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain, WebCore::ShouldRelaxThirdPartyCookieBlocking shouldRelaxThirdPartyCookieBlocking, Optional<WebCore::PrivateClickMeasurement::PcmDataCarried> pcmDataCarried)
     {
-        return adoptRef(*new NetworkDataTaskCocoa(session, client, request, frameID, pageID, storedCredentialsPolicy, shouldContentSniff, shouldContentEncodingSniff, shouldClearReferrerOnHTTPSToHTTPRedirect, shouldPreconnectOnly, dataTaskIsForMainFrameNavigation, dataTaskIsForMainResourceNavigationForAnyFrame, networkActivityTracker, isNavigatingToAppBoundDomain, shouldRelaxThirdPartyCookieBlocking, pcmDataCarried));
+        return adoptRef(*new NetworkDataTaskCocoa(session, client, request, frameID, pageID, webPageProxyID, storedCredentialsPolicy, shouldContentSniff, shouldContentEncodingSniff, shouldClearReferrerOnHTTPSToHTTPRedirect, shouldPreconnectOnly, dataTaskIsForMainFrameNavigation, dataTaskIsForMainResourceNavigationForAnyFrame, networkActivityTracker, isNavigatingToAppBoundDomain, shouldRelaxThirdPartyCookieBlocking, pcmDataCarried));
     }
 
     ~NetworkDataTaskCocoa();
@@ -85,7 +85,7 @@
     void setPriority(WebCore::ResourceLoadPriority) override;
 
 private:
-    NetworkDataTaskCocoa(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, WebCore::FrameIdentifier, WebCore::PageIdentifier, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker>, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain, WebCore::ShouldRelaxThirdPartyCookieBlocking, Optional<WebCore::PrivateClickMeasurement::PcmDataCarried>);
+    NetworkDataTaskCocoa(NetworkSession&, NetworkDataTaskClient&, const WebCore::ResourceRequest&, WebCore::FrameIdentifier, WebCore::PageIdentifier, WebPageProxyIdentifier, WebCore::StoredCredentialsPolicy, WebCore::ContentSniffingPolicy, WebCore::ContentEncodingSniffingPolicy, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker>, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain, WebCore::ShouldRelaxThirdPartyCookieBlocking, Optional<WebCore::PrivateClickMeasurement::PcmDataCarried>);
 
     bool tryPasswordBasedAuthentication(const WebCore::AuthenticationChallenge&, ChallengeCompletionHandler&);
     void applySniffingPoliciesAndBindRequestToInferfaceIfNeeded(__strong NSURLRequest*&, bool shouldContentSniff, bool shouldContentEncodingSniff);
@@ -108,6 +108,7 @@
     WebCore::NetworkLoadMetrics m_networkLoadMetrics;
     WebCore::FrameIdentifier m_frameID;
     WebCore::PageIdentifier m_pageID;
+    WebPageProxyIdentifier m_webPageProxyID;
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     bool m_hasBeenSetToUseStatelessCookieStorage { false };

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2021-03-26 22:05:35 UTC (rev 275116)
@@ -291,11 +291,12 @@
     return session.sessionID().isAlwaysOnLoggingAllowed();
 }
 
-NetworkDataTaskCocoa::NetworkDataTaskCocoa(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& requestWithCredentials, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker> networkActivityTracker, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain, WebCore::ShouldRelaxThirdPartyCookieBlocking shouldRelaxThirdPartyCookieBlocking, Optional<WebCore::PrivateClickMeasurement::PcmDataCarried> pcmDataCarried)
+NetworkDataTaskCocoa::NetworkDataTaskCocoa(NetworkSession& session, NetworkDataTaskClient& client, const WebCore::ResourceRequest& requestWithCredentials, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID, WebPageProxyIdentifier webPageProxyID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, WebCore::ContentSniffingPolicy shouldContentSniff, WebCore::ContentEncodingSniffingPolicy shouldContentEncodingSniff, bool shouldClearReferrerOnHTTPSToHTTPRedirect, PreconnectOnly shouldPreconnectOnly, bool dataTaskIsForMainFrameNavigation, bool dataTaskIsForMainResourceNavigationForAnyFrame, Optional<NetworkActivityTracker> networkActivityTracker, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain, WebCore::ShouldRelaxThirdPartyCookieBlocking shouldRelaxThirdPartyCookieBlocking, Optional<WebCore::PrivateClickMeasurement::PcmDataCarried> pcmDataCarried)
     : NetworkDataTask(session, client, requestWithCredentials, storedCredentialsPolicy, shouldClearReferrerOnHTTPSToHTTPRedirect, dataTaskIsForMainFrameNavigation)
-    , m_sessionWrapper(makeWeakPtr(static_cast<NetworkSessionCocoa&>(session).sessionWrapperForTask(requestWithCredentials, storedCredentialsPolicy, isNavigatingToAppBoundDomain)))
+    , m_sessionWrapper(makeWeakPtr(static_cast<NetworkSessionCocoa&>(session).sessionWrapperForTask(webPageProxyID, requestWithCredentials, storedCredentialsPolicy, isNavigatingToAppBoundDomain)))
     , m_frameID(frameID)
     , m_pageID(pageID)
+    , m_webPageProxyID(webPageProxyID)
     , m_isForMainResourceNavigationForAnyFrame(dataTaskIsForMainResourceNavigationForAnyFrame)
     , m_isAlwaysOnLoggingAllowed(computeIsAlwaysOnLoggingAllowed(session))
     , m_shouldRelaxThirdPartyCookieBlocking(shouldRelaxThirdPartyCookieBlocking)

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.h	2021-03-26 22:05:35 UTC (rev 275116)
@@ -38,6 +38,7 @@
 #include "DownloadID.h"
 #include "NetworkDataTaskCocoa.h"
 #include "NetworkSession.h"
+#include "WebPageProxyIdentifier.h"
 #include "WebSocketTask.h"
 #include <WebCore/NetworkLoadMetrics.h>
 #include <WebCore/RegistrableDomain.h>
@@ -69,7 +70,7 @@
     NetworkSessionCocoa(NetworkProcess&, NetworkSessionCreationParameters&&);
     ~NetworkSessionCocoa();
 
-    void initializeEphemeralStatelessSession(NavigatingToAppBoundDomain);
+    SessionWrapper& initializeEphemeralStatelessSessionIfNeeded(WebPageProxyIdentifier, NavigatingToAppBoundDomain);
 
     const String& boundInterfaceIdentifier() const;
     const String& sourceApplicationBundleIdentifier() const;
@@ -83,7 +84,7 @@
 
     void continueDidReceiveChallenge(SessionWrapper&, const WebCore::AuthenticationChallenge&, NegotiatedLegacyTLS, NetworkDataTaskCocoa::TaskIdentifier, NetworkDataTaskCocoa*, CompletionHandler<void(WebKit::AuthenticationChallengeDisposition, const WebCore::Credential&)>&&);
 
-    SessionWrapper& sessionWrapperForDownloads() { return m_sessionWithCredentialStorage; }
+    SessionWrapper& sessionWrapperForDownloadResume() { return m_defaultSessionSet->sessionWithCredentialStorage; }
 
     bool fastServerTrustEvaluationEnabled() const { return m_fastServerTrustEvaluationEnabled; }
     bool deviceManagementRestrictionsEnabled() const { return m_deviceManagementRestrictionsEnabled; }
@@ -96,11 +97,11 @@
     void clearIsolatedSessions() override;
 
 #if ENABLE(APP_BOUND_DOMAINS)
-    bool hasAppBoundSession() const override { return !!m_appBoundSession; }
+    bool hasAppBoundSession() const override;
     void clearAppBoundSession() override;
 #endif
 
-    SessionWrapper& sessionWrapperForTask(const WebCore::ResourceRequest&, WebCore::StoredCredentialsPolicy, Optional<NavigatingToAppBoundDomain>);
+    SessionWrapper& sessionWrapperForTask(WebPageProxyIdentifier, const WebCore::ResourceRequest&, WebCore::StoredCredentialsPolicy, Optional<NavigatingToAppBoundDomain>);
     bool preventsSystemHTTPProxyAuthentication() const { return m_preventsSystemHTTPProxyAuthentication; }
     
     _NSHSTSStorage *hstsStorage() const;
@@ -109,10 +110,10 @@
     void invalidateAndCancel() override;
     void clearCredentials() override;
     bool shouldLogCookieInformation() const override { return m_shouldLogCookieInformation; }
-    SessionWrapper& isolatedSession(WebCore::StoredCredentialsPolicy, const WebCore::RegistrableDomain, NavigatingToAppBoundDomain);
+    SessionWrapper& isolatedSession(WebPageProxyIdentifier, WebCore::StoredCredentialsPolicy, const WebCore::RegistrableDomain, NavigatingToAppBoundDomain);
 
 #if ENABLE(APP_BOUND_DOMAINS)
-    SessionWrapper& appBoundSession(WebCore::StoredCredentialsPolicy);
+    SessionWrapper& appBoundSession(WebPageProxyIdentifier, WebCore::StoredCredentialsPolicy);
 #endif
 
     Vector<WebCore::SecurityOriginData> hostNamesWithAlternativeServices() const override;
@@ -120,9 +121,9 @@
     void clearAlternativeServices(WallTime) override;
 
 #if HAVE(NSURLSESSION_WEBSOCKET)
-    std::unique_ptr<WebSocketTask> createWebSocketTask(NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol) final;
-    void addWebSocketTask(WebSocketTask&) final;
-    void removeWebSocketTask(WebSocketTask&) final;
+    std::unique_ptr<WebSocketTask> createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol) final;
+    void addWebSocketTask(WebPageProxyIdentifier, WebSocketTask&) final;
+    void removeWebSocketTask(WebPageProxyIdentifier, WebSocketTask&) final;
 #endif
 
     struct IsolatedSession {
@@ -133,13 +134,35 @@
         WallTime lastUsed;
     };
 
-    HashMap<WebCore::RegistrableDomain, std::unique_ptr<IsolatedSession>> m_isolatedSessions;
-    std::unique_ptr<IsolatedSession> m_appBoundSession;
+    struct SessionSet : public RefCounted<SessionSet> {
+    public:
+        static Ref<SessionSet> create()
+        {
+            return adoptRef(*new SessionSet);
+        }
+    
+        SessionWrapper& isolatedSession(WebCore::StoredCredentialsPolicy, const WebCore::RegistrableDomain, NavigatingToAppBoundDomain, NetworkSessionCocoa&);
+        SessionWrapper& initializeEphemeralStatelessSessionIfNeeded(NavigatingToAppBoundDomain, NetworkSessionCocoa&);
 
-    SessionWrapper m_sessionWithCredentialStorage;
-    SessionWrapper m_sessionWithoutCredentialStorage;
-    SessionWrapper m_ephemeralStatelessSession;
+        HashMap<WebCore::RegistrableDomain, std::unique_ptr<IsolatedSession>> isolatedSessions;
+        std::unique_ptr<IsolatedSession> appBoundSession;
 
+        SessionWrapper sessionWithCredentialStorage;
+        SessionWrapper sessionWithoutCredentialStorage;
+        SessionWrapper ephemeralStatelessSession;
+
+    private:
+        SessionSet() = default;
+    };
+
+    Ref<SessionSet> m_defaultSessionSet;
+    HashMap<WebPageProxyIdentifier, Ref<SessionSet>> m_perPageSessionSets;
+
+    void initializeStandardSessionsInSet(SessionSet&, NSURLSessionConfiguration *);
+    SessionSet& sessionSetForPage(WebPageProxyIdentifier);
+    const SessionSet& sessionSetForPage(WebPageProxyIdentifier) const;
+    void invalidateAndCancelSessionSet(SessionSet&);
+    
     String m_boundInterfaceIdentifier;
     String m_sourceApplicationBundleIdentifier;
     String m_sourceApplicationSecondaryIdentifier;

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2021-03-26 22:05:35 UTC (rev 275116)
@@ -1061,10 +1061,10 @@
 _NSHSTSStorage *NetworkSessionCocoa::hstsStorage() const
 {
 #if HAVE(HSTS_STORAGE)
-    NSURLSessionConfiguration *configuration = m_sessionWithCredentialStorage.session.get().configuration;
+    NSURLSessionConfiguration *configuration = m_defaultSessionSet->sessionWithCredentialStorage.session.get().configuration;
     // FIXME: Remove this respondsToSelector check once rdar://problem/50109631 is in a build and bots are updated.
     if ([configuration respondsToSelector:@selector(_hstsStorage)])
-        return m_sessionWithCredentialStorage.session.get().configuration._hstsStorage;
+        return configuration._hstsStorage;
 #endif
     return nil;
 }
@@ -1160,6 +1160,7 @@
 
 NetworkSessionCocoa::NetworkSessionCocoa(NetworkProcess& networkProcess, NetworkSessionCreationParameters&& parameters)
     : NetworkSession(networkProcess, parameters)
+    , m_defaultSessionSet(SessionSet::create())
     , m_boundInterfaceIdentifier(parameters.boundInterfaceIdentifier)
     , m_sourceApplicationBundleIdentifier(parameters.sourceApplicationBundleIdentifier)
     , m_sourceApplicationSecondaryIdentifier(parameters.sourceApplicationSecondaryIdentifier)
@@ -1271,16 +1272,8 @@
         cookieStorage.get()._overrideSessionCookieAcceptPolicy = YES;
 #endif
 
-    m_sessionWithCredentialStorage.initialize(configuration, *this, WebCore::StoredCredentialsPolicy::Use, NavigatingToAppBoundDomain::No);
-    LOG(NetworkSession, "Created NetworkSession with cookieAcceptPolicy %lu", configuration.HTTPCookieStorage.cookieAcceptPolicy);
+    initializeStandardSessionsInSet(m_defaultSessionSet.get(), configuration);
 
-    configuration.URLCredentialStorage = nil;
-    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=177394
-    // configuration.HTTPCookieStorage = nil;
-    // configuration.HTTPCookieAcceptPolicy = NSHTTPCookieAcceptPolicyNever;
-
-    m_sessionWithoutCredentialStorage.initialize(configuration, *this, WebCore::StoredCredentialsPolicy::DoNotUse, NavigatingToAppBoundDomain::No);
-
     m_deviceManagementRestrictionsEnabled = parameters.deviceManagementRestrictionsEnabled;
     m_allLoadsBlockedByDeviceManagementRestrictionsForTesting = parameters.allLoadsBlockedByDeviceManagementRestrictionsForTesting;
 
@@ -1296,10 +1289,39 @@
 
 NetworkSessionCocoa::~NetworkSessionCocoa() = default;
 
-void NetworkSessionCocoa::initializeEphemeralStatelessSession(NavigatingToAppBoundDomain isNavigatingToAppBoundDomain)
+void NetworkSessionCocoa::initializeStandardSessionsInSet(SessionSet& sessionSet, NSURLSessionConfiguration *configuration)
 {
+    sessionSet.sessionWithCredentialStorage.initialize(configuration, *this, WebCore::StoredCredentialsPolicy::Use, NavigatingToAppBoundDomain::No);
+    LOG(NetworkSession, "Created NetworkSession with cookieAcceptPolicy %lu", configuration.HTTPCookieStorage.cookieAcceptPolicy);
+
+    configuration.URLCredentialStorage = nil;
+    sessionSet.sessionWithoutCredentialStorage.initialize(configuration, *this, WebCore::StoredCredentialsPolicy::DoNotUse, NavigatingToAppBoundDomain::No);
+}
+
+NetworkSessionCocoa::SessionSet& NetworkSessionCocoa::sessionSetForPage(WebPageProxyIdentifier webPageProxyID)
+{
+    SessionSet* sessionSet = webPageProxyID ? m_perPageSessionSets.get(webPageProxyID) : nullptr;
+    return sessionSet ? *sessionSet : m_defaultSessionSet.get();
+}
+
+const NetworkSessionCocoa::SessionSet& NetworkSessionCocoa::sessionSetForPage(WebPageProxyIdentifier webPageProxyID) const
+{
+    SessionSet* sessionSet = webPageProxyID ? m_perPageSessionSets.get(webPageProxyID) : nullptr;
+    return sessionSet ? *sessionSet : m_defaultSessionSet.get();
+}
+
+SessionWrapper& NetworkSessionCocoa::initializeEphemeralStatelessSessionIfNeeded(WebPageProxyIdentifier webPageProxyID, NavigatingToAppBoundDomain isNavigatingToAppBoundDomain)
+{
+    return sessionSetForPage(webPageProxyID).initializeEphemeralStatelessSessionIfNeeded(isNavigatingToAppBoundDomain, *this);
+}
+
+SessionWrapper& NetworkSessionCocoa::SessionSet::initializeEphemeralStatelessSessionIfNeeded(NavigatingToAppBoundDomain isNavigatingToAppBoundDomain, NetworkSessionCocoa& session)
+{
+    if (ephemeralStatelessSession.session)
+        return ephemeralStatelessSession;
+
     NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration ephemeralSessionConfiguration];
-    NSURLSessionConfiguration *existingConfiguration = m_sessionWithoutCredentialStorage.session.get().configuration;
+    NSURLSessionConfiguration *existingConfiguration = sessionWithoutCredentialStorage.session.get().configuration;
 
     configuration.HTTPCookieAcceptPolicy = NSHTTPCookieAcceptPolicyNever;
     configuration.URLCredentialStorage = nil;
@@ -1318,10 +1340,12 @@
         configuration._attributedBundleIdentifier = existingConfiguration._attributedBundleIdentifier;
 #endif
 
-    m_ephemeralStatelessSession.initialize(configuration, *this, WebCore::StoredCredentialsPolicy::EphemeralStateless, isNavigatingToAppBoundDomain);
+    ephemeralStatelessSession.initialize(configuration, session, WebCore::StoredCredentialsPolicy::EphemeralStateless, isNavigatingToAppBoundDomain);
+
+    return ephemeralStatelessSession;
 }
 
-SessionWrapper& NetworkSessionCocoa::sessionWrapperForTask(const WebCore::ResourceRequest& request, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain)
+SessionWrapper& NetworkSessionCocoa::sessionWrapperForTask(WebPageProxyIdentifier webPageProxyID, const WebCore::ResourceRequest& request, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain)
 {
     auto shouldBeConsideredAppBound = isNavigatingToAppBoundDomain ? *isNavigatingToAppBoundDomain : NavigatingToAppBoundDomain::Yes;
     if (RefPtr<IPC::Connection> connection = networkProcess().parentProcessConnection()) {
@@ -1332,7 +1356,7 @@
     if (auto* storageSession = networkStorageSession()) {
         auto firstParty = WebCore::RegistrableDomain(request.firstPartyForCookies());
         if (storageSession->shouldBlockThirdPartyCookiesButKeepFirstPartyCookiesFor(firstParty))
-            return isolatedSession(storedCredentialsPolicy, firstParty, shouldBeConsideredAppBound);
+            return sessionSetForPage(webPageProxyID).isolatedSession(storedCredentialsPolicy, firstParty, shouldBeConsideredAppBound, *this);
     } else
         ASSERT_NOT_REACHED();
 #endif
@@ -1339,28 +1363,28 @@
 
 #if ENABLE(APP_BOUND_DOMAINS)
     if (shouldBeConsideredAppBound == NavigatingToAppBoundDomain::Yes)
-        return appBoundSession(storedCredentialsPolicy);
+        return appBoundSession(webPageProxyID, storedCredentialsPolicy);
 #endif
 
     switch (storedCredentialsPolicy) {
     case WebCore::StoredCredentialsPolicy::Use:
-        return m_sessionWithCredentialStorage;
+        return sessionSetForPage(webPageProxyID).sessionWithCredentialStorage;
     case WebCore::StoredCredentialsPolicy::DoNotUse:
-        return m_sessionWithoutCredentialStorage;
+        return sessionSetForPage(webPageProxyID).sessionWithoutCredentialStorage;
     case WebCore::StoredCredentialsPolicy::EphemeralStateless:
-        if (!m_ephemeralStatelessSession.session)
-            initializeEphemeralStatelessSession(NavigatingToAppBoundDomain::No);
-        return m_ephemeralStatelessSession;
+        return initializeEphemeralStatelessSessionIfNeeded(webPageProxyID, NavigatingToAppBoundDomain::No);
     }
 }
 
 #if ENABLE(APP_BOUND_DOMAINS)
-SessionWrapper& NetworkSessionCocoa::appBoundSession(WebCore::StoredCredentialsPolicy storedCredentialsPolicy)
+SessionWrapper& NetworkSessionCocoa::appBoundSession(WebPageProxyIdentifier webPageProxyID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy)
 {
-    if (!m_appBoundSession) {
-        m_appBoundSession = makeUnique<IsolatedSession>();
-        m_appBoundSession->sessionWithCredentialStorage.initialize(m_sessionWithCredentialStorage.session.get().configuration, *this, WebCore::StoredCredentialsPolicy::Use, NavigatingToAppBoundDomain::Yes);
-        m_appBoundSession->sessionWithoutCredentialStorage.initialize(m_sessionWithoutCredentialStorage.session.get().configuration, *this, WebCore::StoredCredentialsPolicy::DoNotUse, NavigatingToAppBoundDomain::Yes);
+    auto& sessionSet = sessionSetForPage(webPageProxyID);
+    
+    if (!sessionSet.appBoundSession) {
+        sessionSet.appBoundSession = makeUnique<IsolatedSession>();
+        sessionSet.appBoundSession->sessionWithCredentialStorage.initialize(sessionSet.sessionWithCredentialStorage.session.get().configuration, *this, WebCore::StoredCredentialsPolicy::Use, NavigatingToAppBoundDomain::Yes);
+        sessionSet.appBoundSession->sessionWithoutCredentialStorage.initialize(sessionSet.sessionWithoutCredentialStorage.session.get().configuration, *this, WebCore::StoredCredentialsPolicy::DoNotUse, NavigatingToAppBoundDomain::Yes);
     }
 
     auto& sessionWrapper = [&] (auto storedCredentialsPolicy) -> SessionWrapper& {
@@ -1367,27 +1391,49 @@
         switch (storedCredentialsPolicy) {
         case WebCore::StoredCredentialsPolicy::Use:
             LOG(NetworkSession, "Using app-bound NSURLSession with credential storage.");
-            return m_appBoundSession->sessionWithCredentialStorage;
+            return sessionSet.appBoundSession->sessionWithCredentialStorage;
         case WebCore::StoredCredentialsPolicy::DoNotUse:
             LOG(NetworkSession, "Using app-bound NSURLSession without credential storage.");
-            return m_appBoundSession->sessionWithoutCredentialStorage;
+            return sessionSet.appBoundSession->sessionWithoutCredentialStorage;
         case WebCore::StoredCredentialsPolicy::EphemeralStateless:
-            if (!m_ephemeralStatelessSession.session)
-                initializeEphemeralStatelessSession(NavigatingToAppBoundDomain::Yes);
-            return m_ephemeralStatelessSession;
+            return initializeEphemeralStatelessSessionIfNeeded(webPageProxyID, NavigatingToAppBoundDomain::Yes);
         }
     } (storedCredentialsPolicy);
 
     return sessionWrapper;
 }
+
+bool NetworkSessionCocoa::hasAppBoundSession() const
+{
+    if (!!m_defaultSessionSet->appBoundSession)
+        return true;
+    for (auto& sessionSet : m_perPageSessionSets.values()) {
+        if (!!sessionSet->appBoundSession)
+            return true;
+    }
+    
+    return false;
+}
+
+void NetworkSessionCocoa::clearAppBoundSession()
+{
+    m_defaultSessionSet->appBoundSession = nullptr;
+    for (auto& sessionSet : m_perPageSessionSets.values())
+        sessionSet->appBoundSession = nullptr;
+}
 #endif
 
-SessionWrapper& NetworkSessionCocoa::isolatedSession(WebCore::StoredCredentialsPolicy storedCredentialsPolicy, const WebCore::RegistrableDomain firstPartyDomain, NavigatingToAppBoundDomain isNavigatingToAppBoundDomain)
+SessionWrapper& NetworkSessionCocoa::isolatedSession(WebPageProxyIdentifier webPageProxyID, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, const WebCore::RegistrableDomain firstPartyDomain, NavigatingToAppBoundDomain isNavigatingToAppBoundDomain)
 {
-    auto& entry = m_isolatedSessions.ensure(firstPartyDomain, [this, isNavigatingToAppBoundDomain] {
+    return sessionSetForPage(webPageProxyID).isolatedSession(storedCredentialsPolicy, firstPartyDomain, isNavigatingToAppBoundDomain, *this);
+}
+
+SessionWrapper& NetworkSessionCocoa::SessionSet::isolatedSession(WebCore::StoredCredentialsPolicy storedCredentialsPolicy, const WebCore::RegistrableDomain firstPartyDomain, NavigatingToAppBoundDomain isNavigatingToAppBoundDomain, NetworkSessionCocoa& session)
+{
+    auto& entry = isolatedSessions.ensure(firstPartyDomain, [this, &session, isNavigatingToAppBoundDomain] {
         auto newEntry = makeUnique<IsolatedSession>();
-        newEntry->sessionWithCredentialStorage.initialize(m_sessionWithCredentialStorage.session.get().configuration, *this, WebCore::StoredCredentialsPolicy::Use, isNavigatingToAppBoundDomain);
-        newEntry->sessionWithoutCredentialStorage.initialize(m_sessionWithoutCredentialStorage.session.get().configuration, *this, WebCore::StoredCredentialsPolicy::DoNotUse, isNavigatingToAppBoundDomain);
+        newEntry->sessionWithCredentialStorage.initialize(sessionWithCredentialStorage.session.get().configuration, session, WebCore::StoredCredentialsPolicy::Use, isNavigatingToAppBoundDomain);
+        newEntry->sessionWithoutCredentialStorage.initialize(sessionWithoutCredentialStorage.session.get().configuration, session, WebCore::StoredCredentialsPolicy::DoNotUse, isNavigatingToAppBoundDomain);
         return newEntry;
     }).iterator->value;
 
@@ -1402,17 +1448,15 @@
             LOG(NetworkSession, "Using isolated NSURLSession without credential storage.");
             return entry->sessionWithoutCredentialStorage;
         case WebCore::StoredCredentialsPolicy::EphemeralStateless:
-            if (!m_ephemeralStatelessSession.session)
-                initializeEphemeralStatelessSession(isNavigatingToAppBoundDomain);
-            return m_ephemeralStatelessSession;
+            return initializeEphemeralStatelessSessionIfNeeded(isNavigatingToAppBoundDomain, session);
         }
     } (storedCredentialsPolicy);
-    
-    if (m_isolatedSessions.size() > maxNumberOfIsolatedSessions) {
+
+    if (isolatedSessions.size() > maxNumberOfIsolatedSessions) {
         WebCore::RegistrableDomain keyToRemove;
         auto oldestTimestamp = WallTime::now();
-        for (auto& key : m_isolatedSessions.keys()) {
-            auto timestamp = m_isolatedSessions.get(key)->lastUsed;
+        for (auto& key : isolatedSessions.keys()) {
+            auto timestamp = isolatedSessions.get(key)->lastUsed;
             if (timestamp < oldestTimestamp) {
                 oldestTimestamp = timestamp;
                 keyToRemove = key;
@@ -1419,10 +1463,10 @@
             }
         }
         LOG(NetworkSession, "About to remove isolated NSURLSession.");
-        m_isolatedSessions.remove(keyToRemove);
+        isolatedSessions.remove(keyToRemove);
     }
 
-    RELEASE_ASSERT(m_isolatedSessions.size() <= maxNumberOfIsolatedSessions);
+    RELEASE_ASSERT(isolatedSessions.size() <= maxNumberOfIsolatedSessions);
 
     return sessionWrapper;
 }
@@ -1429,48 +1473,57 @@
 
 bool NetworkSessionCocoa::hasIsolatedSession(const WebCore::RegistrableDomain domain) const
 {
-    return m_isolatedSessions.contains(domain);
+    if (m_defaultSessionSet->isolatedSessions.contains(domain))
+        return true;
+    for (auto& sessionSet : m_perPageSessionSets.values()) {
+        if (sessionSet->isolatedSessions.contains(domain))
+            return true;
+    }
+    
+    return false;
 }
 
 void NetworkSessionCocoa::clearIsolatedSessions()
 {
-    m_isolatedSessions.clear();
+    m_defaultSessionSet->isolatedSessions.clear();
+    for (auto& sessionSet : m_perPageSessionSets.values())
+        sessionSet->isolatedSessions.clear();
 }
 
-#if ENABLE(APP_BOUND_DOMAINS)
-void NetworkSessionCocoa::clearAppBoundSession()
+void NetworkSessionCocoa::invalidateAndCancelSessionSet(SessionSet& sessionSet)
 {
-    m_appBoundSession = nullptr;
-}
-#endif
+    [sessionSet.sessionWithCredentialStorage.session invalidateAndCancel];
+    [sessionSet.sessionWithoutCredentialStorage.session invalidateAndCancel];
+    [sessionSet.ephemeralStatelessSession.session invalidateAndCancel];
+    [sessionSet.sessionWithCredentialStorage.delegate sessionInvalidated];
+    [sessionSet.sessionWithoutCredentialStorage.delegate sessionInvalidated];
+    [sessionSet.ephemeralStatelessSession.delegate sessionInvalidated];
 
-void NetworkSessionCocoa::invalidateAndCancel()
-{
-    NetworkSession::invalidateAndCancel();
-
-    [m_sessionWithCredentialStorage.session invalidateAndCancel];
-    [m_sessionWithoutCredentialStorage.session invalidateAndCancel];
-    [m_ephemeralStatelessSession.session invalidateAndCancel];
-    [m_sessionWithCredentialStorage.delegate sessionInvalidated];
-    [m_sessionWithoutCredentialStorage.delegate sessionInvalidated];
-    [m_ephemeralStatelessSession.delegate sessionInvalidated];
-
-    for (auto& session : m_isolatedSessions.values()) {
+    for (auto& session : sessionSet.isolatedSessions.values()) {
         [session->sessionWithCredentialStorage.session invalidateAndCancel];
         [session->sessionWithCredentialStorage.delegate sessionInvalidated];
         [session->sessionWithoutCredentialStorage.session invalidateAndCancel];
         [session->sessionWithoutCredentialStorage.delegate sessionInvalidated];
     }
-    m_isolatedSessions.clear();
+    sessionSet.isolatedSessions.clear();
 
-    if (m_appBoundSession) {
-        [m_appBoundSession->sessionWithCredentialStorage.session invalidateAndCancel];
-        [m_appBoundSession->sessionWithCredentialStorage.delegate sessionInvalidated];
-        [m_appBoundSession->sessionWithoutCredentialStorage.session invalidateAndCancel];
-        [m_appBoundSession->sessionWithoutCredentialStorage.delegate sessionInvalidated];
+    if (sessionSet.appBoundSession) {
+        [sessionSet.appBoundSession->sessionWithCredentialStorage.session invalidateAndCancel];
+        [sessionSet.appBoundSession->sessionWithCredentialStorage.delegate sessionInvalidated];
+        [sessionSet.appBoundSession->sessionWithoutCredentialStorage.session invalidateAndCancel];
+        [sessionSet.appBoundSession->sessionWithoutCredentialStorage.delegate sessionInvalidated];
     }
 }
 
+void NetworkSessionCocoa::invalidateAndCancel()
+{
+    NetworkSession::invalidateAndCancel();
+
+    invalidateAndCancelSessionSet(m_defaultSessionSet.get());
+    for (auto& sessionSet : m_perPageSessionSets.values())
+        invalidateAndCancelSessionSet(sessionSet.get());
+}
+
 void NetworkSessionCocoa::clearCredentials()
 {
 #if !USE(CREDENTIAL_STORAGE_WITH_NETWORK_SESSION)
@@ -1579,7 +1632,7 @@
 }
 
 #if HAVE(NSURLSESSION_WEBSOCKET)
-std::unique_ptr<WebSocketTask> NetworkSessionCocoa::createWebSocketTask(NetworkSocketChannel& channel, const WebCore::ResourceRequest& request, const String& protocol)
+std::unique_ptr<WebSocketTask> NetworkSessionCocoa::createWebSocketTask(WebPageProxyIdentifier webPageProxyID, NetworkSocketChannel& channel, const WebCore::ResourceRequest& request, const String& protocol)
 {
     ASSERT(!request.hasHTTPHeaderField(WebCore::HTTPHeaderName::SecWebSocketProtocol));
     auto nsRequest = retainPtr(request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody));
@@ -1591,20 +1644,20 @@
     // rdar://problem/68057031: explicitly disable sniffing for WebSocket handshakes.
     [nsRequest _setProperty:@NO forKey:(NSString *)_kCFURLConnectionPropertyShouldSniff];
 
-    RetainPtr<NSURLSessionWebSocketTask> task = [m_sessionWithCredentialStorage.session webSocketTaskWithRequest:nsRequest.get()];
+    RetainPtr<NSURLSessionWebSocketTask> task = [sessionSetForPage(webPageProxyID).sessionWithCredentialStorage.session webSocketTaskWithRequest:nsRequest.get()];
     return makeUnique<WebSocketTask>(channel, WTFMove(task));
 }
 
-void NetworkSessionCocoa::addWebSocketTask(WebSocketTask& task)
+void NetworkSessionCocoa::addWebSocketTask(WebPageProxyIdentifier webPageProxyID, WebSocketTask& task)
 {
-    RELEASE_ASSERT(!m_sessionWithCredentialStorage.webSocketDataTaskMap.contains(task.identifier()));
-    m_sessionWithCredentialStorage.webSocketDataTaskMap.add(task.identifier(), &task);
+    RELEASE_ASSERT(!sessionSetForPage(webPageProxyID).sessionWithCredentialStorage.webSocketDataTaskMap.contains(task.identifier()));
+    sessionSetForPage(webPageProxyID).sessionWithCredentialStorage.webSocketDataTaskMap.add(task.identifier(), &task);
 }
 
-void NetworkSessionCocoa::removeWebSocketTask(WebSocketTask& task)
+void NetworkSessionCocoa::removeWebSocketTask(WebPageProxyIdentifier webPageProxyID, WebSocketTask& task)
 {
-    RELEASE_ASSERT(m_sessionWithCredentialStorage.webSocketDataTaskMap.contains(task.identifier()));
-    m_sessionWithCredentialStorage.webSocketDataTaskMap.remove(task.identifier());
+    RELEASE_ASSERT(sessionSetForPage(webPageProxyID).sessionWithCredentialStorage.webSocketDataTaskMap.contains(task.identifier()));
+    sessionSetForPage(webPageProxyID).sessionWithCredentialStorage.webSocketDataTaskMap.remove(task.identifier());
 }
 
 #endif // HAVE(NSURLSESSION_WEBSOCKET)
@@ -1613,7 +1666,7 @@
 {
 #if HAVE(CFNETWORK_ALTERNATIVE_SERVICE)
     Vector<WebCore::SecurityOriginData> origins;
-    _NSHTTPAlternativeServicesStorage* storage = m_sessionWithCredentialStorage.session.get().configuration._alternativeServicesStorage;
+    _NSHTTPAlternativeServicesStorage* storage = m_defaultSessionSet->sessionWithCredentialStorage.session.get().configuration._alternativeServicesStorage;
     NSArray<_NSHTTPAlternativeServiceEntry *> *entries = [storage HTTPServiceEntriesWithFilter:_NSHTTPAlternativeServicesFilter.emptyFilter];
 
     for (_NSHTTPAlternativeServiceEntry* entry in entries) {
@@ -1629,7 +1682,7 @@
 void NetworkSessionCocoa::deleteAlternativeServicesForHostNames(const Vector<String>& hosts)
 {
 #if HAVE(CFNETWORK_ALTERNATIVE_SERVICE)
-    _NSHTTPAlternativeServicesStorage* storage = m_sessionWithCredentialStorage.session.get().configuration._alternativeServicesStorage;
+    _NSHTTPAlternativeServicesStorage* storage = m_defaultSessionSet->sessionWithCredentialStorage.session.get().configuration._alternativeServicesStorage;
     for (auto& host : hosts)
         [storage removeHTTPAlternativeServiceEntriesWithRegistrableDomain:host];
 #else
@@ -1640,7 +1693,7 @@
 void NetworkSessionCocoa::clearAlternativeServices(WallTime modifiedSince)
 {
 #if HAVE(CFNETWORK_ALTERNATIVE_SERVICE)
-    _NSHTTPAlternativeServicesStorage* storage = m_sessionWithCredentialStorage.session.get().configuration._alternativeServicesStorage;
+    _NSHTTPAlternativeServicesStorage* storage = m_defaultSessionSet->sessionWithCredentialStorage.session.get().configuration._alternativeServicesStorage;
     NSTimeInterval timeInterval = modifiedSince.secondsSinceEpoch().seconds();
     NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval];
     [storage removeHTTPAlternativeServiceEntriesCreatedAfterDate:date];

Modified: trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -123,7 +123,7 @@
 }
 #endif
 
-std::unique_ptr<WebSocketTask> NetworkSessionSoup::createWebSocketTask(NetworkSocketChannel& channel, const ResourceRequest& request, const String& protocol)
+std::unique_ptr<WebSocketTask> NetworkSessionSoup::createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel& channel, const ResourceRequest& request, const String& protocol)
 {
     GRefPtr<SoupMessage> soupMessage = request.createSoupMessage(blobRegistry());
     if (!soupMessage)

Modified: trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h (275115 => 275116)


--- trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/NetworkProcess/soup/NetworkSessionSoup.h	2021-03-26 22:05:35 UTC (rev 275116)
@@ -27,6 +27,7 @@
 
 #include "NetworkSession.h"
 #include "SoupCookiePersistentStorageType.h"
+#include "WebPageProxyIdentifier.h"
 
 typedef struct _SoupSession SoupSession;
 
@@ -62,7 +63,7 @@
     void setProxySettings(WebCore::SoupNetworkProxySettings&&);
 
 private:
-    std::unique_ptr<WebSocketTask> createWebSocketTask(NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol) final;
+    std::unique_ptr<WebSocketTask> createWebSocketTask(WebPageProxyIdentifier, NetworkSocketChannel&, const WebCore::ResourceRequest&, const String& protocol) final;
     void clearCredentials() final;
 
     std::unique_ptr<WebCore::SoupNetworkSession> m_networkSession;

Modified: trunk/Source/WebKit/Shared/AuxiliaryProcess.cpp (275115 => 275116)


--- trunk/Source/WebKit/Shared/AuxiliaryProcess.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/Shared/AuxiliaryProcess.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -30,6 +30,7 @@
 #include "LogInitialization.h"
 #include "Logging.h"
 #include "SandboxInitializationParameters.h"
+#include "WebPageProxyIdentifier.h"
 #include <WebCore/LogInitialization.h>
 #include <pal/SessionID.h>
 
@@ -90,6 +91,7 @@
     // In WebKit2, only the UI process should ever be generating certain identifiers.
     PAL::SessionID::enableGenerationProtection();
     ContentWorldIdentifier::enableGenerationProtection();
+    WebPageProxyIdentifier::enableGenerationProtection();
 
     m_connection = IPC::Connection::createClientConnection(parameters.connectionIdentifier, *this);
     initializeConnection(m_connection.get());

Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp (275115 => 275116)


--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -42,9 +42,9 @@
 namespace WebKit {
 using namespace WebCore;
 
-Ref<WebSocketChannel> WebSocketChannel::create(Document& document, WebSocketChannelClient& client)
+Ref<WebSocketChannel> WebSocketChannel::create(WebPageProxyIdentifier webPageProxyID, Document& document, WebSocketChannelClient& client)
 {
-    return adoptRef(*new WebSocketChannel(document, client));
+    return adoptRef(*new WebSocketChannel(webPageProxyID, document, client));
 }
 
 void WebSocketChannel::notifySendFrame(WebSocketFrame::OpCode opCode, const char* data, size_t length)
@@ -68,11 +68,12 @@
     } };
 }
 
-WebSocketChannel::WebSocketChannel(Document& document, WebSocketChannelClient& client)
+WebSocketChannel::WebSocketChannel(WebPageProxyIdentifier webPageProxyID, Document& document, WebSocketChannelClient& client)
     : m_document(makeWeakPtr(document))
     , m_client(makeWeakPtr(client))
     , m_messageQueue(createMessageQueue(document, *this))
     , m_inspector(document)
+    , m_webPageProxyID(webPageProxyID)
 {
     WebProcess::singleton().webSocketChannelManager().addChannel(*this);
 }
@@ -116,7 +117,7 @@
 
     m_inspector.didCreateWebSocket(m_document.get(), url);
     m_url = request->url();
-    MessageSender::send(Messages::NetworkConnectionToWebProcess::CreateSocketChannel { *request, protocol, m_identifier });
+    MessageSender::send(Messages::NetworkConnectionToWebProcess::CreateSocketChannel { *request, protocol, m_identifier, m_webPageProxyID });
     return ConnectStatus::OK;
 }
 

Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h (275115 => 275116)


--- trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.h	2021-03-26 22:05:35 UTC (rev 275116)
@@ -28,6 +28,7 @@
 #include "DataReference.h"
 #include "MessageReceiver.h"
 #include "MessageSender.h"
+#include "WebPageProxyIdentifier.h"
 #include <WebCore/NetworkSendQueue.h>
 #include <WebCore/ResourceRequest.h>
 #include <WebCore/ResourceResponse.h>
@@ -45,7 +46,7 @@
 
 class WebSocketChannel : public IPC::MessageSender, public IPC::MessageReceiver, public WebCore::ThreadableWebSocketChannel, public RefCounted<WebSocketChannel> {
 public:
-    static Ref<WebSocketChannel> create(WebCore::Document&, WebCore::WebSocketChannelClient&);
+    static Ref<WebSocketChannel> create(WebPageProxyIdentifier, WebCore::Document&, WebCore::WebSocketChannelClient&);
     ~WebSocketChannel();
 
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&);
@@ -56,7 +57,7 @@
     using RefCounted<WebSocketChannel>::deref;
 
 private:
-    WebSocketChannel(WebCore::Document&, WebCore::WebSocketChannelClient&);
+    WebSocketChannel(WebPageProxyIdentifier, WebCore::Document&, WebCore::WebSocketChannelClient&);
 
     static WebCore::NetworkSendQueue createMessageQueue(WebCore::Document&, WebSocketChannel&);
 
@@ -116,6 +117,7 @@
     WebCore::WebSocketChannelInspector m_inspector;
     WebCore::ResourceRequest m_handshakeRequest;
     WebCore::ResourceResponse m_handshakeResponse;
+    WebPageProxyIdentifier m_webPageProxyID;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketProvider.cpp (275115 => 275116)


--- trunk/Source/WebKit/WebProcess/Network/WebSocketProvider.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketProvider.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -46,7 +46,7 @@
 
 RefPtr<ThreadableWebSocketChannel> WebSocketProvider::createWebSocketChannel(Document& document, WebSocketChannelClient& client)
 {
-    return WebSocketChannel::create(document, client);
+    return WebSocketChannel::create(m_webPageProxyID, document, client);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/Network/WebSocketProvider.h (275115 => 275116)


--- trunk/Source/WebKit/WebProcess/Network/WebSocketProvider.h	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/WebProcess/Network/WebSocketProvider.h	2021-03-26 22:05:35 UTC (rev 275116)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "WebPageProxyIdentifier.h"
 #include <WebCore/SocketProvider.h>
 
 namespace WebKit {
@@ -31,10 +32,18 @@
 
 class WebSocketProvider final : public WebCore::SocketProvider {
 public:
-    static Ref<WebSocketProvider> create() { return adoptRef(*new WebSocketProvider); }
+    static Ref<WebSocketProvider> create(WebPageProxyIdentifier webPageProxyID) { return adoptRef(*new WebSocketProvider(webPageProxyID)); }
+    WebSocketProvider(WebPageProxyIdentifier webPageProxyID)
+        : m_webPageProxyID(webPageProxyID)
+    {
+    }
+
     Ref<WebCore::SocketStreamHandle> createSocketStreamHandle(const URL&, WebCore::SocketStreamHandleClient&, WebCore::WebSocketIdentifier, PAL::SessionID, const String& credentialPartition, const WebCore::StorageSessionProvider*) final;
     RefPtr<WebCore::ThreadableWebSocketChannel> createWebSocketChannel(WebCore::Document&, WebCore::WebSocketChannelClient&) final;
     virtual ~WebSocketProvider() { }
+
+private:
+    WebPageProxyIdentifier m_webPageProxyID;
 };
 
 }

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (275115 => 275116)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -124,7 +124,7 @@
 
 void WebSWContextManagerConnection::establishConnection(CompletionHandler<void()>&& completionHandler)
 {
-    m_connectionToNetworkProcess->sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::EstablishSWContextConnection { m_registrableDomain }, WTFMove(completionHandler), 0);
+    m_connectionToNetworkProcess->sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::EstablishSWContextConnection { m_webPageProxyID, m_registrableDomain }, WTFMove(completionHandler), 0);
 }
 
 void WebSWContextManagerConnection::updatePreferencesStore(const WebPreferencesStore& store)
@@ -142,7 +142,7 @@
 #if ENABLE(INDEXED_DATABASE)
     pageConfiguration.databaseProvider = WebDatabaseProvider::getOrCreate(m_pageGroupID);
 #endif
-    pageConfiguration.socketProvider = WebSocketProvider::create();
+    pageConfiguration.socketProvider = WebSocketProvider::create(m_webPageProxyID);
     pageConfiguration.userContentProvider = m_userContentController;
 #if ENABLE(WEB_RTC)
     pageConfiguration.libWebRTCProvider = makeUniqueRef<ServiceWorkerLibWebRTCProvider>();

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (275115 => 275116)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-03-26 22:00:33 UTC (rev 275115)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-03-26 22:05:35 UTC (rev 275116)
@@ -526,7 +526,7 @@
     PageConfiguration pageConfiguration(
         WebProcess::singleton().sessionID(),
         makeUniqueRef<WebEditorClient>(this),
-        WebSocketProvider::create(),
+        WebSocketProvider::create(parameters.webPageProxyIdentifier),
         createLibWebRTCProvider(*this),
         WebProcess::singleton().cacheStorageProvider(),
         m_userContentController,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to