Move NetworkProcessProxy ownership from WebProcessPool to WebsiteDataStore
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Sep 2020 21:43:46 +0000 (21:43 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Sep 2020 21:43:46 +0000 (21:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=216041

Reviewed by Brady Eidson.

Source/WebKit:

This patch moves the things on WebProcessPool associated with NetworkProcessProxy ownership and moves them
to WebsiteDataStore.  It's pretty mechanical, but it reaches its fingers into a lot of things.  Some comments
on interesting parts are below.

Why am I doing this?  I'm glad you asked.

WKWebView had a fundamental cookie problem before this change.  It had a WKWebsiteDataStore that could point to a cookie store on disk
that could be used in multiple network processes at the same time.  This led to problems with cookies being received over the network
in those different processes being unable to be shared until they were written to disk, something that does not happen immediately, especially
on iOS.  This problem is even worse with session cookies, which should be kept in memory and never be written to disk.  Those processes
did not use shared memory to share the cookies.  They just didn't share them, which led to cookie incorrectness.  This was unfortunately
the default configuration if you call [[WKWebView alloc] init] more than once, which many developers do.  There was also occasional cookie
corruption and loss from multiple processes writing cookies to the same file.  All these problems can be worked around by doing what Safari does:
manually setting the WKProcessPool of all WKWebViewConfigurations to the same process pool to only use one network process.  This is not intuitive
or well documented, and even though I have spent the majority of WWDC labs for the last 3 years telling developers to do it, most developers do not.
The default behavior should not lead to cookie incorrectness, corruption, or loss.  This accomplishes that.

A bigger problem that can't really be worked around well is what we were doing in our WKHTTPCookieStore API.  Many developers call setCookie:completionHandler:
to "log in" the user by setting a cookie, then in the completion handler, they open a WKWebView to their page and expect the cookie to be sent.  Before this
change, we would not know which process pool to set the cookie in so we would guess.  If there were no process pools, we would start writing to disk and hope
it writes fast enough.  We can't wait for it to complete because it causes hangs like rdar://problem/66961066.  This solution allows to start the network
process of that WebsiteDataStore and set the cookie in that process.  We now know that is the only process this WebsiteDataStore will ever use.  Now, users
will be able to actually be logged in all the time in such apps.

* NetworkProcess/Cookies/WebCookieManager.cpp:
(WebKit::WebCookieManager::setHTTPCookieAcceptPolicy):
(WebKit::WebCookieManager::getHTTPCookieAcceptPolicy):
* NetworkProcess/Cookies/WebCookieManager.h:
* NetworkProcess/Cookies/WebCookieManager.messages.in:
* NetworkProcess/Cookies/curl/WebCookieManagerCurl.cpp:
(WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
* NetworkProcess/Cookies/mac/WebCookieManagerMac.mm:
(WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
* NetworkProcess/Cookies/soup/WebCookieManagerSoup.cpp:
(WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::initializeNetworkProcess):
(WebKit::NetworkProcess::ensureSession):
(WebKit::NetworkProcess::storageSession const):
(WebKit::NetworkProcess::forEachNetworkStorageSession):
(WebKit::NetworkProcess::defaultStorageSession const): Deleted.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode const):
(WebKit::NetworkProcessCreationParameters::decode):
* NetworkProcess/NetworkProcessCreationParameters.h:
* NetworkProcess/WebStorage/LocalStorageDatabase.cpp:
(WebKit::LocalStorageDatabase::close):
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
(WebKit::saveCookies):
(WebKit::NetworkProcess::platformCreateDefaultStorageSession const): Deleted.
* NetworkProcess/curl/NetworkProcessCurl.cpp:
(WebKit::NetworkProcess::platformCreateDefaultStorageSession const): Deleted.
* NetworkProcess/mac/RemoteNetworkingContext.mm:
(WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
* NetworkProcess/soup/NetworkProcessSoup.cpp:
(WebKit::NetworkProcess::platformCreateDefaultStorageSession const): Deleted.
* Platform/IPC/Attachment.h:
* Shared/WebsiteDataStoreParameters.cpp:
(WebKit::WebsiteDataStoreParameters::encode const):
(WebKit::WebsiteDataStoreParameters::decode):
* Shared/WebsiteDataStoreParameters.h:
* UIProcess/API/APIHTTPCookieStore.cpp:
(API::HTTPCookieStore::HTTPCookieStore):
(API::HTTPCookieStore::~HTTPCookieStore):
(API::HTTPCookieStore::cookies):
(API::HTTPCookieStore::cookiesForURL):
(API::HTTPCookieStore::setCookies):
(API::HTTPCookieStore::deleteCookie):
(API::HTTPCookieStore::deleteAllCookies):
(API::HTTPCookieStore::setHTTPCookieAcceptPolicy):
(API::HTTPCookieStore::registerObserver):
(API::HTTPCookieStore::cookieManagerDestroyed):
(API::HTTPCookieStore::registerForNewProcessPoolNotifications): Deleted.
(API::HTTPCookieStore::unregisterForNewProcessPoolNotifications): Deleted.
* UIProcess/API/APIHTTPCookieStore.h:
* UIProcess/API/C/WKContext.cpp:
(WKContextSetUseSeparateServiceWorkerProcess):
(WKContextSetPrimaryWebsiteDataStore):
(WKContextGetCookieManager): Deleted.
(WKContextSetAllowsAnySSLCertificateForServiceWorkerTesting): Deleted.
(WKContextTerminateNetworkProcess): Deleted.
(WKContextGetNetworkProcessIdentifier): Deleted.
* UIProcess/API/C/WKContext.h:
* UIProcess/API/C/WKContextPrivate.h:
* UIProcess/API/C/WKPage.cpp:
(WKPageGetWebsiteDataStore):
* UIProcess/API/C/WKPage.h:
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreTerminateNetworkProcess):
(WKWebsiteDataStoreGetNetworkProcessIdentifier):
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _setUseSeparateServiceWorkerProcess:]):
(-[WKProcessPool _terminateNetworkProcess]): Deleted.
(-[WKProcessPool _sendNetworkProcessWillSuspendImminently]): Deleted.
(-[WKProcessPool _sendNetworkProcessPrepareToSuspend:]): Deleted.
(-[WKProcessPool _sendNetworkProcessDidResume]): Deleted.
(-[WKProcessPool _networkProcessIdentifier]): Deleted.
(-[WKProcessPool _makeNextNetworkProcessLaunchFailForTesting]): Deleted.
(-[WKProcessPool _synthesizeAppIsBackground:]): Deleted.
(-[WKProcessPool _setAllowsAnySSLCertificateForServiceWorker:]): Deleted.
(-[WKProcessPool _networkProcessHasEntitlementForTesting:]): Deleted.
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _networkProcessHasEntitlementForTesting:]):
(-[WKWebsiteDataStore _terminateNetworkProcess]):
(-[WKWebsiteDataStore _sendNetworkProcessPrepareToSuspend:]):
(-[WKWebsiteDataStore _sendNetworkProcessWillSuspendImminently]):
(-[WKWebsiteDataStore _sendNetworkProcessDidResume]):
(-[WKWebsiteDataStore _synthesizeAppIsBackground:]):
(-[WKWebsiteDataStore _networkProcessIdentifier]):
(+[WKWebsiteDataStore _makeNextNetworkProcessLaunchFailForTesting]):
* UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
* UIProcess/API/glib/WebKitCookieManager.cpp:
(_WebKitCookieManagerPrivate::cookieManager const):
(_WebKitCookieManagerPrivate::~_WebKitCookieManagerPrivate):
(webkitCookieManagerCreate):
(webkit_cookie_manager_set_persistent_storage):
(webkit_cookie_manager_set_accept_policy):
(webkit_cookie_manager_get_accept_policy):
(webkit_cookie_manager_add_cookie):
(webkit_cookie_manager_get_cookies):
(webkit_cookie_manager_delete_cookie):
* UIProcess/API/glib/WebKitWebContext.cpp:
(webkitWebContextConstructed):
(webkit_web_context_prefetch_dns):
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::addSingleCookie):
(WebKit::WebAutomationSession::deleteAllCookies):
* UIProcess/AuxiliaryProcessProxy.h:
* UIProcess/Cocoa/LegacyCustomProtocolManagerClient.h:
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::updateProcessSuppressionState):
(WebKit::WebProcessPool::platformInitialize):
(WebKit::WebProcessPool::platformInitializeNetworkProcess):
(WebKit::WebProcessPool::networkProcessHasEntitlementForTesting): Deleted.
(WebKit::WebProcessPool::xpcEndpointMessage const): Deleted.
(WebKit::WebProcessPool::sendNetworkProcessXPCEndpointToWebProcess): Deleted.
* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::cancel):
(WebKit::DownloadProxy::publishProgress):
(WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
(WebKit::DownloadProxy::willSendRequest):
(WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
* UIProcess/Downloads/DownloadProxyMap.cpp:
(WebKit::DownloadProxyMap::DownloadProxyMap):
(WebKit::DownloadProxyMap::applicationDidEnterBackground):
(WebKit::DownloadProxyMap::applicationWillEnterForeground):
(WebKit::DownloadProxyMap::createDownloadProxy):
(WebKit::DownloadProxyMap::downloadFinished):
(WebKit::DownloadProxyMap::invalidate):
* UIProcess/Downloads/DownloadProxyMap.h:
* UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.cpp:
(WebKit::LegacyCustomProtocolManagerProxy::startLoading):
(WebKit::LegacyCustomProtocolManagerProxy::stopLoading):
(WebKit::LegacyCustomProtocolManagerProxy::invalidate):
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::allNetworkProcesses):
(WebKit::defaultProcess):
(WebKit::NetworkProcessProxy::defaultNetworkProcess):
(WebKit::NetworkProcessProxy::terminate):
(WebKit::NetworkProcessProxy::didTerminate):
(WebKit::NetworkProcessProxy::sendCreationParametersToNewProcess):
(WebKit::anyProcessPoolAlwaysRunsAtBackgroundPriority):
(WebKit::anyProcessPoolShouldTakeUIBackgroundAssertion):
(WebKit::NetworkProcessProxy::NetworkProcessProxy):
(WebKit::NetworkProcessProxy::~NetworkProcessProxy):
(WebKit::NetworkProcessProxy::getLaunchOptions):
(WebKit::NetworkProcessProxy::createDownloadProxy):
(WebKit::NetworkProcessProxy::networkProcessCrashed):
(WebKit::NetworkProcessProxy::didReceiveMessage):
(WebKit::NetworkProcessProxy::didClose):
(WebKit::NetworkProcessProxy::didReceiveAuthenticationChallenge):
(WebKit::NetworkProcessProxy::didFinishLaunching):
(WebKit::NetworkProcessProxy::setDomainsWithUserInteraction):
(WebKit::NetworkProcessProxy::addSession):
(WebKit::NetworkProcessProxy::removeSession):
(WebKit::NetworkProcessProxy::websiteDataStoreFromSessionID):
(WebKit::NetworkProcessProxy::establishWorkerContextConnectionToNetworkProcess):
(WebKit::anyProcessPoolHasForegroundWebProcesses):
(WebKit::anyProcessPoolHasBackgroundWebProcesses):
(WebKit::NetworkProcessProxy::updateProcessAssertion):
(WebKit::NetworkProcessProxy::hasSession const): Deleted.
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxyCocoa.mm:
(WebKit::NetworkProcessProxy::XPCEventHandler::handleXPCEvent const):
* UIProcess/WebCookieManagerProxy.cpp:
(WebKit::WebCookieManagerProxy::WebCookieManagerProxy):
(WebKit::WebCookieManagerProxy::~WebCookieManagerProxy):
(WebKit::WebCookieManagerProxy::getHostnamesWithCookies):
(WebKit::WebCookieManagerProxy::deleteCookiesForHostnames):
(WebKit::WebCookieManagerProxy::deleteAllCookies):
(WebKit::WebCookieManagerProxy::deleteCookie):
(WebKit::WebCookieManagerProxy::deleteAllCookiesModifiedSince):
(WebKit::WebCookieManagerProxy::setCookies):
(WebKit::WebCookieManagerProxy::getAllCookies):
(WebKit::WebCookieManagerProxy::getCookies):
(WebKit::WebCookieManagerProxy::startObservingCookieChanges):
(WebKit::WebCookieManagerProxy::stopObservingCookieChanges):
(WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy):
(WebKit::WebCookieManagerProxy::getHTTPCookieAcceptPolicy):
(WebKit::WebCookieManagerProxy::supplementName): Deleted.
(WebKit::WebCookieManagerProxy::create): Deleted.
(WebKit::WebCookieManagerProxy::processPoolDestroyed): Deleted.
(WebKit::WebCookieManagerProxy::processDidClose): Deleted.
(WebKit::WebCookieManagerProxy::refWebContextSupplement): Deleted.
(WebKit::WebCookieManagerProxy::derefWebContextSupplement): Deleted.
* UIProcess/WebCookieManagerProxy.h:
(WebKit::WebCookieManagerProxy::create):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setControlledByAutomation):
(WebKit::WebPageProxy::disableServiceWorkerEntitlementInNetworkProcess):
(WebKit::WebPageProxy::clearServiceWorkerEntitlementOverride):
(WebKit::WebPageProxy::preconnectTo):
(WebKit::WebPageProxy::didCommitLoadForFrame):
(WebKit::WebPageProxy::logFrameNavigation):
(WebKit::WebPageProxy::dumpAdClickAttribution):
(WebKit::WebPageProxy::clearAdClickAttribution):
(WebKit::WebPageProxy::setAdClickAttributionOverrideTimerForTesting):
(WebKit::WebPageProxy::setAdClickAttributionConversionURLForTesting):
(WebKit::WebPageProxy::markAdClickAttributionsAsExpiredForTesting):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::urlSchemesWithCustomProtocolHandlers):
(WebKit::WebProcessPool::WebProcessPool):
(WebKit::WebProcessPool::~WebProcessPool):
(WebKit::WebProcessPool::languageChanged):
(WebKit::WebProcessPool::sendMemoryPressureEvent):
(WebKit::WebProcessPool::networkProcessCrashed):
(WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
(WebKit::WebProcessPool::removeFromServiceWorkerProcesses):
(WebKit::WebProcessPool::tryTakePrewarmedProcess):
(WebKit::WebProcessPool::initializeNewWebProcess):
(WebKit::WebProcessPool::processDidFinishLaunching):
(WebKit::WebProcessPool::createWebPage):
(WebKit::WebProcessPool::updateServiceWorkerUserAgent):
(WebKit::WebProcessPool::pageBeginUsingWebsiteDataStore):
(WebKit::WebProcessPool::download):
(WebKit::WebProcessPool::resumeDownload):
(WebKit::WebProcessPool::registerURLSchemeAsSecure):
(WebKit::WebProcessPool::registerURLSchemeAsBypassingContentSecurityPolicy):
(WebKit::WebProcessPool::registerURLSchemeAsLocal):
(WebKit::WebProcessPool::registerURLSchemeAsNoAccess):
(WebKit::WebProcessPool::registerGlobalURLSchemeAsHavingCustomProtocolHandlers):
(WebKit::WebProcessPool::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers):
(WebKit::WebProcessPool::setCacheModel):
(WebKit::WebProcessPool::setCacheModelSynchronouslyForTesting):
(WebKit::WebProcessPool::createDownloadProxy):
(WebKit::WebProcessPool::terminateServiceWorkers):
(WebKit::WebProcessPool::serviceWorkerProcesses):
(WebKit::WebProcessPool::updateProcessAssertions):
(WebKit::WebProcessPool::isServiceWorkerPageID const):
(WebKit::WebProcessPool::setUseSeparateServiceWorkerProcess):
(WebKit::WebProcessPool::hasServiceWorkerForegroundActivityForTesting const):
(WebKit::WebProcessPool::hasServiceWorkerBackgroundActivityForTesting const):
(WebKit::WebProcessPool::setLegacyCustomProtocolManagerClient): Deleted.
(WebKit::WebProcessPool::networkingProcessConnection): Deleted.
(WebKit::WebProcessPool::ensureNetworkProcess): Deleted.
There seems to be a lot of code removal here, but most of it was duplicate code with
WebsiteDataStore::parameters which is used instead.  That which was not duplicate was
moved to NetworkProcessProxy::sendCreationParametersToNewProcess.  This was the hardest part of this patch.
(WebKit::WebProcessPool::getNetworkProcessConnection): Deleted.
(WebKit::WebProcessPool::networkProcessIdentifier): Deleted.
(WebKit::WebProcessPool::synthesizeAppIsBackground): Deleted.
(WebKit::WebProcessPool::sendSyncToNetworkingProcess): Deleted.
(WebKit::WebProcessPool::clearCachedCredentials): Deleted.
(WebKit::WebProcessPool::terminateNetworkProcess): Deleted.
(WebKit::WebProcessPool::sendNetworkProcessPrepareToSuspendForTesting): Deleted.
(WebKit::WebProcessPool::sendNetworkProcessWillSuspendImminentlyForTesting): Deleted.
(WebKit::WebProcessPool::sendNetworkProcessDidResume): Deleted.
(WebKit::WebProcessPool::flushCookies): Deleted.
(WebKit::WebProcessPool::didCommitCrossSiteLoadWithDataTransfer): Deleted.
* UIProcess/WebProcessPool.h:
(WebKit::WebProcessPool::sendToNetworkingProcess): Deleted.
(WebKit::WebProcessPool::sendToNetworkingProcessRelaunchingIfNecessary): Deleted.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::setWebsiteDataStore):
(WebKit::WebProcessProxy::getNetworkProcessConnection):
(WebKit::WebProcessProxy::didFinishLaunching):
* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::networkProcessHasEntitlementForTesting):
(WebKit::WebsiteDataStore::sendNetworkProcessXPCEndpointToWebProcess):
(WebKit::WebsiteDataStore::sendNetworkProcessXPCEndpointToAllWebProcesses):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::forEachWebsiteDataStore):
(WebKit::WebsiteDataStore::WebsiteDataStore):
(WebKit::WebsiteDataStore::~WebsiteDataStore):
(WebKit::WebsiteDataStore::registerWithSessionIDMap):
(WebKit::WebsiteDataStore::existingDataStoreForSessionID):
(WebKit::WebsiteDataStore::networkProcess):
(WebKit::WebsiteDataStore::networkProcess const):
(WebKit::WebsiteDataStore::fetchDataAndApply):
(WebKit::WebsiteDataStore::removeData):
(WebKit::WebsiteDataStore::setServiceWorkerTimeoutForTesting):
(WebKit::WebsiteDataStore::resetServiceWorkerTimeoutForTesting):
(WebKit::WebsiteDataStore::setMaxStatisticsEntries):
(WebKit::WebsiteDataStore::setPruneEntriesDownTo):
(WebKit::WebsiteDataStore::setGrandfatheringTime):
(WebKit::WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval):
(WebKit::WebsiteDataStore::dumpResourceLoadStatistics):
(WebKit::WebsiteDataStore::isPrevalentResource):
(WebKit::WebsiteDataStore::isGrandfathered):
(WebKit::WebsiteDataStore::setPrevalentResource):
(WebKit::WebsiteDataStore::setPrevalentResourceForDebugMode):
(WebKit::WebsiteDataStore::isVeryPrevalentResource):
(WebKit::WebsiteDataStore::setVeryPrevalentResource):
(WebKit::WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
(WebKit::WebsiteDataStore::setSubframeUnderTopFrameDomain):
(WebKit::WebsiteDataStore::isRegisteredAsSubFrameUnder):
(WebKit::WebsiteDataStore::setSubresourceUnderTopFrameDomain):
(WebKit::WebsiteDataStore::isRegisteredAsSubresourceUnder):
(WebKit::WebsiteDataStore::setSubresourceUniqueRedirectTo):
(WebKit::WebsiteDataStore::setSubresourceUniqueRedirectFrom):
(WebKit::WebsiteDataStore::setTopFrameUniqueRedirectTo):
(WebKit::WebsiteDataStore::setTopFrameUniqueRedirectFrom):
(WebKit::WebsiteDataStore::isRegisteredAsRedirectingTo):
(WebKit::WebsiteDataStore::clearPrevalentResource):
(WebKit::WebsiteDataStore::resetParametersToDefaultValues):
(WebKit::WebsiteDataStore::submitTelemetry):
(WebKit::WebsiteDataStore::scheduleClearInMemoryAndPersistent):
(WebKit::WebsiteDataStore::getResourceLoadStatisticsDataSummary):
(WebKit::WebsiteDataStore::scheduleCookieBlockingUpdate):
(WebKit::WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing):
(WebKit::WebsiteDataStore::statisticsDatabaseHasAllTables):
(WebKit::WebsiteDataStore::setLastSeen):
(WebKit::WebsiteDataStore::domainIDExistsInDatabase):
(WebKit::WebsiteDataStore::mergeStatisticForTesting):
(WebKit::WebsiteDataStore::insertExpiredStatisticForTesting):
(WebKit::WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned):
(WebKit::WebsiteDataStore::setIsRunningResourceLoadStatisticsTest):
(WebKit::WebsiteDataStore::getAllStorageAccessEntries):
(WebKit::WebsiteDataStore::setTimeToLiveUserInteraction):
(WebKit::WebsiteDataStore::logUserInteraction):
(WebKit::WebsiteDataStore::hasHadUserInteraction):
(WebKit::WebsiteDataStore::isRelationshipOnlyInDatabaseOnce):
(WebKit::WebsiteDataStore::clearUserInteraction):
(WebKit::WebsiteDataStore::setGrandfathered):
(WebKit::WebsiteDataStore::setUseITPDatabase):
(WebKit::WebsiteDataStore::setCrossSiteLoadWithLinkDecorationForTesting):
(WebKit::WebsiteDataStore::resetCrossSiteLoadsWithLinkDecorationForTesting):
(WebKit::WebsiteDataStore::deleteCookiesForTesting):
(WebKit::WebsiteDataStore::hasLocalStorageForTesting const):
(WebKit::WebsiteDataStore::hasIsolatedSessionForTesting const):
(WebKit::WebsiteDataStore::setResourceLoadStatisticsShouldDowngradeReferrerForTesting):
(WebKit::WebsiteDataStore::setThirdPartyCookieBlockingMode):
(WebKit::WebsiteDataStore::setResourceLoadStatisticsShouldEnbleSameSiteStrictEnforcementForTesting):
(WebKit::WebsiteDataStore::setResourceLoadStatisticsFirstPartyWebsiteDataRemovalModeForTesting):
(WebKit::WebsiteDataStore::setResourceLoadStatisticsToSameSiteStrictCookiesForTesting):
(WebKit::WebsiteDataStore::setResourceLoadStatisticsFirstPartyHostCNAMEDomainForTesting):
(WebKit::WebsiteDataStore::setResourceLoadStatisticsThirdPartyCNAMEDomainForTesting):
(WebKit::WebsiteDataStore::syncLocalStorage):
(WebKit::WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources):
(WebKit::WebsiteDataStore::resetCacheMaxAgeCapForPrevalentResources):
(WebKit::WebsiteDataStore::processPools const):
(WebKit::WebsiteDataStore::allowSpecificHTTPSCertificateForHost):
(WebKit::WebsiteDataStore::getNetworkProcessConnection):
(WebKit::WebsiteDataStore::networkProcessCrashed):
(WebKit::WebsiteDataStore::terminateNetworkProcess):
(WebKit::WebsiteDataStore::sendNetworkProcessPrepareToSuspendForTesting):
(WebKit::WebsiteDataStore::sendNetworkProcessWillSuspendImminentlyForTesting):
(WebKit::WebsiteDataStore::sendNetworkProcessDidResume):
(WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
(WebKit::WebsiteDataStore::setStatisticsTestingCallback):
(WebKit::WebsiteDataStore::setResourceLoadStatisticsDebugMode):
(WebKit::WebsiteDataStore::isResourceLoadStatisticsEphemeral const):
(WebKit::WebsiteDataStore::setAdClickAttributionDebugMode):
(WebKit::WebsiteDataStore::flushCookies):
(WebKit::WebsiteDataStore::setAllowsAnySSLCertificateForWebSocket):
(WebKit::WebsiteDataStore::clearCachedCredentials):
(WebKit::WebsiteDataStore::parameters):
(WebKit::WebsiteDataStore::getLocalStorageDetails):
(WebKit::WebsiteDataStore::resetQuota):
(WebKit::WebsiteDataStore::networkProcessHasEntitlementForTesting):
(WebKit::WebsiteDataStore::renameOriginInWebsiteData):
(WebKit::WebsiteDataStore::hasAppBoundSession const):
(WebKit::WebsiteDataStore::clearAppBoundSession):
(WebKit::WebsiteDataStore::forwardAppBoundDomainsToITPIfInitialized):
(WebKit::WebsiteDataStore::setAppBoundDomainsForITP):
(WebKit::WebsiteDataStore::updateBundleIdentifierInNetworkProcess):
(WebKit::WebsiteDataStore::clearBundleIdentifierInNetworkProcess):
(WebKit::WebsiteDataStore::makeNextNetworkProcessLaunchFailForTesting):
(WebKit::WebsiteDataStore::shouldMakeNextNetworkProcessLaunchFailForTesting):
(WebKit::WebsiteDataStore::maybeRegisterWithSessionIDMap): Deleted.
(WebKit::WebsiteDataStore::existingNonDefaultDataStoreForSessionID): Deleted.
(WebKit::WebsiteDataStore::processPoolForCookieStorageOperations): Deleted.
(WebKit::WebsiteDataStore::isAssociatedProcessPool const): Deleted.
(WebKit::WebsiteDataStore::pendingCookies const): Deleted.
(WebKit::WebsiteDataStore::addPendingCookie): Deleted.
(WebKit::WebsiteDataStore::removePendingCookie): Deleted.
(WebKit::WebsiteDataStore::clearPendingCookies): Deleted.
(WebKit::WebsiteDataStore::didCreateNetworkProcess): Deleted.
* UIProcess/WebsiteData/WebsiteDataStore.h:
* UIProcess/WebsiteData/curl/WebsiteDataStoreCurl.cpp:
(WebKit::WebsiteDataStore::setNetworkProxySettings):
* UIProcess/WebsiteData/soup/WebsiteDataStoreSoup.cpp:
(WebKit::WebsiteDataStore::platformSetNetworkParameters):
(WebKit::WebsiteDataStore::setPersistentCredentialStorageEnabled):
* UIProcess/glib/WebProcessProxyGLib.cpp:
(WebKit::WebProcessProxy::platformGetLaunchOptions):
* UIProcess/soup/WebCookieManagerProxySoup.cpp:
(WebKit::WebCookieManagerProxy::setCookiePersistentStorage):
* UIProcess/soup/WebProcessPoolSoup.cpp:
(WebKit::WebProcessPool::platformInitializeNetworkProcess):
(WebKit::WebProcessPool::setIgnoreTLSErrors):
(WebKit::WebProcessPool::setNetworkProxySettings):
* WebProcess/Network/NetworkProcessConnectionInfo.h:

Tools:

Most changes to tests are just calling a function on the WKWebsiteDataStore instead of the WKProcessPool
because we want to do something with the network process and it has a new owner.
Exceptions are noted inline.

* TestWebKitAPI/Tests/WebKit/NetworkProcessCrashWithPendingConnection.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
(TestWebKitAPI::downloadAtRate):
* TestWebKitAPI/Tests/WebKitCocoa/IDBCheckpointWAL.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/IDBDeleteRecovery.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/IDBIndexUpgradeToV2.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/IDBObjectStoreInfoUpgradeToV2.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/IndexedDBDatabaseProcessKill.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/IndexedDBMultiProcess.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/IndexedDBPersistence.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/IndexedDBSuspendImminently.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/IndexedDBTempFileSize.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/NetworkProcessCrashNonPersistentDataStore.mm:
(checkRecoveryAfterCrash):
* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
* TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
(TEST):
This test was making a WKWebsiteDataStore, getting its resource load statistics directory,
putting things in that directory, then starting the network process and making sure everything
works when initializing the network process.  Now, network process initialization happens when a
WKWebsiteDataStore is instantiated, so we need to put things there before instantiating a WKWebsiteDataStore.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
Before this change, each WKProcessPool had its own network process, which holds the service worker registry
for the WebsiteDataStores used with that process pool.  Now, the network process still needs to have a service
worker registry in it, but when we receive a message from it looking for a web process to run the service
worker, we go arbitrarily to the first process pool that has a process we can use.  This logic is in
WebProcessPool::establishWorkerContextConnectionToNetworkProcess.  Because we use the first process pool each
time, setting the custom user agent to two different things in two different process pools causes only one
to be used.  This is not a problem in practice, though, because the only application that uses the SPI to
set a service worker's custom user agent is Safari, which only has one process pool.  This test still verifies
that a user ageint is correctly sent.
Similarly, the tests that count service worker processes either have different results or need to be run with
one process pool per parent process.  To keep the results the same, I separated the tests into different
TEST(ServiceWorkers, ...) macros which are run in separate parent processes.
The test RestoreFromDiskNonDefaultStore needs to use the same data store for both WKWebViews now because otherwise
there was a race condition in the startup of a new network process that wasn't there before because we were using the
same process pool and therefore the same network process.  I added spinning the run loop and sleeping to be able to
reproduce the race condition failure and I use the same WKWebsiteDataStore to use the same network process, which was
the intent of using the same WKProcessPool before.  The test still tests that the registration is re-used when we are
not using the default data store.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
(-[CheckSessionCookieUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(-[CheckSessionCookieUIDelegate waitForMessage]):
(-[CheckSessionCookieUIDelegate alertCookieHTML]):
(TEST):
This is the whole point of me doing this.
I took a test that was flaky only on iOS (because of different NSHTTPCookieStorage syncing behavior) and made
it flaky nowhere (fingers crossed!) and added a test that correctly handles session cookies like we could not
before this change.
I also re-used some test infrastructure and made it stop using process-global static variables for test state.
* TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-leaks.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
(runWebsiteDataStoreCustomPaths):
(TEST):
* TestWebKitAPI/Tests/WebKitObjC/CustomProtocolsTest.mm:
(-[CloseWhileStartingProtocol startLoading]):
(TestWebKitAPI::runTest):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetStateToConsistentValues):
(WTR::TestController::findAndDumpWebKitProcessIdentifiers):
(WTR::TestController::networkProcessDidCrash):
(WTR::TestController::terminateNetworkProcess):
(WTR::TestController::platformAdjustContext):
WKContextSetAllowsAnySSLCertificateForServiceWorkerTesting is not needed, so I removed it.
WKContextSetPrimaryWebsiteDataStore isn't needed any more because WKContextRef (WebProcessPool) doesn't
own a network process any more, so it doesn't care which is the default WebsiteDataStore.
In fact, the "default" WebsiteDataStore isn't really important in the network process any more.

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

88 files changed:
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp
Source/WebKit/NetworkProcess/Cookies/WebCookieManager.h
Source/WebKit/NetworkProcess/Cookies/WebCookieManager.messages.in
Source/WebKit/NetworkProcess/Cookies/curl/WebCookieManagerCurl.cpp
Source/WebKit/NetworkProcess/Cookies/mac/WebCookieManagerMac.mm
Source/WebKit/NetworkProcess/Cookies/soup/WebCookieManagerSoup.cpp
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp
Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h
Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp
Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
Source/WebKit/NetworkProcess/curl/NetworkProcessCurl.cpp
Source/WebKit/NetworkProcess/mac/RemoteNetworkingContext.mm
Source/WebKit/NetworkProcess/soup/NetworkProcessMainSoup.cpp
Source/WebKit/NetworkProcess/soup/NetworkProcessSoup.cpp
Source/WebKit/Platform/IPC/Attachment.h
Source/WebKit/Shared/WebsiteDataStoreParameters.cpp
Source/WebKit/Shared/WebsiteDataStoreParameters.h
Source/WebKit/UIProcess/API/APIHTTPCookieStore.cpp
Source/WebKit/UIProcess/API/APIHTTPCookieStore.h
Source/WebKit/UIProcess/API/C/WKContext.cpp
Source/WebKit/UIProcess/API/C/WKContext.h
Source/WebKit/UIProcess/API/C/WKContextPrivate.h
Source/WebKit/UIProcess/API/C/WKPage.cpp
Source/WebKit/UIProcess/API/C/WKPage.h
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h
Source/WebKit/UIProcess/API/glib/WebKitCookieManager.cpp
Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp
Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataManager.cpp
Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataManagerPrivate.h
Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
Source/WebKit/UIProcess/AuxiliaryProcessProxy.h
Source/WebKit/UIProcess/Cocoa/LegacyCustomProtocolManagerClient.h
Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Source/WebKit/UIProcess/Downloads/DownloadProxy.cpp
Source/WebKit/UIProcess/Downloads/DownloadProxyMap.cpp
Source/WebKit/UIProcess/Downloads/DownloadProxyMap.h
Source/WebKit/UIProcess/Inspector/gtk/WebInspectorProxyGtk.cpp
Source/WebKit/UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit/UIProcess/Network/NetworkProcessProxyCocoa.mm
Source/WebKit/UIProcess/WebCookieManagerProxy.cpp
Source/WebKit/UIProcess/WebCookieManagerProxy.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
Source/WebKit/UIProcess/WebsiteData/curl/WebsiteDataStoreCurl.cpp
Source/WebKit/UIProcess/WebsiteData/soup/WebsiteDataStoreSoup.cpp
Source/WebKit/UIProcess/glib/WebProcessProxyGLib.cpp
Source/WebKit/UIProcess/soup/WebCookieManagerProxySoup.cpp
Source/WebKit/UIProcess/soup/WebProcessPoolSoup.cpp
Source/WebKit/WebProcess/Network/NetworkProcessConnectionInfo.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit/NetworkProcessCrashWithPendingConnection.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/IDBCheckpointWAL.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/IDBDeleteRecovery.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/IDBIndexUpgradeToV2.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/IDBObjectStoreInfoUpgradeToV2.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/IndexedDBDatabaseProcessKill.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/IndexedDBMultiProcess.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/IndexedDBPersistence.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/IndexedDBSuspendImminently.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/IndexedDBTempFileSize.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/NetworkProcessCrashNonPersistentDataStore.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-leaks.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm
Tools/TestWebKitAPI/Tests/WebKitObjC/CustomProtocolsTest.mm
Tools/WebKitTestRunner/TestController.cpp

index 904757f..30da435 100644 (file)
@@ -1,3 +1,418 @@
+2020-09-29  Alex Christensen  <achristensen@webkit.org>
+
+        Move NetworkProcessProxy ownership from WebProcessPool to WebsiteDataStore
+        https://bugs.webkit.org/show_bug.cgi?id=216041
+
+        Reviewed by Brady Eidson.
+
+        This patch moves the things on WebProcessPool associated with NetworkProcessProxy ownership and moves them
+        to WebsiteDataStore.  It's pretty mechanical, but it reaches its fingers into a lot of things.  Some comments
+        on interesting parts are below.
+
+        Why am I doing this?  I'm glad you asked.
+
+        WKWebView had a fundamental cookie problem before this change.  It had a WKWebsiteDataStore that could point to a cookie store on disk
+        that could be used in multiple network processes at the same time.  This led to problems with cookies being received over the network
+        in those different processes being unable to be shared until they were written to disk, something that does not happen immediately, especially
+        on iOS.  This problem is even worse with session cookies, which should be kept in memory and never be written to disk.  Those processes
+        did not use shared memory to share the cookies.  They just didn't share them, which led to cookie incorrectness.  This was unfortunately
+        the default configuration if you call [[WKWebView alloc] init] more than once, which many developers do.  There was also occasional cookie
+        corruption and loss from multiple processes writing cookies to the same file.  All these problems can be worked around by doing what Safari does:
+        manually setting the WKProcessPool of all WKWebViewConfigurations to the same process pool to only use one network process.  This is not intuitive
+        or well documented, and even though I have spent the majority of WWDC labs for the last 3 years telling developers to do it, most developers do not.
+        The default behavior should not lead to cookie incorrectness, corruption, or loss.  This accomplishes that.
+
+        A bigger problem that can't really be worked around well is what we were doing in our WKHTTPCookieStore API.  Many developers call setCookie:completionHandler:
+        to "log in" the user by setting a cookie, then in the completion handler, they open a WKWebView to their page and expect the cookie to be sent.  Before this
+        change, we would not know which process pool to set the cookie in so we would guess.  If there were no process pools, we would start writing to disk and hope
+        it writes fast enough.  We can't wait for it to complete because it causes hangs like rdar://problem/66961066.  This solution allows to start the network
+        process of that WebsiteDataStore and set the cookie in that process.  We now know that is the only process this WebsiteDataStore will ever use.  Now, users
+        will be able to actually be logged in all the time in such apps.
+
+        * NetworkProcess/Cookies/WebCookieManager.cpp:
+        (WebKit::WebCookieManager::setHTTPCookieAcceptPolicy):
+        (WebKit::WebCookieManager::getHTTPCookieAcceptPolicy):
+        * NetworkProcess/Cookies/WebCookieManager.h:
+        * NetworkProcess/Cookies/WebCookieManager.messages.in:
+        * NetworkProcess/Cookies/curl/WebCookieManagerCurl.cpp:
+        (WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
+        * NetworkProcess/Cookies/mac/WebCookieManagerMac.mm:
+        (WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
+        * NetworkProcess/Cookies/soup/WebCookieManagerSoup.cpp:
+        (WebKit::WebCookieManager::platformSetHTTPCookieAcceptPolicy):
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::initializeNetworkProcess):
+        (WebKit::NetworkProcess::ensureSession):
+        (WebKit::NetworkProcess::storageSession const):
+        (WebKit::NetworkProcess::forEachNetworkStorageSession):
+        (WebKit::NetworkProcess::defaultStorageSession const): Deleted.
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcessCreationParameters.cpp:
+        (WebKit::NetworkProcessCreationParameters::encode const):
+        (WebKit::NetworkProcessCreationParameters::decode):
+        * NetworkProcess/NetworkProcessCreationParameters.h:
+        * NetworkProcess/WebStorage/LocalStorageDatabase.cpp:
+        (WebKit::LocalStorageDatabase::close):
+        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+        (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
+        (WebKit::saveCookies):
+        (WebKit::NetworkProcess::platformCreateDefaultStorageSession const): Deleted.
+        * NetworkProcess/curl/NetworkProcessCurl.cpp:
+        (WebKit::NetworkProcess::platformCreateDefaultStorageSession const): Deleted.
+        * NetworkProcess/mac/RemoteNetworkingContext.mm:
+        (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
+        * NetworkProcess/soup/NetworkProcessSoup.cpp:
+        (WebKit::NetworkProcess::platformCreateDefaultStorageSession const): Deleted.
+        * Platform/IPC/Attachment.h:
+        * Shared/WebsiteDataStoreParameters.cpp:
+        (WebKit::WebsiteDataStoreParameters::encode const):
+        (WebKit::WebsiteDataStoreParameters::decode):
+        * Shared/WebsiteDataStoreParameters.h:
+        * UIProcess/API/APIHTTPCookieStore.cpp:
+        (API::HTTPCookieStore::HTTPCookieStore):
+        (API::HTTPCookieStore::~HTTPCookieStore):
+        (API::HTTPCookieStore::cookies):
+        (API::HTTPCookieStore::cookiesForURL):
+        (API::HTTPCookieStore::setCookies):
+        (API::HTTPCookieStore::deleteCookie):
+        (API::HTTPCookieStore::deleteAllCookies):
+        (API::HTTPCookieStore::setHTTPCookieAcceptPolicy):
+        (API::HTTPCookieStore::registerObserver):
+        (API::HTTPCookieStore::cookieManagerDestroyed):
+        (API::HTTPCookieStore::registerForNewProcessPoolNotifications): Deleted.
+        (API::HTTPCookieStore::unregisterForNewProcessPoolNotifications): Deleted.
+        * UIProcess/API/APIHTTPCookieStore.h:
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextSetUseSeparateServiceWorkerProcess):
+        (WKContextSetPrimaryWebsiteDataStore):
+        (WKContextGetCookieManager): Deleted.
+        (WKContextSetAllowsAnySSLCertificateForServiceWorkerTesting): Deleted.
+        (WKContextTerminateNetworkProcess): Deleted.
+        (WKContextGetNetworkProcessIdentifier): Deleted.
+        * UIProcess/API/C/WKContext.h:
+        * UIProcess/API/C/WKContextPrivate.h:
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageGetWebsiteDataStore):
+        * UIProcess/API/C/WKPage.h:
+        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+        (WKWebsiteDataStoreTerminateNetworkProcess):
+        (WKWebsiteDataStoreGetNetworkProcessIdentifier):
+        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (-[WKProcessPool _setUseSeparateServiceWorkerProcess:]):
+        (-[WKProcessPool _terminateNetworkProcess]): Deleted.
+        (-[WKProcessPool _sendNetworkProcessWillSuspendImminently]): Deleted.
+        (-[WKProcessPool _sendNetworkProcessPrepareToSuspend:]): Deleted.
+        (-[WKProcessPool _sendNetworkProcessDidResume]): Deleted.
+        (-[WKProcessPool _networkProcessIdentifier]): Deleted.
+        (-[WKProcessPool _makeNextNetworkProcessLaunchFailForTesting]): Deleted.
+        (-[WKProcessPool _synthesizeAppIsBackground:]): Deleted.
+        (-[WKProcessPool _setAllowsAnySSLCertificateForServiceWorker:]): Deleted.
+        (-[WKProcessPool _networkProcessHasEntitlementForTesting:]): Deleted.
+        * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
+        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+        (-[WKWebsiteDataStore _networkProcessHasEntitlementForTesting:]):
+        (-[WKWebsiteDataStore _terminateNetworkProcess]):
+        (-[WKWebsiteDataStore _sendNetworkProcessPrepareToSuspend:]):
+        (-[WKWebsiteDataStore _sendNetworkProcessWillSuspendImminently]):
+        (-[WKWebsiteDataStore _sendNetworkProcessDidResume]):
+        (-[WKWebsiteDataStore _synthesizeAppIsBackground:]):
+        (-[WKWebsiteDataStore _networkProcessIdentifier]):
+        (+[WKWebsiteDataStore _makeNextNetworkProcessLaunchFailForTesting]):
+        * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+        * UIProcess/API/glib/WebKitCookieManager.cpp:
+        (_WebKitCookieManagerPrivate::cookieManager const):
+        (_WebKitCookieManagerPrivate::~_WebKitCookieManagerPrivate):
+        (webkitCookieManagerCreate):
+        (webkit_cookie_manager_set_persistent_storage):
+        (webkit_cookie_manager_set_accept_policy):
+        (webkit_cookie_manager_get_accept_policy):
+        (webkit_cookie_manager_add_cookie):
+        (webkit_cookie_manager_get_cookies):
+        (webkit_cookie_manager_delete_cookie):
+        * UIProcess/API/glib/WebKitWebContext.cpp:
+        (webkitWebContextConstructed):
+        (webkit_web_context_prefetch_dns):
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::addSingleCookie):
+        (WebKit::WebAutomationSession::deleteAllCookies):
+        * UIProcess/AuxiliaryProcessProxy.h:
+        * UIProcess/Cocoa/LegacyCustomProtocolManagerClient.h:
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::updateProcessSuppressionState):
+        (WebKit::WebProcessPool::platformInitialize):
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+        (WebKit::WebProcessPool::networkProcessHasEntitlementForTesting): Deleted.
+        (WebKit::WebProcessPool::xpcEndpointMessage const): Deleted.
+        (WebKit::WebProcessPool::sendNetworkProcessXPCEndpointToWebProcess): Deleted.
+        * UIProcess/Downloads/DownloadProxy.cpp:
+        (WebKit::DownloadProxy::cancel):
+        (WebKit::DownloadProxy::publishProgress):
+        (WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
+        (WebKit::DownloadProxy::willSendRequest):
+        (WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
+        * UIProcess/Downloads/DownloadProxyMap.cpp:
+        (WebKit::DownloadProxyMap::DownloadProxyMap):
+        (WebKit::DownloadProxyMap::applicationDidEnterBackground):
+        (WebKit::DownloadProxyMap::applicationWillEnterForeground):
+        (WebKit::DownloadProxyMap::createDownloadProxy):
+        (WebKit::DownloadProxyMap::downloadFinished):
+        (WebKit::DownloadProxyMap::invalidate):
+        * UIProcess/Downloads/DownloadProxyMap.h:
+        * UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.cpp:
+        (WebKit::LegacyCustomProtocolManagerProxy::startLoading):
+        (WebKit::LegacyCustomProtocolManagerProxy::stopLoading):
+        (WebKit::LegacyCustomProtocolManagerProxy::invalidate):
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::allNetworkProcesses):
+        (WebKit::defaultProcess):
+        (WebKit::NetworkProcessProxy::defaultNetworkProcess):
+        (WebKit::NetworkProcessProxy::terminate):
+        (WebKit::NetworkProcessProxy::didTerminate):
+        (WebKit::NetworkProcessProxy::sendCreationParametersToNewProcess):
+        (WebKit::anyProcessPoolAlwaysRunsAtBackgroundPriority):
+        (WebKit::anyProcessPoolShouldTakeUIBackgroundAssertion):
+        (WebKit::NetworkProcessProxy::NetworkProcessProxy):
+        (WebKit::NetworkProcessProxy::~NetworkProcessProxy):
+        (WebKit::NetworkProcessProxy::getLaunchOptions):
+        (WebKit::NetworkProcessProxy::createDownloadProxy):
+        (WebKit::NetworkProcessProxy::networkProcessCrashed):
+        (WebKit::NetworkProcessProxy::didReceiveMessage):
+        (WebKit::NetworkProcessProxy::didClose):
+        (WebKit::NetworkProcessProxy::didReceiveAuthenticationChallenge):
+        (WebKit::NetworkProcessProxy::didFinishLaunching):
+        (WebKit::NetworkProcessProxy::setDomainsWithUserInteraction):
+        (WebKit::NetworkProcessProxy::addSession):
+        (WebKit::NetworkProcessProxy::removeSession):
+        (WebKit::NetworkProcessProxy::websiteDataStoreFromSessionID):
+        (WebKit::NetworkProcessProxy::establishWorkerContextConnectionToNetworkProcess):
+        (WebKit::anyProcessPoolHasForegroundWebProcesses):
+        (WebKit::anyProcessPoolHasBackgroundWebProcesses):
+        (WebKit::NetworkProcessProxy::updateProcessAssertion):
+        (WebKit::NetworkProcessProxy::hasSession const): Deleted.
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxyCocoa.mm:
+        (WebKit::NetworkProcessProxy::XPCEventHandler::handleXPCEvent const):
+        * UIProcess/WebCookieManagerProxy.cpp:
+        (WebKit::WebCookieManagerProxy::WebCookieManagerProxy):
+        (WebKit::WebCookieManagerProxy::~WebCookieManagerProxy):
+        (WebKit::WebCookieManagerProxy::getHostnamesWithCookies):
+        (WebKit::WebCookieManagerProxy::deleteCookiesForHostnames):
+        (WebKit::WebCookieManagerProxy::deleteAllCookies):
+        (WebKit::WebCookieManagerProxy::deleteCookie):
+        (WebKit::WebCookieManagerProxy::deleteAllCookiesModifiedSince):
+        (WebKit::WebCookieManagerProxy::setCookies):
+        (WebKit::WebCookieManagerProxy::getAllCookies):
+        (WebKit::WebCookieManagerProxy::getCookies):
+        (WebKit::WebCookieManagerProxy::startObservingCookieChanges):
+        (WebKit::WebCookieManagerProxy::stopObservingCookieChanges):
+        (WebKit::WebCookieManagerProxy::setHTTPCookieAcceptPolicy):
+        (WebKit::WebCookieManagerProxy::getHTTPCookieAcceptPolicy):
+        (WebKit::WebCookieManagerProxy::supplementName): Deleted.
+        (WebKit::WebCookieManagerProxy::create): Deleted.
+        (WebKit::WebCookieManagerProxy::processPoolDestroyed): Deleted.
+        (WebKit::WebCookieManagerProxy::processDidClose): Deleted.
+        (WebKit::WebCookieManagerProxy::refWebContextSupplement): Deleted.
+        (WebKit::WebCookieManagerProxy::derefWebContextSupplement): Deleted.
+        * UIProcess/WebCookieManagerProxy.h:
+        (WebKit::WebCookieManagerProxy::create):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setControlledByAutomation):
+        (WebKit::WebPageProxy::disableServiceWorkerEntitlementInNetworkProcess):
+        (WebKit::WebPageProxy::clearServiceWorkerEntitlementOverride):
+        (WebKit::WebPageProxy::preconnectTo):
+        (WebKit::WebPageProxy::didCommitLoadForFrame):
+        (WebKit::WebPageProxy::logFrameNavigation):
+        (WebKit::WebPageProxy::dumpAdClickAttribution):
+        (WebKit::WebPageProxy::clearAdClickAttribution):
+        (WebKit::WebPageProxy::setAdClickAttributionOverrideTimerForTesting):
+        (WebKit::WebPageProxy::setAdClickAttributionConversionURLForTesting):
+        (WebKit::WebPageProxy::markAdClickAttributionsAsExpiredForTesting):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::urlSchemesWithCustomProtocolHandlers):
+        (WebKit::WebProcessPool::WebProcessPool):
+        (WebKit::WebProcessPool::~WebProcessPool):
+        (WebKit::WebProcessPool::languageChanged):
+        (WebKit::WebProcessPool::sendMemoryPressureEvent):
+        (WebKit::WebProcessPool::networkProcessCrashed):
+        (WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
+        (WebKit::WebProcessPool::removeFromServiceWorkerProcesses):
+        (WebKit::WebProcessPool::tryTakePrewarmedProcess):
+        (WebKit::WebProcessPool::initializeNewWebProcess):
+        (WebKit::WebProcessPool::processDidFinishLaunching):
+        (WebKit::WebProcessPool::createWebPage):
+        (WebKit::WebProcessPool::updateServiceWorkerUserAgent):
+        (WebKit::WebProcessPool::pageBeginUsingWebsiteDataStore):
+        (WebKit::WebProcessPool::download):
+        (WebKit::WebProcessPool::resumeDownload):
+        (WebKit::WebProcessPool::registerURLSchemeAsSecure):
+        (WebKit::WebProcessPool::registerURLSchemeAsBypassingContentSecurityPolicy):
+        (WebKit::WebProcessPool::registerURLSchemeAsLocal):
+        (WebKit::WebProcessPool::registerURLSchemeAsNoAccess):
+        (WebKit::WebProcessPool::registerGlobalURLSchemeAsHavingCustomProtocolHandlers):
+        (WebKit::WebProcessPool::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers):
+        (WebKit::WebProcessPool::setCacheModel):
+        (WebKit::WebProcessPool::setCacheModelSynchronouslyForTesting):
+        (WebKit::WebProcessPool::createDownloadProxy):
+        (WebKit::WebProcessPool::terminateServiceWorkers):
+        (WebKit::WebProcessPool::serviceWorkerProcesses):
+        (WebKit::WebProcessPool::updateProcessAssertions):
+        (WebKit::WebProcessPool::isServiceWorkerPageID const):
+        (WebKit::WebProcessPool::setUseSeparateServiceWorkerProcess):
+        (WebKit::WebProcessPool::hasServiceWorkerForegroundActivityForTesting const):
+        (WebKit::WebProcessPool::hasServiceWorkerBackgroundActivityForTesting const):
+        (WebKit::WebProcessPool::setLegacyCustomProtocolManagerClient): Deleted.
+        (WebKit::WebProcessPool::networkingProcessConnection): Deleted.
+        (WebKit::WebProcessPool::ensureNetworkProcess): Deleted.
+        There seems to be a lot of code removal here, but most of it was duplicate code with
+        WebsiteDataStore::parameters which is used instead.  That which was not duplicate was
+        moved to NetworkProcessProxy::sendCreationParametersToNewProcess.  This was the hardest part of this patch.
+        (WebKit::WebProcessPool::getNetworkProcessConnection): Deleted.
+        (WebKit::WebProcessPool::networkProcessIdentifier): Deleted.
+        (WebKit::WebProcessPool::synthesizeAppIsBackground): Deleted.
+        (WebKit::WebProcessPool::sendSyncToNetworkingProcess): Deleted.
+        (WebKit::WebProcessPool::clearCachedCredentials): Deleted.
+        (WebKit::WebProcessPool::terminateNetworkProcess): Deleted.
+        (WebKit::WebProcessPool::sendNetworkProcessPrepareToSuspendForTesting): Deleted.
+        (WebKit::WebProcessPool::sendNetworkProcessWillSuspendImminentlyForTesting): Deleted.
+        (WebKit::WebProcessPool::sendNetworkProcessDidResume): Deleted.
+        (WebKit::WebProcessPool::flushCookies): Deleted.
+        (WebKit::WebProcessPool::didCommitCrossSiteLoadWithDataTransfer): Deleted.
+        * UIProcess/WebProcessPool.h:
+        (WebKit::WebProcessPool::sendToNetworkingProcess): Deleted.
+        (WebKit::WebProcessPool::sendToNetworkingProcessRelaunchingIfNecessary): Deleted.
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::setWebsiteDataStore):
+        (WebKit::WebProcessProxy::getNetworkProcessConnection):
+        (WebKit::WebProcessProxy::didFinishLaunching):
+        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+        (WebKit::WebsiteDataStore::networkProcessHasEntitlementForTesting):
+        (WebKit::WebsiteDataStore::sendNetworkProcessXPCEndpointToWebProcess):
+        (WebKit::WebsiteDataStore::sendNetworkProcessXPCEndpointToAllWebProcesses):
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::forEachWebsiteDataStore):
+        (WebKit::WebsiteDataStore::WebsiteDataStore):
+        (WebKit::WebsiteDataStore::~WebsiteDataStore):
+        (WebKit::WebsiteDataStore::registerWithSessionIDMap):
+        (WebKit::WebsiteDataStore::existingDataStoreForSessionID):
+        (WebKit::WebsiteDataStore::networkProcess):
+        (WebKit::WebsiteDataStore::networkProcess const):
+        (WebKit::WebsiteDataStore::fetchDataAndApply):
+        (WebKit::WebsiteDataStore::removeData):
+        (WebKit::WebsiteDataStore::setServiceWorkerTimeoutForTesting):
+        (WebKit::WebsiteDataStore::resetServiceWorkerTimeoutForTesting):
+        (WebKit::WebsiteDataStore::setMaxStatisticsEntries):
+        (WebKit::WebsiteDataStore::setPruneEntriesDownTo):
+        (WebKit::WebsiteDataStore::setGrandfatheringTime):
+        (WebKit::WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval):
+        (WebKit::WebsiteDataStore::dumpResourceLoadStatistics):
+        (WebKit::WebsiteDataStore::isPrevalentResource):
+        (WebKit::WebsiteDataStore::isGrandfathered):
+        (WebKit::WebsiteDataStore::setPrevalentResource):
+        (WebKit::WebsiteDataStore::setPrevalentResourceForDebugMode):
+        (WebKit::WebsiteDataStore::isVeryPrevalentResource):
+        (WebKit::WebsiteDataStore::setVeryPrevalentResource):
+        (WebKit::WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
+        (WebKit::WebsiteDataStore::setSubframeUnderTopFrameDomain):
+        (WebKit::WebsiteDataStore::isRegisteredAsSubFrameUnder):
+        (WebKit::WebsiteDataStore::setSubresourceUnderTopFrameDomain):
+        (WebKit::WebsiteDataStore::isRegisteredAsSubresourceUnder):
+        (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectTo):
+        (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectFrom):
+        (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectTo):
+        (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectFrom):
+        (WebKit::WebsiteDataStore::isRegisteredAsRedirectingTo):
+        (WebKit::WebsiteDataStore::clearPrevalentResource):
+        (WebKit::WebsiteDataStore::resetParametersToDefaultValues):
+        (WebKit::WebsiteDataStore::submitTelemetry):
+        (WebKit::WebsiteDataStore::scheduleClearInMemoryAndPersistent):
+        (WebKit::WebsiteDataStore::getResourceLoadStatisticsDataSummary):
+        (WebKit::WebsiteDataStore::scheduleCookieBlockingUpdate):
+        (WebKit::WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing):
+        (WebKit::WebsiteDataStore::statisticsDatabaseHasAllTables):
+        (WebKit::WebsiteDataStore::setLastSeen):
+        (WebKit::WebsiteDataStore::domainIDExistsInDatabase):
+        (WebKit::WebsiteDataStore::mergeStatisticForTesting):
+        (WebKit::WebsiteDataStore::insertExpiredStatisticForTesting):
+        (WebKit::WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned):
+        (WebKit::WebsiteDataStore::setIsRunningResourceLoadStatisticsTest):
+        (WebKit::WebsiteDataStore::getAllStorageAccessEntries):
+        (WebKit::WebsiteDataStore::setTimeToLiveUserInteraction):
+        (WebKit::WebsiteDataStore::logUserInteraction):
+        (WebKit::WebsiteDataStore::hasHadUserInteraction):
+        (WebKit::WebsiteDataStore::isRelationshipOnlyInDatabaseOnce):
+        (WebKit::WebsiteDataStore::clearUserInteraction):
+        (WebKit::WebsiteDataStore::setGrandfathered):
+        (WebKit::WebsiteDataStore::setUseITPDatabase):
+        (WebKit::WebsiteDataStore::setCrossSiteLoadWithLinkDecorationForTesting):
+        (WebKit::WebsiteDataStore::resetCrossSiteLoadsWithLinkDecorationForTesting):
+        (WebKit::WebsiteDataStore::deleteCookiesForTesting):
+        (WebKit::WebsiteDataStore::hasLocalStorageForTesting const):
+        (WebKit::WebsiteDataStore::hasIsolatedSessionForTesting const):
+        (WebKit::WebsiteDataStore::setResourceLoadStatisticsShouldDowngradeReferrerForTesting):
+        (WebKit::WebsiteDataStore::setThirdPartyCookieBlockingMode):
+        (WebKit::WebsiteDataStore::setResourceLoadStatisticsShouldEnbleSameSiteStrictEnforcementForTesting):
+        (WebKit::WebsiteDataStore::setResourceLoadStatisticsFirstPartyWebsiteDataRemovalModeForTesting):
+        (WebKit::WebsiteDataStore::setResourceLoadStatisticsToSameSiteStrictCookiesForTesting):
+        (WebKit::WebsiteDataStore::setResourceLoadStatisticsFirstPartyHostCNAMEDomainForTesting):
+        (WebKit::WebsiteDataStore::setResourceLoadStatisticsThirdPartyCNAMEDomainForTesting):
+        (WebKit::WebsiteDataStore::syncLocalStorage):
+        (WebKit::WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources):
+        (WebKit::WebsiteDataStore::resetCacheMaxAgeCapForPrevalentResources):
+        (WebKit::WebsiteDataStore::processPools const):
+        (WebKit::WebsiteDataStore::allowSpecificHTTPSCertificateForHost):
+        (WebKit::WebsiteDataStore::getNetworkProcessConnection):
+        (WebKit::WebsiteDataStore::networkProcessCrashed):
+        (WebKit::WebsiteDataStore::terminateNetworkProcess):
+        (WebKit::WebsiteDataStore::sendNetworkProcessPrepareToSuspendForTesting):
+        (WebKit::WebsiteDataStore::sendNetworkProcessWillSuspendImminentlyForTesting):
+        (WebKit::WebsiteDataStore::sendNetworkProcessDidResume):
+        (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
+        (WebKit::WebsiteDataStore::setStatisticsTestingCallback):
+        (WebKit::WebsiteDataStore::setResourceLoadStatisticsDebugMode):
+        (WebKit::WebsiteDataStore::isResourceLoadStatisticsEphemeral const):
+        (WebKit::WebsiteDataStore::setAdClickAttributionDebugMode):
+        (WebKit::WebsiteDataStore::flushCookies):
+        (WebKit::WebsiteDataStore::setAllowsAnySSLCertificateForWebSocket):
+        (WebKit::WebsiteDataStore::clearCachedCredentials):
+        (WebKit::WebsiteDataStore::parameters):
+        (WebKit::WebsiteDataStore::getLocalStorageDetails):
+        (WebKit::WebsiteDataStore::resetQuota):
+        (WebKit::WebsiteDataStore::networkProcessHasEntitlementForTesting):
+        (WebKit::WebsiteDataStore::renameOriginInWebsiteData):
+        (WebKit::WebsiteDataStore::hasAppBoundSession const):
+        (WebKit::WebsiteDataStore::clearAppBoundSession):
+        (WebKit::WebsiteDataStore::forwardAppBoundDomainsToITPIfInitialized):
+        (WebKit::WebsiteDataStore::setAppBoundDomainsForITP):
+        (WebKit::WebsiteDataStore::updateBundleIdentifierInNetworkProcess):
+        (WebKit::WebsiteDataStore::clearBundleIdentifierInNetworkProcess):
+        (WebKit::WebsiteDataStore::makeNextNetworkProcessLaunchFailForTesting):
+        (WebKit::WebsiteDataStore::shouldMakeNextNetworkProcessLaunchFailForTesting):
+        (WebKit::WebsiteDataStore::maybeRegisterWithSessionIDMap): Deleted.
+        (WebKit::WebsiteDataStore::existingNonDefaultDataStoreForSessionID): Deleted.
+        (WebKit::WebsiteDataStore::processPoolForCookieStorageOperations): Deleted.
+        (WebKit::WebsiteDataStore::isAssociatedProcessPool const): Deleted.
+        (WebKit::WebsiteDataStore::pendingCookies const): Deleted.
+        (WebKit::WebsiteDataStore::addPendingCookie): Deleted.
+        (WebKit::WebsiteDataStore::removePendingCookie): Deleted.
+        (WebKit::WebsiteDataStore::clearPendingCookies): Deleted.
+        (WebKit::WebsiteDataStore::didCreateNetworkProcess): Deleted.
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        * UIProcess/WebsiteData/curl/WebsiteDataStoreCurl.cpp:
+        (WebKit::WebsiteDataStore::setNetworkProxySettings):
+        * UIProcess/WebsiteData/soup/WebsiteDataStoreSoup.cpp:
+        (WebKit::WebsiteDataStore::platformSetNetworkParameters):
+        (WebKit::WebsiteDataStore::setPersistentCredentialStorageEnabled):
+        * UIProcess/glib/WebProcessProxyGLib.cpp:
+        (WebKit::WebProcessProxy::platformGetLaunchOptions):
+        * UIProcess/soup/WebCookieManagerProxySoup.cpp:
+        (WebKit::WebCookieManagerProxy::setCookiePersistentStorage):
+        * UIProcess/soup/WebProcessPoolSoup.cpp:
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+        (WebKit::WebProcessPool::setIgnoreTLSErrors):
+        (WebKit::WebProcessPool::setNetworkProxySettings):
+        * WebProcess/Network/NetworkProcessConnectionInfo.h:
+
 2020-09-29  Tim Horton  <timothy_horton@apple.com>
 
         Enable the Web Share Level 2 feature wherever Web Share is enabled
index fce2389..5c9b771 100644 (file)
@@ -32,6 +32,7 @@
 #include "WebCoreArgumentCoders.h"
 #include <WebCore/Cookie.h>
 #include <WebCore/CookieStorage.h>
+#include <WebCore/HTTPCookieAcceptPolicy.h>
 #include <WebCore/NetworkStorageSession.h>
 #include <wtf/MainThread.h>
 #include <wtf/URL.h>
@@ -143,15 +144,18 @@ void WebCookieManager::stopObservingCookieChanges(PAL::SessionID sessionID)
 
 void WebCookieManager::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& completionHandler)
 {
-    platformSetHTTPCookieAcceptPolicy(policy);
-    m_process.cookieAcceptPolicyChanged(policy);
-
-    completionHandler();
+    platformSetHTTPCookieAcceptPolicy(policy, [policy, process = makeRef(m_process), completionHandler = WTFMove(completionHandler)] () mutable {
+        process->cookieAcceptPolicyChanged(policy);
+        completionHandler();
+    });
 }
 
-void WebCookieManager::getHTTPCookieAcceptPolicy(CompletionHandler<void(HTTPCookieAcceptPolicy)>&& completionHandler)
+void WebCookieManager::getHTTPCookieAcceptPolicy(PAL::SessionID sessionID, CompletionHandler<void(HTTPCookieAcceptPolicy)>&& completionHandler)
 {
-    completionHandler(m_process.defaultStorageSession().cookieAcceptPolicy());
+    if (auto* storageSession = m_process.storageSession(sessionID))
+        completionHandler(storageSession->cookieAcceptPolicy());
+    else
+        completionHandler(HTTPCookieAcceptPolicy::Never);
 }
 
 } // namespace WebKit
index ca7f55e..35ce8a9 100644 (file)
@@ -37,6 +37,8 @@
 #include "SoupCookiePersistentStorageType.h"
 #endif
 
+OBJC_CLASS NSHTTPCookieStorage;
+
 namespace WebCore {
 struct Cookie;
 enum class HTTPCookieAcceptPolicy : uint8_t;
@@ -79,8 +81,8 @@ private:
     void getAllCookies(PAL::SessionID, CompletionHandler<void(Vector<WebCore::Cookie>&&)>&&);
     void getCookies(PAL::SessionID, const URL&, CompletionHandler<void(Vector<WebCore::Cookie>&&)>&&);
 
-    void platformSetHTTPCookieAcceptPolicy(WebCore::HTTPCookieAcceptPolicy);
-    void getHTTPCookieAcceptPolicy(CompletionHandler<void(WebCore::HTTPCookieAcceptPolicy)>&&);
+    void platformSetHTTPCookieAcceptPolicy(WebCore::HTTPCookieAcceptPolicy, CompletionHandler<void()>&&);
+    void getHTTPCookieAcceptPolicy(PAL::SessionID, CompletionHandler<void(WebCore::HTTPCookieAcceptPolicy)>&&);
 
     void startObservingCookieChanges(PAL::SessionID);
     void stopObservingCookieChanges(PAL::SessionID);
@@ -88,4 +90,8 @@ private:
     NetworkProcess& m_process;
 };
 
+#if PLATFORM(COCOA)
+void saveCookies(NSHTTPCookieStorage *, CompletionHandler<void()>&&);
+#endif
+
 } // namespace WebKit
index acd7544..6fdf577 100644 (file)
@@ -36,7 +36,7 @@ messages -> WebCookieManager NotRefCounted {
     void DeleteAllCookiesModifiedSince(PAL::SessionID sessionID, WallTime time) -> () Async
 
     void SetHTTPCookieAcceptPolicy(enum:uint8_t WebCore::HTTPCookieAcceptPolicy policy) -> () Async
-    void GetHTTPCookieAcceptPolicy() -> (enum:uint8_t WebCore::HTTPCookieAcceptPolicy policy) Async
+    void GetHTTPCookieAcceptPolicy(PAL::SessionID sessionID) -> (enum:uint8_t WebCore::HTTPCookieAcceptPolicy policy) Async
     
     void StartObservingCookieChanges(PAL::SessionID sessionID)
     void StopObservingCookieChanges(PAL::SessionID sessionID)
index c2ef156..faada50 100644 (file)
@@ -34,7 +34,7 @@ namespace WebKit {
 
 using namespace WebCore;
 
-void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
+void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& completionHandler)
 {
     CookieAcceptPolicy curlPolicy = CookieAcceptPolicy::OnlyFromMainDocumentDomain;
     switch (policy) {
@@ -55,6 +55,7 @@ void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy
     m_process.forEachNetworkStorageSession([curlPolicy] (const auto& networkStorageSession) {
         networkStorageSession.setCookieAcceptPolicy(curlPolicy);
     });
+    completionHandler();
 }
 
 } // namespace WebKit
index 19f5878..7f9120c 100644 (file)
@@ -31,6 +31,7 @@
 #import <WebCore/HTTPCookieAcceptPolicy.h>
 #import <WebCore/NetworkStorageSession.h>
 #import <pal/spi/cf/CFNetworkSPI.h>
+#import <wtf/CallbackAggregator.h>
 #import <wtf/ProcessPrivilege.h>
 
 namespace WebKit {
@@ -53,15 +54,19 @@ static CFHTTPCookieStorageAcceptPolicy toCFHTTPCookieStorageAcceptPolicy(HTTPCoo
     return CFHTTPCookieStorageAcceptPolicyAlways;
 }
 
-void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
+void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
 
+    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:static_cast<NSHTTPCookieAcceptPolicy>(policy)];
+    saveCookies([NSHTTPCookieStorage sharedHTTPCookieStorage], [callbackAggregator] { });
 
     m_process.forEachNetworkStorageSession([&] (const auto& networkStorageSession) {
         if (auto cookieStorage = networkStorageSession.cookieStorage())
             CFHTTPCookieStorageSetCookieAcceptPolicy(cookieStorage.get(), toCFHTTPCookieStorageAcceptPolicy(policy));
+        if (auto *storage = networkStorageSession.nsCookieStorage())
+            saveCookies(storage, [callbackAggregator] { });
     });
 }
 
index 754d0bb..d576afd 100644 (file)
 namespace WebKit {
 using namespace WebCore;
 
-void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
+void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& completionHandler)
 {
     m_process.forEachNetworkStorageSession([policy] (auto& session) {
         session.setCookieAcceptPolicy(policy);
     });
+    completionHandler();
 }
 
 void WebCookieManager::setCookiePersistentStorage(PAL::SessionID sessionID, const String& storagePath, SoupCookiePersistentStorageType storageType)
index 4041c52..33f2952 100644 (file)
@@ -173,6 +173,7 @@ NetworkProcess::NetworkProcess(AuxiliaryProcessInitializationParameters&& parame
 #endif
 
 #if USE(SOUP)
+    // FIXME: Do not use the default session ID.
     DNSResolveQueueSoup::setGlobalDefaultSoupSessionAccessor([this]() -> SoupSession* {
         return static_cast<NetworkSessionSoup&>(*networkSession(PAL::SessionID::defaultSessionID())).soupSession();
     });
@@ -338,30 +339,6 @@ void NetworkProcess::initializeNetworkProcess(NetworkProcessCreationParameters&&
 
     setAdClickAttributionDebugMode(parameters.enableAdClickAttributionDebugMode);
 
-    SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsParameters.directoryExtensionHandle);
-
-    auto sessionID = parameters.defaultDataStoreParameters.networkSessionParameters.sessionID;
-    setSession(sessionID, NetworkSession::create(*this, WTFMove(parameters.defaultDataStoreParameters.networkSessionParameters)));
-
-    SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.cacheStorageDirectoryExtensionHandle);
-    addSessionStorageQuotaManager(sessionID, parameters.defaultDataStoreParameters.perOriginStorageQuota, parameters.defaultDataStoreParameters.perThirdPartyOriginStorageQuota, parameters.defaultDataStoreParameters.cacheStorageDirectory, parameters.defaultDataStoreParameters.cacheStorageDirectoryExtensionHandle);
-
-#if ENABLE(INDEXED_DATABASE)
-    addIndexedDatabaseSession(sessionID, parameters.defaultDataStoreParameters.indexedDatabaseDirectory, parameters.defaultDataStoreParameters.indexedDatabaseDirectoryExtensionHandle);
-#endif
-
-#if ENABLE(SERVICE_WORKER)
-    bool serviceWorkerProcessTerminationDelayEnabled = true;
-    addServiceWorkerSession(PAL::SessionID::defaultSessionID(), serviceWorkerProcessTerminationDelayEnabled, WTFMove(parameters.serviceWorkerRegistrationDirectory), parameters.serviceWorkerRegistrationDirectoryExtensionHandle);
-#endif
-
-    m_storageManagerSet->add(sessionID, parameters.defaultDataStoreParameters.localStorageDirectory, parameters.defaultDataStoreParameters.localStorageDirectoryExtensionHandle);
-
-    auto* defaultSession = networkSession(PAL::SessionID::defaultSessionID());
-    auto* defaultStorageSession = defaultSession->networkStorageSession();
-    for (const auto& cookie : parameters.defaultDataStoreParameters.pendingCookies)
-        defaultStorageSession->setCookie(cookie);
-
     for (auto& supplement : m_supplements.values())
         supplement->initialize(parameters);
 
@@ -496,8 +473,6 @@ void NetworkProcess::ensureSession(const PAL::SessionID& sessionID, bool shouldU
 void NetworkProcess::ensureSession(const PAL::SessionID& sessionID, bool shouldUseTestingNetworkSession, const String& identifierBase)
 #endif
 {
-    ASSERT(sessionID != PAL::SessionID::defaultSessionID());
-
     auto addResult = m_networkStorageSessions.add(sessionID, nullptr);
     if (!addResult.isNewEntry)
         return;
@@ -512,7 +487,7 @@ void NetworkProcess::ensureSession(const PAL::SessionID& sessionID, bool shouldU
     RetainPtr<CFStringRef> cfIdentifier = makeString(identifierBase, ".PrivateBrowsing.", createCanonicalUUIDString()).createCFString();
     if (sessionID.isEphemeral())
         storageSession = adoptCF(createPrivateStorageSession(cfIdentifier.get()));
-    else
+    else if (sessionID != PAL::SessionID::defaultSessionID())
         storageSession = WebCore::NetworkStorageSession::createCFStorageSessionForIdentifier(cfIdentifier.get());
 
     if (NetworkStorageSession::processMayUseCookieAPI()) {
@@ -535,21 +510,11 @@ void NetworkProcess::cookieAcceptPolicyChanged(HTTPCookieAcceptPolicy newPolicy)
 
 WebCore::NetworkStorageSession* NetworkProcess::storageSession(const PAL::SessionID& sessionID) const
 {
-    if (sessionID == PAL::SessionID::defaultSessionID())
-        return &defaultStorageSession();
     return m_networkStorageSessions.get(sessionID);
 }
 
-WebCore::NetworkStorageSession& NetworkProcess::defaultStorageSession() const
-{
-    if (!m_defaultNetworkStorageSession)
-        m_defaultNetworkStorageSession = platformCreateDefaultStorageSession();
-    return *m_defaultNetworkStorageSession;
-}
-
 void NetworkProcess::forEachNetworkStorageSession(const Function<void(WebCore::NetworkStorageSession&)>& functor)
 {
-    functor(defaultStorageSession());
     for (auto& storageSession : m_networkStorageSessions.values())
         functor(*storageSession);
 }
index 716a101..66aa1c3 100644 (file)
@@ -170,7 +170,6 @@ public:
 
     void forEachNetworkStorageSession(const Function<void(WebCore::NetworkStorageSession&)>&);
     WebCore::NetworkStorageSession* storageSession(const PAL::SessionID&) const;
-    WebCore::NetworkStorageSession& defaultStorageSession() const;
     std::unique_ptr<WebCore::NetworkStorageSession> newTestingSession(const PAL::SessionID&);
 #if PLATFORM(COCOA)
     void ensureSession(const PAL::SessionID&, bool shouldUseTestingNetworkSession, const String& identifier, RetainPtr<CFHTTPCookieStorageRef>&&);
@@ -373,7 +372,6 @@ public:
 
 private:
     void platformInitializeNetworkProcess(const NetworkProcessCreationParameters&);
-    std::unique_ptr<WebCore::NetworkStorageSession> platformCreateDefaultStorageSession() const;
 
     void didReceiveNetworkProcessMessage(IPC::Connection&, IPC::Decoder&);
 
@@ -542,7 +540,6 @@ private:
 
     HashMap<PAL::SessionID, std::unique_ptr<NetworkSession>> m_networkSessions;
     HashMap<PAL::SessionID, std::unique_ptr<WebCore::NetworkStorageSession>> m_networkStorageSessions;
-    mutable std::unique_ptr<WebCore::NetworkStorageSession> m_defaultNetworkStorageSession;
 
     RefPtr<StorageManagerSet> m_storageManagerSet;
 
index 7163ec2..49fa880 100644 (file)
@@ -55,7 +55,6 @@ void NetworkProcessCreationParameters::encode(IPC::Encoder& encoder) const
     encoder << uiProcessSDKVersion;
     IPC::encode(encoder, networkATSContext.get());
 #endif
-    encoder << defaultDataStoreParameters;
 #if USE(SOUP)
     encoder << cookieAcceptPolicy;
     encoder << languages;
@@ -66,9 +65,6 @@ void NetworkProcessCreationParameters::encode(IPC::Encoder& encoder) const
     encoder << urlSchemesRegisteredAsLocal;
     encoder << urlSchemesRegisteredAsNoAccess;
 
-#if ENABLE(SERVICE_WORKER)
-    encoder << serviceWorkerRegistrationDirectory << serviceWorkerRegistrationDirectoryExtensionHandle << shouldDisableServiceWorkerProcessTerminationDelay;
-#endif
     encoder << enableAdClickAttributionDebugMode;
 }
 
@@ -113,12 +109,6 @@ bool NetworkProcessCreationParameters::decode(IPC::Decoder& decoder, NetworkProc
         return false;
 #endif
 
-    Optional<WebsiteDataStoreParameters> defaultDataStoreParameters;
-    decoder >> defaultDataStoreParameters;
-    if (!defaultDataStoreParameters)
-        return false;
-    result.defaultDataStoreParameters = WTFMove(*defaultDataStoreParameters);
-
 #if USE(SOUP)
     if (!decoder.decode(result.cookieAcceptPolicy))
         return false;
@@ -135,20 +125,6 @@ bool NetworkProcessCreationParameters::decode(IPC::Decoder& decoder, NetworkProc
     if (!decoder.decode(result.urlSchemesRegisteredAsNoAccess))
         return false;
 
-#if ENABLE(SERVICE_WORKER)
-    if (!decoder.decode(result.serviceWorkerRegistrationDirectory))
-        return false;
-    
-    Optional<SandboxExtension::Handle> serviceWorkerRegistrationDirectoryExtensionHandle;
-    decoder >> serviceWorkerRegistrationDirectoryExtensionHandle;
-    if (!serviceWorkerRegistrationDirectoryExtensionHandle)
-        return false;
-    result.serviceWorkerRegistrationDirectoryExtensionHandle = WTFMove(*serviceWorkerRegistrationDirectoryExtensionHandle);
-
-    if (!decoder.decode(result.shouldDisableServiceWorkerProcessTerminationDelay))
-        return false;
-#endif
-
     if (!decoder.decode(result.enableAdClickAttributionDebugMode))
         return false;
 
index 8f0a003..7829a2d 100644 (file)
@@ -27,7 +27,6 @@
 
 #include "CacheModel.h"
 #include "SandboxExtension.h"
-#include "WebsiteDataStoreParameters.h"
 #include <WebCore/Cookie.h>
 #include <wtf/ProcessID.h>
 #include <wtf/Vector.h>
@@ -70,8 +69,6 @@ struct NetworkProcessCreationParameters {
     RetainPtr<CFDataRef> networkATSContext;
 #endif
 
-    WebsiteDataStoreParameters defaultDataStoreParameters;
-    
 #if USE(SOUP)
     WebCore::HTTPCookieAcceptPolicy cookieAcceptPolicy { WebCore::HTTPCookieAcceptPolicy::AlwaysAccept };
     Vector<String> languages;
@@ -82,11 +79,6 @@ struct NetworkProcessCreationParameters {
     Vector<String> urlSchemesRegisteredAsLocal;
     Vector<String> urlSchemesRegisteredAsNoAccess;
 
-#if ENABLE(SERVICE_WORKER)
-    String serviceWorkerRegistrationDirectory;
-    SandboxExtension::Handle serviceWorkerRegistrationDirectoryExtensionHandle;
-    bool shouldDisableServiceWorkerProcessTerminationDelay { false };
-#endif
     bool enableAdClickAttributionDebugMode { false };
 };
 
index f995e01..02c8673 100644 (file)
@@ -214,7 +214,8 @@ void LocalStorageDatabase::clear()
 
 void LocalStorageDatabase::close()
 {
-    ASSERT(!m_isClosed);
+    if (m_isClosed)
+        return;
     m_isClosed = true;
 
     if (m_didScheduleDatabaseUpdate) {
index da63591..82d4420 100644 (file)
@@ -33,6 +33,7 @@
 #import "NetworkResourceLoader.h"
 #import "NetworkSessionCocoa.h"
 #import "SandboxExtension.h"
+#import "WebCookieManager.h"
 #import <WebCore/NetworkStorageSession.h>
 #import <WebCore/PublicSuffix.h>
 #import <WebCore/ResourceRequestCFNet.h>
@@ -78,9 +79,6 @@ void NetworkProcess::platformInitializeNetworkProcessCocoa(const NetworkProcessC
     SandboxExtension::consumePermanently(parameters.cookieStorageDirectoryExtensionHandle);
     SandboxExtension::consumePermanently(parameters.containerCachesDirectoryExtensionHandle);
     SandboxExtension::consumePermanently(parameters.parentBundleDirectoryExtensionHandle);
-#if ENABLE(INDEXED_DATABASE)
-    SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.indexedDatabaseTempBlobDirectoryExtensionHandle);
-#endif
 #endif
 
     _CFNetworkSetATSContext(parameters.networkATSContext.get());
@@ -105,11 +103,6 @@ void NetworkProcess::platformInitializeNetworkProcessCocoa(const NetworkProcessC
     [NSURLCache setSharedURLCache:urlCache.get()];
 }
 
-std::unique_ptr<WebCore::NetworkStorageSession> NetworkProcess::platformCreateDefaultStorageSession() const
-{
-    return makeUnique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID());
-}
-
 RetainPtr<CFDataRef> NetworkProcess::sourceApplicationAuditData() const
 {
 #if USE(SOURCE_APPLICATION_AUDIT_DATA)
@@ -221,7 +214,7 @@ void NetworkProcess::flushCookies(const PAL::SessionID& sessionID, CompletionHan
     platformFlushCookies(sessionID, WTFMove(completionHandler));
 }
 
-static void saveCookies(NSHTTPCookieStorage *cookieStorage, CompletionHandler<void()>&& completionHandler)
+void saveCookies(NSHTTPCookieStorage *cookieStorage, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
     ASSERT(cookieStorage);
index d99f9dd..4953811 100644 (file)
@@ -39,11 +39,6 @@ void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreati
 {
 }
 
-std::unique_ptr<WebCore::NetworkStorageSession> NetworkProcess::platformCreateDefaultStorageSession() const
-{
-    return makeUnique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID());
-}
-
 void NetworkProcess::allowSpecificHTTPSCertificateForHost(const CertificateInfo& certificateInfo, const String& host)
 {
     notImplemented();
index c2736e0..1e18489 100644 (file)
@@ -55,15 +55,11 @@ void RemoteNetworkingContext::ensureWebsiteDataStoreSession(NetworkProcess& netw
         SandboxExtension::consumePermanently(parameters.cookieStoragePathExtensionHandle);
 
     RetainPtr<CFHTTPCookieStorageRef> uiProcessCookieStorage;
-    if (!sessionID.isEphemeral() && !parameters.uiProcessCookieStorageIdentifier.isEmpty())
+    if (!sessionID.isEphemeral() && !parameters.uiProcessCookieStorageIdentifier.isEmpty() && parameters.networkSessionParameters.sessionID != PAL::SessionID::defaultSessionID())
         uiProcessCookieStorage = cookieStorageFromIdentifyingData(parameters.uiProcessCookieStorageIdentifier);
 
     networkProcess.ensureSession(sessionID, parameters.networkSessionParameters.shouldUseTestingNetworkSession, makeString(base, '.', sessionID.toUInt64()), WTFMove(uiProcessCookieStorage));
 
-    auto* session = networkProcess.storageSession(sessionID);
-    for (const auto& cookie : parameters.pendingCookies)
-        session->setCookie(cookie);
-
     networkProcess.setSession(sessionID, NetworkSession::create(networkProcess, WTFMove(parameters.networkSessionParameters)));
 }
 
index 0d31b3d..a4c031d 100644 (file)
@@ -39,6 +39,7 @@ class NetworkProcessMainSoup final: public AuxiliaryProcessMainBase {
 public:
     void platformFinalize() override
     {
+        // FIXME: Is this still needed? We should probably destroy all existing sessions at this point instead.
         // Needed to destroy the SoupSession and SoupCookieJar, e.g. to avoid
         // leaking SQLite temporary journaling files.
         globalNetworkProcess->destroySession(PAL::SessionID::defaultSessionID());
index a212845..00ff8b2 100644 (file)
@@ -135,11 +135,6 @@ void NetworkProcess::platformInitializeNetworkProcess(const NetworkProcessCreati
         userPreferredLanguagesChanged(parameters.languages);
 }
 
-std::unique_ptr<WebCore::NetworkStorageSession> NetworkProcess::platformCreateDefaultStorageSession() const
-{
-    return makeUnique<WebCore::NetworkStorageSession>(PAL::SessionID::defaultSessionID());
-}
-
 void NetworkProcess::setIgnoreTLSErrors(PAL::SessionID sessionID, bool ignoreTLSErrors)
 {
     if (auto* session = networkSession(sessionID))
index 1743c3b..d6ff3c1 100644 (file)
@@ -95,8 +95,8 @@ private:
     int m_fileDescriptor { -1 };
     size_t m_size;
 #elif OS(DARWIN)
-    mach_port_name_t m_port;
-    mach_msg_type_name_t m_disposition;
+    mach_port_name_t m_port { 0 };
+    mach_msg_type_name_t m_disposition { 0 };
 #elif OS(WINDOWS)
     HANDLE m_handle { INVALID_HANDLE_VALUE };
 #endif
index 6d0c129..04810b3 100644 (file)
@@ -40,13 +40,9 @@ void WebsiteDataStoreParameters::encode(IPC::Encoder& encoder) const
     encoder << networkSessionParameters;
     encoder << uiProcessCookieStorageIdentifier;
     encoder << cookieStoragePathExtensionHandle;
-    encoder << pendingCookies;
 
 #if ENABLE(INDEXED_DATABASE)
     encoder << indexedDatabaseDirectory << indexedDatabaseDirectoryExtensionHandle;
-#if PLATFORM(IOS_FAMILY)
-    encoder << indexedDatabaseTempBlobDirectoryExtensionHandle;
-#endif
 #endif
 
 #if ENABLE(SERVICE_WORKER)
@@ -83,12 +79,6 @@ Optional<WebsiteDataStoreParameters> WebsiteDataStoreParameters::decode(IPC::Dec
         return WTF::nullopt;
     parameters.cookieStoragePathExtensionHandle = WTFMove(*cookieStoragePathExtensionHandle);
 
-    Optional<Vector<WebCore::Cookie>> pendingCookies;
-    decoder >> pendingCookies;
-    if (!pendingCookies)
-        return WTF::nullopt;
-    parameters.pendingCookies = WTFMove(*pendingCookies);
-
 #if ENABLE(INDEXED_DATABASE)
     Optional<String> indexedDatabaseDirectory;
     decoder >> indexedDatabaseDirectory;
@@ -101,14 +91,6 @@ Optional<WebsiteDataStoreParameters> WebsiteDataStoreParameters::decode(IPC::Dec
     if (!indexedDatabaseDirectoryExtensionHandle)
         return WTF::nullopt;
     parameters.indexedDatabaseDirectoryExtensionHandle = WTFMove(*indexedDatabaseDirectoryExtensionHandle);
-
-#if PLATFORM(IOS_FAMILY)
-    Optional<SandboxExtension::Handle> indexedDatabaseTempBlobDirectoryExtensionHandle;
-    decoder >> indexedDatabaseTempBlobDirectoryExtensionHandle;
-    if (!indexedDatabaseTempBlobDirectoryExtensionHandle)
-        return WTF::nullopt;
-    parameters.indexedDatabaseTempBlobDirectoryExtensionHandle = WTFMove(*indexedDatabaseTempBlobDirectoryExtensionHandle);
-#endif
 #endif
 
 #if ENABLE(SERVICE_WORKER)
index f27df48..e1b2337 100644 (file)
@@ -51,15 +51,11 @@ struct WebsiteDataStoreParameters {
 
     Vector<uint8_t> uiProcessCookieStorageIdentifier;
     SandboxExtension::Handle cookieStoragePathExtensionHandle;
-    Vector<WebCore::Cookie> pendingCookies;
     NetworkSessionCreationParameters networkSessionParameters;
 
 #if ENABLE(INDEXED_DATABASE)
     String indexedDatabaseDirectory;
     SandboxExtension::Handle indexedDatabaseDirectoryExtensionHandle;
-#if PLATFORM(IOS_FAMILY)
-    SandboxExtension::Handle indexedDatabaseTempBlobDirectoryExtensionHandle;
-#endif
 #endif
 
 #if ENABLE(SERVICE_WORKER)
index bc07866..ff95589 100644 (file)
@@ -46,8 +46,6 @@ namespace API {
 HTTPCookieStore::HTTPCookieStore(WebKit::WebsiteDataStore& websiteDataStore)
     : m_owningDataStore(websiteDataStore)
 {
-    if (!m_owningDataStore->processPoolForCookieStorageOperations())
-        registerForNewProcessPoolNotifications();
 }
 
 HTTPCookieStore::~HTTPCookieStore()
@@ -55,8 +53,6 @@ HTTPCookieStore::~HTTPCookieStore()
     ASSERT(m_observers.isEmpty());
     ASSERT(!m_observedCookieManagerProxy);
     ASSERT(!m_cookieManagerProxyObserver);
-
-    unregisterForNewProcessPoolNotifications();
 }
 
 void HTTPCookieStore::filterAppBoundCookies(const Vector<WebCore::Cookie>& cookies, CompletionHandler<void(Vector<WebCore::Cookie>&&)>&& completionHandler)
@@ -81,33 +77,16 @@ void HTTPCookieStore::filterAppBoundCookies(const Vector<WebCore::Cookie>& cooki
 
 void HTTPCookieStore::cookies(CompletionHandler<void(const Vector<WebCore::Cookie>&)>&& completionHandler)
 {
-    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
-    if (!pool) {
-        Vector<WebCore::Cookie> allCookies;
-        if (m_owningDataStore->sessionID() == PAL::SessionID::defaultSessionID())
-            allCookies = getAllDefaultUIProcessCookieStoreCookies();
-        allCookies.appendVector(m_owningDataStore->pendingCookies());
-
-        RunLoop::main().dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler), allCookies] () mutable {
-            filterAppBoundCookies(allCookies, WTFMove(completionHandler));
-        });
-        return;
-    }
-
-    auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
-    cookieManager->getAllCookies(m_owningDataStore->sessionID(), [this, protectedThis = makeRef(*this), pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)] (const Vector<WebCore::Cookie>& cookies) mutable {
+    auto& cookieManager = m_owningDataStore->networkProcess().cookieManager();
+    cookieManager.getAllCookies(m_owningDataStore->sessionID(), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)] (const Vector<WebCore::Cookie>& cookies) mutable {
         filterAppBoundCookies(cookies, WTFMove(completionHandler));
     });
 }
 
 void HTTPCookieStore::cookiesForURL(WTF::URL&& url, CompletionHandler<void(Vector<WebCore::Cookie>&&)>&& completionHandler)
 {
-    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
-    if (!pool)
-        return completionHandler({ });
-
-    auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
-    cookieManager->getCookies(m_owningDataStore->sessionID(), url, [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)] (Vector<WebCore::Cookie>&& cookies) mutable {
+    auto& cookieManager = m_owningDataStore->networkProcess().cookieManager();
+    cookieManager.getCookies(m_owningDataStore->sessionID(), url, [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)] (Vector<WebCore::Cookie>&& cookies) mutable {
         filterAppBoundCookies(cookies, WTFMove(completionHandler));
     });
 }
@@ -115,78 +94,29 @@ void HTTPCookieStore::cookiesForURL(WTF::URL&& url, CompletionHandler<void(Vecto
 void HTTPCookieStore::setCookies(const Vector<WebCore::Cookie>& cookies, CompletionHandler<void()>&& completionHandler)
 {
     filterAppBoundCookies(cookies, [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)] (auto&& appBoundCookies) mutable {
-        auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
-        if (!pool) {
-            for (auto& cookie : appBoundCookies) {
-                // FIXME: pendingCookies used for defaultSession because session cookies cannot be propagated to Network Process with uiProcessCookieStorageIdentifier.
-                if (m_owningDataStore->sessionID() == PAL::SessionID::defaultSessionID() && !cookie.session)
-                    setCookieInDefaultUIProcessCookieStore(cookie);
-                else
-                    m_owningDataStore->addPendingCookie(cookie);
-            }
-
-            RunLoop::main().dispatch(WTFMove(completionHandler));
-            return;
-        }
-
-        auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
-        cookieManager->setCookies(m_owningDataStore->sessionID(), appBoundCookies, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)] () mutable {
-            completionHandler();
-        });
+        auto& cookieManager = m_owningDataStore->networkProcess().cookieManager();
+        cookieManager.setCookies(m_owningDataStore->sessionID(), appBoundCookies, WTFMove(completionHandler));
     });
 }
 
 void HTTPCookieStore::deleteCookie(const WebCore::Cookie& cookie, CompletionHandler<void()>&& completionHandler)
 {
-    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
-    if (!pool) {
-        if (m_owningDataStore->sessionID() == PAL::SessionID::defaultSessionID() && !cookie.session)
-            deleteCookieFromDefaultUIProcessCookieStore(cookie);
-        else
-            m_owningDataStore->removePendingCookie(cookie);
-
-        RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] () mutable {
-            completionHandler();
-        });
-        return;
-    }
-
-    auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
-    cookieManager->deleteCookie(m_owningDataStore->sessionID(), cookie, [pool = WTFMove(pool), completionHandler = WTFMove(completionHandler)]() mutable {
-        completionHandler();
-    });
+    auto& cookieManager = m_owningDataStore->networkProcess().cookieManager();
+    cookieManager.deleteCookie(m_owningDataStore->sessionID(), cookie, WTFMove(completionHandler));
 }
 
 void HTTPCookieStore::deleteAllCookies(CompletionHandler<void()>&& completionHandler)
 {
-    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
-    if (!pool) {
-        if (!m_owningDataStore->sessionID().isEphemeral())
-            deleteCookiesInDefaultUIProcessCookieStore();
-        RunLoop::main().dispatch(WTFMove(completionHandler));
-        return;
-    }
-
-    auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
-    cookieManager->deleteAllCookies(m_owningDataStore->sessionID());
+    auto& cookieManager = m_owningDataStore->networkProcess().cookieManager();
+    cookieManager.deleteAllCookies(m_owningDataStore->sessionID());
     // FIXME: The CompletionHandler should be passed to WebCookieManagerProxy::deleteAllCookies.
     RunLoop::main().dispatch(WTFMove(completionHandler));
 }
 
 void HTTPCookieStore::setHTTPCookieAcceptPolicy(WebCore::HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& completionHandler)
 {
-    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
-    if (!pool) {
-        if (!m_owningDataStore->sessionID().isEphemeral())
-            setHTTPCookieAcceptPolicyInDefaultUIProcessCookieStore(policy);
-        RunLoop::main().dispatch(WTFMove(completionHandler));
-        return;
-    }
-
-    auto* cookieManager = pool->supplement<WebKit::WebCookieManagerProxy>();
-    cookieManager->setHTTPCookieAcceptPolicy(m_owningDataStore->sessionID(), policy, [completionHandler = WTFMove(completionHandler)] () mutable {
-        completionHandler();
-    });
+    auto& cookieManager = m_owningDataStore->networkProcess().cookieManager();
+    cookieManager.setHTTPCookieAcceptPolicy(m_owningDataStore->sessionID(), policy, WTFMove(completionHandler));
 }
 
 void HTTPCookieStore::flushCookies(CompletionHandler<void()>&& completionHandler)
@@ -227,21 +157,7 @@ void HTTPCookieStore::registerObserver(Observer& observer)
 
     m_cookieManagerProxyObserver = makeUnique<APIWebCookieManagerProxyObserver>(*this);
 
-    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
-
-    if (!pool) {
-        ASSERT(!m_observingUIProcessCookies);
-
-        // Listen for cookie notifications in the UIProcess in the meantime.
-        startObservingChangesToDefaultUIProcessCookieStore([this] () {
-            cookiesDidChange();
-        });
-
-        m_observingUIProcessCookies = true;
-        return;
-    }
-
-    m_observedCookieManagerProxy = pool->supplement<WebKit::WebCookieManagerProxy>();
+    m_observedCookieManagerProxy = &m_owningDataStore->networkProcess().cookieManager();
     m_observedCookieManagerProxy->registerObserver(m_owningDataStore->sessionID(), *m_cookieManagerProxyObserver);
 }
 
@@ -276,46 +192,10 @@ void HTTPCookieStore::cookiesDidChange()
 void HTTPCookieStore::cookieManagerDestroyed()
 {
     m_observedCookieManagerProxy->unregisterObserver(m_owningDataStore->sessionID(), *m_cookieManagerProxyObserver);
-    m_observedCookieManagerProxy = nullptr;
-
-    auto* pool = m_owningDataStore->processPoolForCookieStorageOperations();
-
-    if (!pool)
-        return;
-
-    m_observedCookieManagerProxy = pool->supplement<WebKit::WebCookieManagerProxy>();
+    m_observedCookieManagerProxy = &m_owningDataStore->networkProcess().cookieManager();
     m_observedCookieManagerProxy->registerObserver(m_owningDataStore->sessionID(), *m_cookieManagerProxyObserver);
 }
 
-void HTTPCookieStore::registerForNewProcessPoolNotifications()
-{
-    ASSERT(!m_processPoolCreationListenerIdentifier);
-
-    m_processPoolCreationListenerIdentifier = WebProcessPool::registerProcessPoolCreationListener([this](WebProcessPool& newProcessPool) {
-        if (!m_owningDataStore->isAssociatedProcessPool(newProcessPool))
-            return;
-
-        // Now that an associated process pool exists, we need to flush the UI process cookie store
-        // to make sure any changes are reflected within the new process pool.
-        flushDefaultUIProcessCookieStore();
-        newProcessPool.ensureNetworkProcess();
-
-        if (m_cookieManagerProxyObserver) {
-            m_observedCookieManagerProxy = newProcessPool.supplement<WebKit::WebCookieManagerProxy>();
-            m_observedCookieManagerProxy->registerObserver(m_owningDataStore->sessionID(), *m_cookieManagerProxyObserver);
-        }
-        unregisterForNewProcessPoolNotifications();
-    });
-}
-
-void HTTPCookieStore::unregisterForNewProcessPoolNotifications()
-{
-    if (m_processPoolCreationListenerIdentifier)
-        WebProcessPool::unregisterProcessPoolCreationListener(m_processPoolCreationListenerIdentifier);
-
-    m_processPoolCreationListenerIdentifier = 0;
-}
-
 #if !PLATFORM(COCOA)
 void HTTPCookieStore::flushDefaultUIProcessCookieStore() { }
 Vector<WebCore::Cookie> HTTPCookieStore::getAllDefaultUIProcessCookieStoreCookies() { return { }; }
index d620add..a05f414 100644 (file)
@@ -83,9 +83,6 @@ public:
 private:
     HTTPCookieStore(WebKit::WebsiteDataStore&);
 
-    void registerForNewProcessPoolNotifications();
-    void unregisterForNewProcessPoolNotifications();
-
     void flushDefaultUIProcessCookieStore();
     static Vector<WebCore::Cookie> getAllDefaultUIProcessCookieStoreCookies();
     static void setCookieInDefaultUIProcessCookieStore(const WebCore::Cookie&);
index 58c5453..37baa68 100644 (file)
@@ -411,11 +411,6 @@ void WKContextPreconnectToServer(WKContextRef, WKURLRef)
 {
 }
 
-WKCookieManagerRef WKContextGetCookieManager(WKContextRef contextRef)
-{
-    return WebKit::toAPI(WebKit::toImpl(contextRef)->supplement<WebKit::WebCookieManagerProxy>());
-}
-
 WKWebsiteDataStoreRef WKContextGetWebsiteDataStore(WKContextRef)
 {
     return WKWebsiteDataStoreGetDefaultDataStore();
@@ -527,13 +522,6 @@ void WKContextSetJavaScriptGarbageCollectorTimerEnabled(WKContextRef contextRef,
     WebKit::toImpl(contextRef)->setJavaScriptGarbageCollectorTimerEnabled(enable);
 }
 
-void WKContextSetAllowsAnySSLCertificateForServiceWorkerTesting(WKContextRef context, bool allows)
-{
-#if ENABLE(SERVICE_WORKER)
-    WebKit::toImpl(context)->setAllowsAnySSLCertificateForServiceWorker(allows);
-#endif
-}
-
 WKDictionaryRef WKContextCopyPlugInAutoStartOriginHashes(WKContextRef contextRef)
 {
     return WebKit::toAPI(&WebKit::toImpl(contextRef)->plugInAutoStartOriginHashes().leakRef());
@@ -575,21 +563,11 @@ void WKContextSetFontAllowList(WKContextRef contextRef, WKArrayRef arrayRef)
     WebKit::toImpl(contextRef)->setFontAllowList(WebKit::toImpl(arrayRef));
 }
 
-void WKContextTerminateNetworkProcess(WKContextRef context)
-{
-    WebKit::toImpl(context)->terminateNetworkProcess();
-}
-
 void WKContextTerminateServiceWorkers(WKContextRef context)
 {
     WebKit::toImpl(context)->terminateServiceWorkers();
 }
 
-ProcessID WKContextGetNetworkProcessIdentifier(WKContextRef contextRef)
-{
-    return WebKit::toImpl(contextRef)->networkProcessIdentifier();
-}
-
 void WKContextAddSupportedPlugin(WKContextRef contextRef, WKStringRef domainRef, WKStringRef nameRef, WKArrayRef mimeTypesRef, WKArrayRef extensionsRef)
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
@@ -619,12 +597,11 @@ void WKContextClearCurrentModifierStateForTesting(WKContextRef contextRef)
     WebKit::toImpl(contextRef)->clearCurrentModifierStateForTesting();
 }
 
-void WKContextSetUseSeparateServiceWorkerProcess(WKContextRef contextRef, bool useSeparateServiceWorkerProcess)
+void WKContextSetUseSeparateServiceWorkerProcess(WKContextRef, bool useSeparateServiceWorkerProcess)
 {
-    WebKit::toImpl(contextRef)->setUseSeparateServiceWorkerProcess(useSeparateServiceWorkerProcess);
+    WebKit::WebProcessPool::setUseSeparateServiceWorkerProcess(useSeparateServiceWorkerProcess);
 }
 
-void WKContextSetPrimaryWebsiteDataStore(WKContextRef contextRef, WKWebsiteDataStoreRef websiteDataStore)
+void WKContextSetPrimaryWebsiteDataStore(WKContextRef, WKWebsiteDataStoreRef)
 {
-    WebKit::toImpl(contextRef)->setPrimaryDataStore(*WebKit::toImpl(websiteDataStore));
 }
index 1d8fab8..2ab6ef8 100644 (file)
@@ -168,7 +168,6 @@ WK_EXPORT void WKContextStopMemorySampler(WKContextRef context);
 WK_EXPORT WKWebsiteDataStoreRef WKContextGetWebsiteDataStore(WKContextRef context) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKWebsiteDataStoreGetDefaultDataStore);
 
 WK_EXPORT WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKWebsiteDataStoreGetDefaultDataStore);
-WK_EXPORT WKCookieManagerRef WKContextGetCookieManager(WKContextRef context) WK_C_API_DEPRECATED;
 WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef context);
 WK_EXPORT WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef context);
 WK_EXPORT WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef context) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKWebsiteDataStoreGetDefaultDataStore);
index a025011..48a29c4 100644 (file)
@@ -83,11 +83,8 @@ WK_EXPORT void WKContextWarmInitialProcess(WKContextRef context);
 // At some point it should be removed.
 WK_EXPORT void WKContextSetUsesNetworkProcess(WKContextRef, bool);
 
-WK_EXPORT void WKContextTerminateNetworkProcess(WKContextRef);
 WK_EXPORT void WKContextTerminateServiceWorkers(WKContextRef);
 
-WK_EXPORT void WKContextSetAllowsAnySSLCertificateForServiceWorkerTesting(WKContextRef, bool);
-
 typedef void (*WKContextInvalidMessageFunction)(WKStringRef messageName);
 WK_EXPORT void WKContextSetInvalidMessageFunction(WKContextInvalidMessageFunction invalidMessageFunction);
     
@@ -97,8 +94,6 @@ WK_EXPORT void WKContextSetFontAllowList(WKContextRef, WKArrayRef);
 
 WK_EXPORT void WKContextPreconnectToServer(WKContextRef context, WKURLRef serverURL) WK_C_API_DEPRECATED;
 
-WK_EXPORT WKProcessID WKContextGetNetworkProcessIdentifier(WKContextRef context);
-
 WK_EXPORT void WKContextAddSupportedPlugin(WKContextRef context, WKStringRef domain, WKStringRef name, WKArrayRef mimeTypes, WKArrayRef extensions);
 WK_EXPORT void WKContextClearSupportedPlugins(WKContextRef context);
 
index 648f300..b447342 100644 (file)
@@ -398,6 +398,11 @@ uint64_t WKPageGetRenderTreeSize(WKPageRef page)
     return toImpl(page)->renderTreeSize();
 }
 
+WKWebsiteDataStoreRef WKPageGetWebsiteDataStore(WKPageRef page)
+{
+    return toAPI(&toImpl(page)->websiteDataStore());
+}
+
 WKInspectorRef WKPageGetInspector(WKPageRef pageRef)
 {
     return toAPI(toImpl(pageRef)->inspector());
index 670b5e9..c51b816 100644 (file)
@@ -118,6 +118,8 @@ WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page);
 
 WK_EXPORT uint64_t WKPageGetRenderTreeSize(WKPageRef page);
 
+WK_EXPORT WKWebsiteDataStoreRef WKPageGetWebsiteDataStore(WKPageRef page);
+
 WK_EXPORT WKInspectorRef WKPageGetInspector(WKPageRef page);
 
 WK_EXPORT WKStringRef WKPageCopyUserAgent(WKPageRef page);
index ff862bb..0fa28d8 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "APIArray.h"
 #include "APIHTTPCookieStore.h"
+#include "NetworkProcessProxy.h"
 #include "ShouldGrandfatherStatistics.h"
 #include "WKAPICast.h"
 #include "WKDictionary.h"
@@ -69,6 +70,16 @@ WKWebsiteDataStoreRef WKWebsiteDataStoreCreateWithConfiguration(WKWebsiteDataSto
     return WebKit::toAPI(&WebKit::WebsiteDataStore::create(*WebKit::toImpl(configuration), sessionID).leakRef());
 }
 
+void WKWebsiteDataStoreTerminateNetworkProcess(WKWebsiteDataStoreRef dataStore)
+{
+    WebKit::toImpl(dataStore)->terminateNetworkProcess();
+}
+
+WKProcessID WKWebsiteDataStoreGetNetworkProcessIdentifier(WKWebsiteDataStoreRef dataStore)
+{
+    return WebKit::toImpl(dataStore)->networkProcess().processIdentifier();
+}
+
 void WKWebsiteDataStoreRemoveITPDataForDomain(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreRemoveITPDataForDomainFunction callback)
 {
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
index b964b71..6e68f73 100644 (file)
 #include <WebKit/WKBase.h>
 #include <WebKit/WKDeprecated.h>
 
+#if defined(WIN32) || defined(_WIN32)
+typedef int WKProcessID;
+#else
+#include <unistd.h>
+typedef pid_t WKProcessID;
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -50,6 +57,11 @@ WK_EXPORT void WKWebsiteDataStoreSetAllowsAnySSLCertificateForWebSocketTesting(W
 
 WK_EXPORT void WKWebsiteDataStoreClearCachedCredentials(WKWebsiteDataStoreRef dataStoreRef);
 
+WK_EXPORT void WKWebsiteDataStoreClearCachedCredentials(WKWebsiteDataStoreRef dataStore);
+WK_EXPORT void WKWebsiteDataStoreTerminateNetworkProcess(WKWebsiteDataStoreRef dataStore);
+
+WK_EXPORT WKProcessID WKWebsiteDataStoreGetNetworkProcessIdentifier(WKWebsiteDataStoreRef dataStore);
+
 WK_EXPORT bool WKWebsiteDataStoreGetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef);
 WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef, bool enable);
 typedef void (*WKWebsiteDataStoreStatisticsEphemeralFunction)(bool isEphemeral, void* functionContext);
index ff30949..1f56fbf 100644 (file)
@@ -406,28 +406,6 @@ static NSDictionary *policiesHashMapToDictionary(const HashMap<String, HashMap<S
     _processPool->clearSupportedPlugins();
 }
 
-- (void)_terminateNetworkProcess
-{
-    _processPool->terminateNetworkProcess();
-}
-
-- (void)_sendNetworkProcessWillSuspendImminently
-{
-    _processPool->sendNetworkProcessWillSuspendImminentlyForTesting();
-}
-
-- (void)_sendNetworkProcessPrepareToSuspend:(void(^)(void))completionHandler
-{
-    _processPool->sendNetworkProcessPrepareToSuspendForTesting([completionHandler = makeBlockPtr(completionHandler)] {
-        completionHandler();
-    });
-}
-
-- (void)_sendNetworkProcessDidResume
-{
-    _processPool->sendNetworkProcessDidResume();
-}
-
 - (void)_terminateServiceWorkers
 {
     _processPool->terminateServiceWorkers();
@@ -435,12 +413,7 @@ static NSDictionary *policiesHashMapToDictionary(const HashMap<String, HashMap<S
 
 - (void)_setUseSeparateServiceWorkerProcess:(BOOL)useSeparateServiceWorkerProcess
 {
-    _processPool->setUseSeparateServiceWorkerProcess(useSeparateServiceWorkerProcess);
-}
-
-- (pid_t)_networkProcessIdentifier
-{
-    return _processPool->networkProcessIdentifier();
+    WebKit::WebProcessPool::setUseSeparateServiceWorkerProcess(useSeparateServiceWorkerProcess);
 }
 
 - (pid_t)_prewarmedProcessIdentifier
@@ -467,11 +440,6 @@ static NSDictionary *policiesHashMapToDictionary(const HashMap<String, HashMap<S
     _processPool->setShouldMakeNextWebProcessLaunchFailForTesting(true);
 }
 
-- (void)_makeNextNetworkProcessLaunchFailForTesting
-{
-    _processPool->setShouldMakeNextNetworkProcessLaunchFailForTesting(true);
-}
-
 - (BOOL)_hasPrewarmedWebProcess
 {
     for (auto& process : _processPool->processes()) {
@@ -560,18 +528,6 @@ static NSDictionary *policiesHashMapToDictionary(const HashMap<String, HashMap<S
     _processPool->setCookieStoragePartitioningEnabled(enabled);
 }
 
-- (void)_synthesizeAppIsBackground:(BOOL)background
-{
-    _processPool->synthesizeAppIsBackground(background);
-}
-
-- (void)_setAllowsAnySSLCertificateForServiceWorker:(BOOL)allows
-{
-#if ENABLE(SERVICE_WORKER)
-    _processPool->setAllowsAnySSLCertificateForServiceWorker(allows);
-#endif
-}
-
 #if PLATFORM(IOS_FAMILY)
 - (id <_WKGeolocationCoreLocationProvider>)_coreLocationProvider
 {
@@ -604,11 +560,6 @@ static NSDictionary *policiesHashMapToDictionary(const HashMap<String, HashMap<S
     });
 }
 
-- (BOOL)_networkProcessHasEntitlementForTesting:(NSString *)entitlement
-{
-    return _processPool->networkProcessHasEntitlementForTesting(entitlement);
-}
-
 - (void)_clearPermanentCredentialsForProtectionSpace:(NSURLProtectionSpace *)protectionSpace
 {
     _processPool->clearPermanentCredentialsForProtectionSpace(WebCore::ProtectionSpace(protectionSpace));
index 6769015..3b93140 100644 (file)
 - (_WKDownload *)_resumeDownloadFromData:(NSData *)resumeData websiteDataStore:(WKWebsiteDataStore *)dataStore  path:(NSString *)path originatingWebView:(WKWebView *)webView WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 // Test only. Should be called only while no web content processes are running.
-- (void)_terminateNetworkProcess WK_API_AVAILABLE(macos(10.15), ios(13.0));
-- (void)_sendNetworkProcessPrepareToSuspend:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
-- (void)_sendNetworkProcessWillSuspendImminently WK_API_AVAILABLE(macos(10.15), ios(13.0));
-- (void)_sendNetworkProcessDidResume WK_API_AVAILABLE(macos(10.15), ios(13.0));
 - (void)_terminateServiceWorkers WK_API_AVAILABLE(macos(10.14), ios(12.0));
 
 // Test only.
-- (pid_t)_networkProcessIdentifier WK_API_AVAILABLE(macos(10.13), ios(11.0));
 - (pid_t)_prewarmedProcessIdentifier WK_API_AVAILABLE(macos(10.15), ios(13.0));
 
 // Test only.
 - (size_t)_serviceWorkerProcessCount WK_API_AVAILABLE(macos(10.14), ios(12.0));
 - (void)_syncNetworkProcessCookies WK_API_DEPRECATED_WITH_REPLACEMENT("WKHTTPCookieStore._flushCookiesToDiskWithCompletionHandler:", macos(10.13, WK_MAC_TBA), ios(11.0, WK_IOS_TBA));
 - (void)_makeNextWebProcessLaunchFailForTesting WK_API_AVAILABLE(macos(10.14), ios(12.0));
-- (void)_makeNextNetworkProcessLaunchFailForTesting WK_API_AVAILABLE(macos(10.14), ios(12.0));
 - (NSUInteger)_maximumSuspendedPageCount WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
 - (NSUInteger)_processCacheCapacity WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
 - (NSUInteger)_processCacheSize WK_API_AVAILABLE(macos(10.15), ios(13.0));
 - (void)_preconnectToServer:(NSURL *)serverURL WK_API_DEPRECATED_WITH_REPLACEMENT("WKWebView._preconnectToServer", macos(10.13.4, WK_MAC_TBA), ios(11.3, WK_IOS_TBA));
 
 // Test only.
-- (void)_setAllowsAnySSLCertificateForServiceWorker:(BOOL)allows WK_API_AVAILABLE(macos(10.13.4), ios(11.3));
 - (void)_getActivePagesOriginsInWebProcessForTesting:(pid_t)pid completionHandler:(void(^)(NSArray<NSString *> *))completionHandler WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
-- (BOOL)_networkProcessHasEntitlementForTesting:(NSString *)entitlement WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
 - (void)_clearPermanentCredentialsForProtectionSpace:(NSURLProtectionSpace *)protectionSpace WK_API_AVAILABLE(macos(10.15), ios(13.0));
 
 @property (nonatomic, getter=_isCookieStoragePartitioningEnabled, setter=_setCookieStoragePartitioningEnabled:) BOOL _cookieStoragePartitioningEnabled WK_API_DEPRECATED("Partitioned cookies are no longer supported", macos(10.12.3, 10.14.4), ios(10.3, 12.2));
-- (void)_synthesizeAppIsBackground:(BOOL)background WK_API_AVAILABLE(macos(10.15), ios(13.0));
 
 // Test only.
 - (void)_seedResourceLoadStatisticsForTestingWithFirstParty:(NSURL *)firstPartyURL thirdParty:(NSURL *)thirdPartyURL shouldScheduleNotification:(BOOL)shouldScheduleNotification completionHandler:(void(^)(void))completionHandler  WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
index d16ee24..7374cbe 100644 (file)
@@ -606,6 +606,11 @@ static Vector<WebKit::WebsiteDataRecord> toWebsiteDataRecords(NSArray *dataRecor
     });
 }
 
+- (BOOL)_networkProcessHasEntitlementForTesting:(NSString *)entitlement
+{
+    return _websiteDataStore->networkProcessHasEntitlementForTesting(entitlement);
+}
+
 - (id <_WKWebsiteDataStoreDelegate>)_delegate
 {
     return _delegate.get().get();
@@ -657,4 +662,42 @@ static Vector<WebKit::WebsiteDataRecord> toWebsiteDataRecords(NSArray *dataRecor
 #endif
 }
 
+- (void)_terminateNetworkProcess
+{
+    _websiteDataStore->terminateNetworkProcess();
+}
+
+- (void)_sendNetworkProcessPrepareToSuspend:(void(^)(void))completionHandler
+{
+    _websiteDataStore->sendNetworkProcessPrepareToSuspendForTesting([completionHandler = makeBlockPtr(completionHandler)] {
+        completionHandler();
+    });
+}
+
+- (void)_sendNetworkProcessWillSuspendImminently
+{
+    _websiteDataStore->sendNetworkProcessWillSuspendImminentlyForTesting();
+
+}
+
+- (void)_sendNetworkProcessDidResume
+{
+    _websiteDataStore->sendNetworkProcessDidResume();
+}
+
+- (void)_synthesizeAppIsBackground:(BOOL)background
+{
+    _websiteDataStore->networkProcess().synthesizeAppIsBackground(background);
+}
+
+- (pid_t)_networkProcessIdentifier
+{
+    return _websiteDataStore->networkProcess().processIdentifier();
+}
+
++ (void)_makeNextNetworkProcessLaunchFailForTesting
+{
+    WebKit::WebsiteDataStore::makeNextNetworkProcessLaunchFailForTesting();
+}
+
 @end
index 828bbef..df2c30b 100644 (file)
@@ -84,9 +84,19 @@ typedef NS_OPTIONS(NSUInteger, _WKWebsiteDataStoreFetchOptions) {
 
 - (void)_renameOrigin:(NSURL *)oldName to:(NSURL *)newName forDataOfTypes:(NSSet<NSString *> *)dataTypes completionHandler:(void (^)(void))completionHandler;
 
+- (BOOL)_networkProcessHasEntitlementForTesting:(NSString *)entitlement WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 @property (nullable, nonatomic, weak) id <_WKWebsiteDataStoreDelegate> _delegate WK_API_AVAILABLE(macos(10.15), ios(13.0));
 @property (nonatomic, readonly, copy) _WKWebsiteDataStoreConfiguration *_configuration;
 
+- (void)_terminateNetworkProcess WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_sendNetworkProcessPrepareToSuspend:(void(^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_sendNetworkProcessWillSuspendImminently WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_sendNetworkProcessDidResume WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_synthesizeAppIsBackground:(BOOL)background WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (pid_t)_networkProcessIdentifier WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
++ (void)_makeNextNetworkProcessLaunchFailForTesting WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 @end
 
 NS_ASSUME_NONNULL_END
index 1ee73eb..d10db29 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "WebKitCookieManager.h"
 
+#include "NetworkProcessProxy.h"
 #include "SoupCookiePersistentStorageType.h"
 #include "WebCookieManagerProxy.h"
 #include "WebKitCookieManagerPrivate.h"
@@ -56,6 +57,12 @@ enum {
 };
 
 struct _WebKitCookieManagerPrivate {
+    WebCookieManagerProxy& cookieManager() const
+    {
+        ASSERT(dataManager);
+        return webkitWebsiteDataManagerGetDataStore(dataManager).networkProcess().cookieManager();
+    }
+
     PAL::SessionID sessionID() const
     {
         ASSERT(dataManager);
@@ -64,8 +71,7 @@ struct _WebKitCookieManagerPrivate {
 
     ~_WebKitCookieManagerPrivate()
     {
-        for (auto* processPool : webkitWebsiteDataManagerGetProcessPools(dataManager))
-            processPool->supplement<WebCookieManagerProxy>()->setCookieObserverCallback(sessionID(), nullptr);
+        cookieManager().setCookieObserverCallback(sessionID(), nullptr);
     }
 
     WebKitWebsiteDataManager* dataManager;
@@ -139,11 +145,9 @@ WebKitCookieManager* webkitCookieManagerCreate(WebKitWebsiteDataManager* dataMan
 {
     WebKitCookieManager* manager = WEBKIT_COOKIE_MANAGER(g_object_new(WEBKIT_TYPE_COOKIE_MANAGER, nullptr));
     manager->priv->dataManager = dataManager;
-    for (auto* processPool : webkitWebsiteDataManagerGetProcessPools(manager->priv->dataManager)) {
-        processPool->supplement<WebCookieManagerProxy>()->setCookieObserverCallback(manager->priv->sessionID(), [manager] {
-            g_signal_emit(manager, signals[CHANGED], 0);
-        });
-    }
+    manager->priv->cookieManager().setCookieObserverCallback(manager->priv->sessionID(), [manager] {
+        g_signal_emit(manager, signals[CHANGED], 0);
+    });
     return manager;
 }
 
@@ -173,8 +177,7 @@ void webkit_cookie_manager_set_persistent_storage(WebKitCookieManager* manager,
     if (sessionID.isEphemeral())
         return;
 
-    for (auto* processPool : webkitWebsiteDataManagerGetProcessPools(manager->priv->dataManager))
-        processPool->supplement<WebCookieManagerProxy>()->setCookiePersistentStorage(sessionID, String::fromUTF8(filename), toSoupCookiePersistentStorageType(storage));
+    manager->priv->cookieManager().setCookiePersistentStorage(sessionID, String::fromUTF8(filename), toSoupCookiePersistentStorageType(storage));
 }
 
 /**
@@ -192,8 +195,7 @@ void webkit_cookie_manager_set_accept_policy(WebKitCookieManager* manager, WebKi
 {
     g_return_if_fail(WEBKIT_IS_COOKIE_MANAGER(manager));
 
-    for (auto* processPool : webkitWebsiteDataManagerGetProcessPools(manager->priv->dataManager))
-        processPool->supplement<WebCookieManagerProxy>()->setHTTPCookieAcceptPolicy(manager->priv->sessionID(), toHTTPCookieAcceptPolicy(policy), []() { });
+    manager->priv->cookieManager().setHTTPCookieAcceptPolicy(manager->priv->sessionID(), toHTTPCookieAcceptPolicy(policy), []() { });
 }
 
 /**
@@ -217,14 +219,7 @@ void webkit_cookie_manager_get_accept_policy(WebKitCookieManager* manager, GCanc
 
     GRefPtr<GTask> task = adoptGRef(g_task_new(manager, cancellable, callback, userData));
 
-    // The policy is the same in all process pools having the same session ID, so just ask any.
-    const auto& processPools = webkitWebsiteDataManagerGetProcessPools(manager->priv->dataManager);
-    if (processPools.isEmpty()) {
-        g_task_return_int(task.get(), WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY);
-        return;
-    }
-
-    processPools[0]->supplement<WebCookieManagerProxy>()->getHTTPCookieAcceptPolicy(manager->priv->sessionID(), [task = WTFMove(task)](WebCore::HTTPCookieAcceptPolicy policy) {
+    manager->priv->cookieManager().getHTTPCookieAcceptPolicy(manager->priv->sessionID(), [task = WTFMove(task)](WebCore::HTTPCookieAcceptPolicy policy) {
         g_task_return_int(task.get(), toWebKitCookieAcceptPolicy(policy));
     });
 }
@@ -269,11 +264,7 @@ void webkit_cookie_manager_add_cookie(WebKitCookieManager* manager, SoupCookie*
     g_return_if_fail(cookie);
 
     GRefPtr<GTask> task = adoptGRef(g_task_new(manager, cancellable, callback, userData));
-
-    // Cookies are read/written from/to the same SQLite database on disk regardless
-    // of the process we access them from, so just use the first process pool.
-    const auto& processPools = webkitWebsiteDataManagerGetProcessPools(manager->priv->dataManager);
-    processPools[0]->supplement<WebCookieManagerProxy>()->setCookies(manager->priv->sessionID(), { WebCore::Cookie(cookie) }, [task = WTFMove(task)]() {
+    manager->priv->cookieManager().setCookies(manager->priv->sessionID(), { WebCore::Cookie(cookie) }, [task = WTFMove(task)]() {
         g_task_return_boolean(task.get(), TRUE);
     });
 }
@@ -320,11 +311,7 @@ void webkit_cookie_manager_get_cookies(WebKitCookieManager* manager, const gchar
     g_return_if_fail(uri);
 
     GRefPtr<GTask> task = adoptGRef(g_task_new(manager, cancellable, callback, userData));
-
-    // Cookies are read/written from/to the same SQLite database on disk regardless
-    // of the process we access them from, so just use the first process pool.
-    const auto& processPools = webkitWebsiteDataManagerGetProcessPools(manager->priv->dataManager);
-    processPools[0]->supplement<WebCookieManagerProxy>()->getCookies(manager->priv->sessionID(), URL(URL(), String::fromUTF8(uri)), [task = WTFMove(task)](const Vector<WebCore::Cookie>& cookies) {
+    manager->priv->cookieManager().getCookies(manager->priv->sessionID(), URL(URL(), String::fromUTF8(uri)), [task = WTFMove(task)](const Vector<WebCore::Cookie>& cookies) {
         GList* cookiesList = nullptr;
         for (auto& cookie : cookies)
             cookiesList = g_list_prepend(cookiesList, cookie.toSoupCookie());
@@ -378,11 +365,7 @@ void webkit_cookie_manager_delete_cookie(WebKitCookieManager* manager, SoupCooki
     g_return_if_fail(cookie);
 
     GRefPtr<GTask> task = adoptGRef(g_task_new(manager, cancellable, callback, userData));
-
-    // Cookies are read/written from/to the same SQLite database on disk regardless
-    // of the process we access them from, so just use the first process pool.
-    const auto& processPools = webkitWebsiteDataManagerGetProcessPools(manager->priv->dataManager);
-    processPools[0]->supplement<WebCookieManagerProxy>()->deleteCookie(manager->priv->sessionID(), WebCore::Cookie(cookie), [task = WTFMove(task)]() {
+    manager->priv->cookieManager().deleteCookie(manager->priv->sessionID(), WebCore::Cookie(cookie), [task = WTFMove(task)]() {
         g_task_return_boolean(task.get(), TRUE);
     });
 }
index 71667cf..36d0008 100644 (file)
@@ -402,7 +402,6 @@ static void webkitWebContextConstructed(GObject* object)
         priv->websiteDataManager = adoptGRef(webkit_website_data_manager_new("local-storage-directory", priv->localStorageDirectory.data(), nullptr));
 
     priv->processPool = WebProcessPool::create(configuration);
-    priv->processPool->setPrimaryDataStore(webkitWebsiteDataManagerGetDataStore(priv->websiteDataManager.get()));
     priv->processPool->setUserMessageHandler([webContext](UserMessage&& message, CompletionHandler<void(UserMessage&&)>&& completionHandler) {
         // Sink the floating ref.
         GRefPtr<WebKitUserMessage> userMessage = webkitUserMessageCreate(WTFMove(message), WTFMove(completionHandler));
@@ -410,8 +409,6 @@ static void webkitWebContextConstructed(GObject* object)
         g_signal_emit(webContext, signals[USER_MESSAGE_RECEIVED], 0, userMessage.get(), &returnValue);
     });
 
-    webkitWebsiteDataManagerAddProcessPool(priv->websiteDataManager.get(), *priv->processPool);
-
     priv->processModel = WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES;
 
 #if ENABLE(MEMORY_SAMPLER)
@@ -439,11 +436,6 @@ static void webkitWebContextDispose(GObject* object)
         priv->processPool->setDownloadClient(makeUniqueRef<API::DownloadClient>());
     }
 
-    if (priv->websiteDataManager) {
-        webkitWebsiteDataManagerRemoveProcessPool(priv->websiteDataManager.get(), *priv->processPool);
-        priv->websiteDataManager = nullptr;
-    }
-
     if (priv->faviconDatabase) {
         webkitFaviconDatabaseClose(priv->faviconDatabase.get());
         priv->faviconDatabase = nullptr;
@@ -1581,8 +1573,8 @@ void webkit_web_context_prefetch_dns(WebKitWebContext* context, const char* host
     g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
     g_return_if_fail(hostname);
 
-    if (context->priv->dnsPrefetchedHosts.add(hostname).isNewEntry)
-        context->priv->processPool->sendToNetworkingProcess(Messages::NetworkProcess::PrefetchDNS(String::fromUTF8(hostname)));
+    auto& websiteDataStore = webkitWebsiteDataManagerGetDataStore(context->priv->websiteDataManager.get());
+    websiteDataStore.networkProcess().send(Messages::NetworkProcess::PrefetchDNS(String::fromUTF8(hostname)), 0);
     context->priv->dnsPrefetchHystereris.impulse();
 }
 
index 4135c26..d8b3f3c 100644 (file)
@@ -759,7 +759,6 @@ static void webkitWebViewConstructed(GObject* object)
         webkit_website_data_manager_set_tls_errors_policy(priv->websiteDataManager.get(), webkit_website_data_manager_get_tls_errors_policy(contextDataManager));
         auto proxySettings = webkitWebsiteDataManagerGetDataStore(contextDataManager).networkProxySettings();
         webkitWebsiteDataManagerGetDataStore(priv->websiteDataManager.get()).setNetworkProxySettings(WTFMove(proxySettings));
-        webkitWebsiteDataManagerAddProcessPool(priv->websiteDataManager.get(), webkitWebContextGetProcessPool(priv->context.get()));
     }
 
     if (!priv->websitePolicies)
@@ -945,11 +944,6 @@ static void webkitWebViewDispose(GObject* object)
         webkitWebContextWebViewDestroyed(webView->priv->context.get(), webView);
     }
 
-    if (webView->priv->websiteDataManager) {
-        webkitWebsiteDataManagerRemoveProcessPool(webView->priv->websiteDataManager.get(), webkitWebContextGetProcessPool(webView->priv->context.get()));
-        webView->priv->websiteDataManager = nullptr;
-    }
-
     if (webView->priv->currentScriptDialog) {
         webkit_script_dialog_close(webView->priv->currentScriptDialog);
         ASSERT(!webView->priv->currentScriptDialog);
index da9a3aa..4c4ef5d 100644 (file)
@@ -95,11 +95,6 @@ enum {
 };
 
 struct _WebKitWebsiteDataManagerPrivate {
-    ~_WebKitWebsiteDataManagerPrivate()
-    {
-        ASSERT(processPools.isEmpty());
-    }
-
     RefPtr<WebKit::WebsiteDataStore> websiteDataStore;
     GUniquePtr<char> baseDataDirectory;
     GUniquePtr<char> baseCacheDirectory;
@@ -115,7 +110,6 @@ struct _WebKitWebsiteDataManagerPrivate {
     WebKitTLSErrorsPolicy tlsErrorsPolicy;
 
     GRefPtr<WebKitCookieManager> cookieManager;
-    Vector<WebProcessPool*> processPools;
 };
 
 WEBKIT_DEFINE_TYPE(WebKitWebsiteDataManager, webkit_website_data_manager, G_TYPE_OBJECT)
@@ -494,30 +488,13 @@ WebKit::WebsiteDataStore& webkitWebsiteDataManagerGetDataStore(WebKitWebsiteData
             configuration->setServiceWorkerRegistrationDirectory(FileSystem::stringFromFileSystemRepresentation(priv->swRegistrationsDirectory.get()));
         if (priv->domCacheDirectory)
             configuration->setCacheStorageDirectory(FileSystem::stringFromFileSystemRepresentation(priv->domCacheDirectory.get()));
-        priv->websiteDataStore = WebKit::WebsiteDataStore::create(WTFMove(configuration), PAL::SessionID::defaultSessionID());
+        priv->websiteDataStore = WebKit::WebsiteDataStore::create(WTFMove(configuration), PAL::SessionID::generatePersistentSessionID());
         priv->websiteDataStore->setIgnoreTLSErrors(priv->tlsErrorsPolicy == WEBKIT_TLS_ERRORS_POLICY_IGNORE);
     }
 
     return *priv->websiteDataStore;
 }
 
-void webkitWebsiteDataManagerAddProcessPool(WebKitWebsiteDataManager* manager, WebProcessPool& processPool)
-{
-    ASSERT(!manager->priv->processPools.contains(&processPool));
-    manager->priv->processPools.append(&processPool);
-}
-
-void webkitWebsiteDataManagerRemoveProcessPool(WebKitWebsiteDataManager* manager, WebProcessPool& processPool)
-{
-    ASSERT(manager->priv->processPools.contains(&processPool));
-    manager->priv->processPools.removeFirst(&processPool);
-}
-
-const Vector<WebProcessPool*>& webkitWebsiteDataManagerGetProcessPools(WebKitWebsiteDataManager* manager)
-{
-    return manager->priv->processPools;
-}
-
 /**
  * webkit_website_data_manager_new:
  * @first_option_name: name of the first option to set
index 2a589e2..fc9e822 100644 (file)
 
 #pragma once
 
-#include "WebProcessPool.h"
 #include "WebsiteDataStore.h"
 
 WebKit::WebsiteDataStore& webkitWebsiteDataManagerGetDataStore(WebKitWebsiteDataManager*);
-void webkitWebsiteDataManagerAddProcessPool(WebKitWebsiteDataManager*, WebKit::WebProcessPool&);
-void webkitWebsiteDataManagerRemoveProcessPool(WebKitWebsiteDataManager*, WebKit::WebProcessPool&);
-const Vector<WebKit::WebProcessPool*>& webkitWebsiteDataManagerGetProcessPools(WebKitWebsiteDataManager*);
-
index ab64a45..2cd88c5 100644 (file)
@@ -1392,8 +1392,8 @@ void WebAutomationSession::addSingleCookie(const Inspector::Protocol::Automation
 
     cookie.httpOnly = *httpOnly;
 
-    WebCookieManagerProxy* cookieManager = m_processPool->supplement<WebCookieManagerProxy>();
-    cookieManager->setCookies(page->websiteDataStore().sessionID(), { cookie }, [callback]() {
+    WebCookieManagerProxy& cookieManager = page->websiteDataStore().networkProcess().cookieManager();
+    cookieManager.setCookies(page->websiteDataStore().sessionID(), { cookie }, [callback]() {
         callback->sendSuccess();
     });
 }
@@ -1409,8 +1409,8 @@ Inspector::Protocol::ErrorStringOr<void> WebAutomationSession::deleteAllCookies(
 
     String host = activeURL.host().toString();
 
-    WebCookieManagerProxy* cookieManager = m_processPool->supplement<WebCookieManagerProxy>();
-    cookieManager->deleteCookiesForHostnames(page->websiteDataStore().sessionID(), { host, domainByAddingDotPrefixIfNeeded(host) });
+    WebCookieManagerProxy& cookieManager = page->websiteDataStore().networkProcess().cookieManager();
+    cookieManager.deleteCookiesForHostnames(page->websiteDataStore().sessionID(), { host, domainByAddingDotPrefixIfNeeded(host) });
 
     return { };
 }
index 41c0a0f..4f398b5 100644 (file)
@@ -48,7 +48,7 @@ public:
     virtual ~AuxiliaryProcessProxy();
 
     void connect();
-    void terminate();
+    virtual void terminate();
 
     virtual ProcessThrottler& throttler() = 0;
 
index dbe44f9..4c845a0 100644 (file)
@@ -41,11 +41,11 @@ namespace WebKit {
 class LegacyCustomProtocolManagerProxy;
 
 class LegacyCustomProtocolManagerClient final : public API::CustomProtocolManagerClient {
-private:
+public:
     void startLoading(LegacyCustomProtocolManagerProxy&, LegacyCustomProtocolID, const WebCore::ResourceRequest&) final;
     void stopLoading(LegacyCustomProtocolManagerProxy&, LegacyCustomProtocolID) final;
     void invalidate(LegacyCustomProtocolManagerProxy&) final;
-
+private:
     HashMap<LegacyCustomProtocolID, RetainPtr<WKCustomProtocolLoader>> m_loaderMap;
 };
 
index 35fbf47..34b1406 100644 (file)
@@ -134,8 +134,9 @@ static void registerUserDefaultsIfNeeded()
 
 void WebProcessPool::updateProcessSuppressionState()
 {
-    if (m_networkProcess)
-        m_networkProcess->setProcessSuppressionEnabled(processSuppressionEnabled());
+    WebsiteDataStore::forEachWebsiteDataStore([enabled = processSuppressionEnabled()] (WebsiteDataStore& dataStore) {
+        dataStore.networkProcess().setProcessSuppressionEnabled(enabled);
+    });
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
     if (!m_processSuppressionDisabledForPageCounter.value())
@@ -166,8 +167,6 @@ void WebProcessPool::platformInitialize()
     if (![[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitSuppressMemoryPressureHandler"])
         installMemoryPressureHandler();
 
-    setLegacyCustomProtocolManagerClient(makeUnique<LegacyCustomProtocolManagerClient>());
-
 #if PLATFORM(IOS_FAMILY) && !PLATFORM(MACCATALYST)
     if (!_MGCacheValid()) {
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@@ -493,22 +492,6 @@ void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationPara
 
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 
-    {
-        bool isSafari = false;
-        bool isMiniBrowser = false;
-#if PLATFORM(IOS_FAMILY)
-        isSafari = WebCore::IOSApplication::isMobileSafari();
-        isMiniBrowser = WebCore::IOSApplication::isMiniBrowser();
-#elif PLATFORM(MAC)
-        isSafari = WebCore::MacApplication::isSafari();
-        isMiniBrowser = WebCore::MacApplication::isMiniBrowser();
-#endif
-        if (isSafari || isMiniBrowser) {
-            parameters.defaultDataStoreParameters.networkSessionParameters.httpProxy = URL(URL(), [defaults stringForKey:(NSString *)WebKit2HTTPProxyDefaultsKey]);
-            parameters.defaultDataStoreParameters.networkSessionParameters.httpsProxy = URL(URL(), [defaults stringForKey:(NSString *)WebKit2HTTPSProxyDefaultsKey]);
-        }
-    }
-
     parameters.networkATSContext = adoptCF(_CFNetworkCopyATSContext());
 
     parameters.shouldSuppressMemoryPressureHandler = [defaults boolForKey:WebKitSuppressMemoryPressureHandlerDefaultsKey];
@@ -520,8 +503,6 @@ void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationPara
 #endif
 
     parameters.enableAdClickAttributionDebugMode = [defaults boolForKey:[NSString stringWithFormat:@"Experimental%@", WebPreferencesKey::adClickAttributionDebugModeEnabledKey().createCFString().get()]];
-
-    parameters.defaultDataStoreParameters.networkSessionParameters.appHasRequestedCrossWebsiteTrackingPermission = hasRequestedCrossWebsiteTrackingPermission();
 }
 
 void WebProcessPool::platformInvalidateContext()
@@ -600,11 +581,6 @@ bool WebProcessPool::processSuppressionEnabled() const
     return !m_userObservablePageCounter.value() && !m_processSuppressionDisabledForPageCounter.value();
 }
 
-bool WebProcessPool::networkProcessHasEntitlementForTesting(const String& entitlement)
-{
-    return WTF::hasEntitlement(ensureNetworkProcess().connection()->xpcConnection(), entitlement.utf8().data());
-}
-
 #if PLATFORM(IOS_FAMILY) && !PLATFORM(MACCATALYST)
 float WebProcessPool::displayBrightness()
 {
@@ -941,23 +917,4 @@ void WebProcessPool::registerHighDynamicRangeChangeCallback()
 }
 #endif
 
-OSObjectPtr<xpc_object_t> WebProcessPool::xpcEndpointMessage() const
-{
-    return m_endpointMessage;
-}
-
-void WebProcessPool::sendNetworkProcessXPCEndpointToWebProcess(OSObjectPtr<xpc_object_t> endpointMessage)
-{
-    m_endpointMessage = endpointMessage;
-
-    for (auto process : m_processes) {
-        if (process->state() != AuxiliaryProcessProxy::State::Running)
-            continue;
-        if (!process->connection())
-            continue;
-        auto connection = process->connection()->xpcConnection();
-        xpc_connection_send_message(connection, endpointMessage.get());
-    }
-}
-
 } // namespace WebKit
index c5de4e7..f7cff85 100644 (file)
@@ -75,8 +75,8 @@ void DownloadProxy::cancel()
     if (!m_processPool)
         return;
 
-    if (NetworkProcessProxy* networkProcess = m_processPool->networkProcess())
-        networkProcess->send(Messages::NetworkProcess::CancelDownload(m_downloadID), 0);
+    if (m_dataStore)
+        m_dataStore->networkProcess().send(Messages::NetworkProcess::CancelDownload(m_downloadID), 0);
 }
 
 void DownloadProxy::invalidate()
@@ -103,15 +103,13 @@ WebPageProxy* DownloadProxy::originatingPage() const
 #if PLATFORM(COCOA)
 void DownloadProxy::publishProgress(const URL& URL)
 {
-    if (!m_processPool)
+    if (!m_dataStore)
         return;
 
-    if (auto* networkProcess = m_processPool->networkProcess()) {
-        SandboxExtension::Handle handle;
-        bool createdSandboxExtension = SandboxExtension::createHandle(URL.fileSystemPath(), SandboxExtension::Type::ReadWrite, handle);
-        ASSERT_UNUSED(createdSandboxExtension, createdSandboxExtension);
-        networkProcess->send(Messages::NetworkProcess::PublishDownloadProgress(m_downloadID, URL, handle), 0);
-    }
+    SandboxExtension::Handle handle;
+    bool createdSandboxExtension = SandboxExtension::createHandle(URL.fileSystemPath(), SandboxExtension::Type::ReadWrite, handle);
+    ASSERT_UNUSED(createdSandboxExtension, createdSandboxExtension);
+    m_dataStore->networkProcess().send(Messages::NetworkProcess::PublishDownloadProgress(m_downloadID, URL, handle), 0);
 }
 #endif // PLATFORM(COCOA)
 
@@ -131,11 +129,10 @@ void DownloadProxy::didStart(const ResourceRequest& request, const String& sugge
 
 void DownloadProxy::didReceiveAuthenticationChallenge(AuthenticationChallenge&& authenticationChallenge, uint64_t challengeID)
 {
-    if (!m_processPool)
+    if (!m_processPool || !m_dataStore)
         return;
 
-    auto authenticationChallengeProxy = AuthenticationChallengeProxy::create(WTFMove(authenticationChallenge), challengeID, makeRef(*m_processPool->networkingProcessConnection()), nullptr);
-
+    auto authenticationChallengeProxy = AuthenticationChallengeProxy::create(WTFMove(authenticationChallenge), challengeID, makeRef(*m_dataStore->networkProcess().connection()), nullptr);
     m_processPool->downloadClient().didReceiveAuthenticationChallenge(*this, authenticationChallengeProxy.get());
 }
 
@@ -146,15 +143,10 @@ void DownloadProxy::willSendRequest(ResourceRequest&& proposedRequest, const Res
 
     m_processPool->downloadClient().willSendRequest(*this, WTFMove(proposedRequest), redirectResponse, [this, protectedThis = makeRef(*this)](ResourceRequest&& newRequest) {
         m_redirectChain.append(newRequest.url());
-
-        if (!protectedThis->m_processPool)
+        if (!protectedThis->m_dataStore)
             return;
-
-        auto* networkProcessProxy = protectedThis->m_processPool->networkProcess();
-        if (!networkProcessProxy)
-            return;
-
-        networkProcessProxy->send(Messages::NetworkProcess::ContinueWillSendRequest(protectedThis->m_downloadID, newRequest), 0);
+        auto& networkProcessProxy = protectedThis->m_dataStore->networkProcess();
+        networkProcessProxy.send(Messages::NetworkProcess::ContinueWillSendRequest(protectedThis->m_downloadID, newRequest), 0);
     });
 }
 
@@ -179,16 +171,14 @@ void DownloadProxy::decideDestinationWithSuggestedFilenameAsync(DownloadID downl
     if (!m_processPool)
         return;
     
-    m_processPool->downloadClient().decideDestinationWithSuggestedFilename(*this, ResourceResponseBase::sanitizeSuggestedFilename(suggestedFilename), [this, protectedThis = makeRef(*this), downloadID = downloadID] (AllowOverwrite allowOverwrite, String destination) {
+    m_processPool->downloadClient().decideDestinationWithSuggestedFilename(*this, ResourceResponseBase::sanitizeSuggestedFilename(suggestedFilename), [this, protectedThis = makeRef(*this), downloadID] (AllowOverwrite allowOverwrite, String destination) {
         SandboxExtension::Handle sandboxExtensionHandle;
         if (!destination.isNull())
             SandboxExtension::createHandle(destination, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
 
-        if (!m_processPool)
+        if (!m_dataStore)
             return;
-
-        if (auto* networkProcess = m_processPool->networkProcess())
-            networkProcess->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite == AllowOverwrite::Yes), 0);
+        m_dataStore->networkProcess().send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite == AllowOverwrite::Yes), 0);
     });
 }
 
index 76a0715..d74a8fa 100644 (file)
@@ -44,7 +44,7 @@
 namespace WebKit {
 
 DownloadProxyMap::DownloadProxyMap(NetworkProcessProxy& process)
-    : m_process(makeWeakPtr(process))
+    : m_process(process)
 #if PLATFORM(COCOA)
     , m_shouldTakeAssertion(WTF::processHasEntitlement("com.apple.multitasking.systemappassertions"))
 #endif
@@ -70,14 +70,12 @@ void DownloadProxyMap::platformDestroy()
 
 void DownloadProxyMap::applicationDidEnterBackground()
 {
-    if (m_process)
-        m_process->send(Messages::NetworkProcess::ApplicationDidEnterBackground(), 0);
+    m_process.send(Messages::NetworkProcess::ApplicationDidEnterBackground(), 0);
 }
 
 void DownloadProxyMap::applicationWillEnterForeground()
 {
-    if (m_process)
-        m_process->send(Messages::NetworkProcess::ApplicationWillEnterForeground(), 0);
+    m_process.send(Messages::NetworkProcess::ApplicationWillEnterForeground(), 0);
 }
 
 DownloadProxy& DownloadProxyMap::createDownloadProxy(WebsiteDataStore& dataStore, WebProcessPool& processPool, const WebCore::ResourceRequest& resourceRequest, const FrameInfoData& frameInfo, WebPageProxy* originatingPage)
@@ -92,13 +90,12 @@ DownloadProxy& DownloadProxyMap::createDownloadProxy(WebsiteDataStore& dataStore
         m_downloadUIAssertion = makeUnique<ProcessAssertion>(getCurrentProcessID(), "WebKit downloads"_s, ProcessAssertionType::UnboundedNetworking);
 
         ASSERT(!m_downloadNetworkingAssertion);
-        RELEASE_ASSERT(m_process);
-        m_downloadNetworkingAssertion = makeUnique<ProcessAssertion>(m_process->processIdentifier(), "WebKit downloads"_s, ProcessAssertionType::UnboundedNetworking);
+        m_downloadNetworkingAssertion = makeUnique<ProcessAssertion>(m_process.processIdentifier(), "WebKit downloads"_s, ProcessAssertionType::UnboundedNetworking);
 
         RELEASE_LOG(ProcessSuspension, "UIProcess took 'WebKit downloads' assertions for UIProcess and NetworkProcess");
     }
 
-    m_process->addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID().downloadID(), downloadProxy.get());
+    m_process.addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID().downloadID(), downloadProxy.get());
 
     return downloadProxy;
 }
@@ -109,12 +106,9 @@ void DownloadProxyMap::downloadFinished(DownloadProxy& downloadProxy)
 
     RELEASE_LOG(Loading, "Removing download %" PRIu64 " from UIProcess DownloadProxyMap", downloadID.downloadID());
 
-    // The DownloadProxy may be holding the last reference to the process pool.
-    auto protectedProcessPool = makeRefPtr(m_process->processPool());
-
     ASSERT(m_downloads.contains(downloadID));
 
-    m_process->removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadID.downloadID());
+    m_process.removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadID.downloadID());
     downloadProxy.invalidate();
     m_downloads.remove(downloadID);
 
@@ -133,15 +127,13 @@ void DownloadProxyMap::invalidate()
     for (const auto& download : m_downloads.values()) {
         download->processDidClose();
         download->invalidate();
-        m_process->removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), download->downloadID().downloadID());
+        m_process.removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), download->downloadID().downloadID());
     }
 
     m_downloads.clear();
     m_downloadUIAssertion = nullptr;
     m_downloadNetworkingAssertion = nullptr;
     RELEASE_LOG(ProcessSuspension, "UIProcess DownloadProxyMap invalidated - Released 'WebKit downloads' assertions for UIProcess and NetworkProcess");
-
-    m_process = nullptr;
 }
 
 } // namespace WebKit
index 3be2079..4fa001b 100644 (file)
@@ -71,7 +71,7 @@ private:
     void platformCreate();
     void platformDestroy();
 
-    WeakPtr<NetworkProcessProxy> m_process;
+    NetworkProcessProxy& m_process;
     HashMap<DownloadID, RefPtr<DownloadProxy>> m_downloads;
 
     bool m_shouldTakeAssertion { false };
index 72deb0c..82c6eb1 100644 (file)
@@ -155,7 +155,7 @@ static Ref<WebsiteDataStore> inspectorWebsiteDataStore()
     configuration->setResourceLoadStatisticsDirectory(FileSystem::pathByAppendingComponent(baseDataDirectory, "itp"));
     configuration->setServiceWorkerRegistrationDirectory(FileSystem::pathByAppendingComponent(baseDataDirectory, "serviceworkers"));
     configuration->setDeviceIdHashSaltsStorageDirectory(FileSystem::pathByAppendingComponent(baseDataDirectory, "deviceidhashsalts"));
-    return WebsiteDataStore::create(WTFMove(configuration), PAL::SessionID::defaultSessionID());
+    return WebsiteDataStore::create(WTFMove(configuration), PAL::SessionID::generatePersistentSessionID());
 }
 
 WebPageProxy* WebInspectorProxy::platformCreateFrontendPage()
@@ -175,7 +175,6 @@ WebPageProxy* WebInspectorProxy::platformCreateFrontendPage()
     auto pageGroup = WebPageGroup::create(inspectorPageGroupIdentifierForPage(inspectedPage()));
     auto websiteDataStore = inspectorWebsiteDataStore();
     auto& processPool = inspectorProcessPool(inspectionLevel());
-    processPool.setPrimaryDataStore(websiteDataStore.get());
 
     auto pageConfiguration = API::PageConfiguration::create();
     pageConfiguration->setProcessPool(&processPool);
index 8c23bbe..d6c3323 100644 (file)
@@ -44,17 +44,17 @@ LegacyCustomProtocolManagerProxy::~LegacyCustomProtocolManagerProxy()
 
 void LegacyCustomProtocolManagerProxy::startLoading(LegacyCustomProtocolID customProtocolID, const WebCore::ResourceRequest& request)
 {
-    m_networkProcessProxy.processPool().customProtocolManagerClient().startLoading(*this, customProtocolID, request);
+    m_networkProcessProxy.customProtocolManagerClient().startLoading(*this, customProtocolID, request);
 }
 
 void LegacyCustomProtocolManagerProxy::stopLoading(LegacyCustomProtocolID customProtocolID)
 {
-    m_networkProcessProxy.processPool().customProtocolManagerClient().stopLoading(*this, customProtocolID);
+    m_networkProcessProxy.customProtocolManagerClient().stopLoading(*this, customProtocolID);
 }
 
 void LegacyCustomProtocolManagerProxy::invalidate()
 {
-    m_networkProcessProxy.processPool().customProtocolManagerClient().invalidate(*this);
+    m_networkProcessProxy.customProtocolManagerClient().invalidate(*this);
 }
 
 void LegacyCustomProtocolManagerProxy::wasRedirectedToRequest(LegacyCustomProtocolID customProtocolID, const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& redirectResponse)
index 825f909..9607a7e 100644 (file)
@@ -27,6 +27,7 @@
 #include "NetworkProcessProxy.h"
 
 #include "APIContentRuleList.h"
+#include "APICustomProtocolManagerClient.h"
 #include "AuthenticationChallengeProxy.h"
 #include "AuthenticationManager.h"
 #include "DownloadProxyMap.h"
@@ -35,6 +36,7 @@
 #include "LegacyCustomProtocolManagerMessages.h"
 #include "LegacyCustomProtocolManagerProxyMessages.h"
 #endif
+#include "LegacyGlobalSettings.h"
 #include "Logging.h"
 #include "NetworkContentRuleListManagerMessages.h"
 #include "NetworkProcessConnectionInfo.h"
@@ -48,6 +50,7 @@
 #include "ShouldGrandfatherStatistics.h"
 #include "StorageAccessStatus.h"
 #include "WebCompiledContentRuleList.h"
+#include "WebCookieManagerProxy.h"
 #include "WebPageMessages.h"
 #include "WebPageProxy.h"
 #include "WebProcessMessages.h"
 #include "WebUserContentControllerProxy.h"
 #include "WebsiteData.h"
 #include "WebsiteDataStoreClient.h"
+#include "WebsiteDataStoreParameters.h"
 #include <WebCore/ClientOrigin.h>
 #include <WebCore/RegistrableDomain.h>
+#include <wtf/CallbackAggregator.h>
 #include <wtf/CompletionHandler.h>
 
 #if ENABLE(SEC_ITEM_SHIM)
 #include <wtf/spi/darwin/XPCSPI.h>
 #endif
 
+#if PLATFORM(COCOA)
+#include "LegacyCustomProtocolManagerClient.h"
+#endif
+
 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, connection())
 
 namespace WebKit {
 using namespace WebCore;
 
-NetworkProcessProxy::NetworkProcessProxy(WebProcessPool& processPool)
-    : AuxiliaryProcessProxy(processPool.alwaysRunsAtBackgroundPriority())
-    , m_processPool(processPool)
+static HashSet<NetworkProcessProxy*>& networkProcessesSet()
+{
+    RELEASE_ASSERT(RunLoop::isMain());
+    static NeverDestroyed<HashSet<NetworkProcessProxy*>> set;
+    return set;
+}
+
+Vector<Ref<NetworkProcessProxy>> NetworkProcessProxy::allNetworkProcesses()
+{
+    Vector<Ref<NetworkProcessProxy>> processes;
+    processes.reserveInitialCapacity(networkProcessesSet().size());
+    for (auto* networkProcess : networkProcessesSet())
+        processes.uncheckedAppend(*networkProcess);
+    return processes;
+}
+
+static RefPtr<NetworkProcessProxy>& defaultProcess()
+{
+    static NeverDestroyed<RefPtr<NetworkProcessProxy>> process;
+    return process.get();
+}
+
+Ref<NetworkProcessProxy> NetworkProcessProxy::defaultNetworkProcess()
+{
+    if (!defaultProcess())
+        defaultProcess() = NetworkProcessProxy::create();
+    return *defaultProcess();
+}
+
+void NetworkProcessProxy::terminate()
+{
+    AuxiliaryProcessProxy::terminate();
+    if (auto* connection = this->connection())
+        connection->invalidate();
+    didTerminate();
+}
+
+void NetworkProcessProxy::didTerminate()
+{
+    if (this == defaultProcess().get())
+        defaultProcess() = nullptr;
+}
+
+void NetworkProcessProxy::sendCreationParametersToNewProcess()
+{
+    ASSERT(RunLoop::isMain());
+
+    // FIXME: This is a temporary workaround for apps using WebKit API on non-main threads.
+    // We should remove this once we enforce threading violation check on our APIs.
+    // https://bugs.webkit.org/show_bug.cgi?id=200246.
+    if (!RunLoop::isMain()) {
+        callOnMainRunLoopAndWait([this] {
+            sendCreationParametersToNewProcess();
+        });
+    }
+
+    NetworkProcessCreationParameters parameters;
+    parameters.urlSchemesRegisteredAsSecure = copyToVector(LegacyGlobalSettings::singleton().schemesToRegisterAsSecure());
+    parameters.urlSchemesRegisteredAsBypassingContentSecurityPolicy = copyToVector(LegacyGlobalSettings::singleton().schemesToRegisterAsBypassingContentSecurityPolicy());
+    parameters.urlSchemesRegisteredAsLocal = copyToVector(LegacyGlobalSettings::singleton().schemesToRegisterAsLocal());
+    parameters.urlSchemesRegisteredAsNoAccess = copyToVector(LegacyGlobalSettings::singleton().schemesToRegisterAsNoAccess());
+    parameters.cacheModel = LegacyGlobalSettings::singleton().cacheModel();
+    for (auto& scheme : WebProcessPool::urlSchemesWithCustomProtocolHandlers())
+        parameters.urlSchemesRegisteredForCustomProtocols.append(scheme);
+#if PLATFORM(IOS_FAMILY)
+    if (String cookieStorageDirectory = WebProcessPool::cookieStorageDirectory(); !cookieStorageDirectory.isEmpty())
+        SandboxExtension::createHandleForReadWriteDirectory(cookieStorageDirectory, parameters.cookieStorageDirectoryExtensionHandle);
+    if (String containerCachesDirectory = WebProcessPool::networkingCachesDirectory(); !containerCachesDirectory.isEmpty())
+        SandboxExtension::createHandleForReadWriteDirectory(containerCachesDirectory, parameters.containerCachesDirectoryExtensionHandle);
+    if (String parentBundleDirectory = WebProcessPool::parentBundleDirectory(); !parentBundleDirectory.isEmpty())
+        SandboxExtension::createHandle(parentBundleDirectory, SandboxExtension::Type::ReadOnly, parameters.parentBundleDirectoryExtensionHandle);
+#endif
+    WebProcessPool::platformInitializeNetworkProcess(parameters);
+    send(Messages::NetworkProcess::InitializeNetworkProcess(parameters), 0);
+}
+
+static bool anyProcessPoolAlwaysRunsAtBackgroundPriority()
+{
+    for (auto* processPool : WebProcessPool::allProcessPools()) {
+        if (processPool->alwaysRunsAtBackgroundPriority())
+            return true;
+    }
+    return false;
+}
+
+static bool anyProcessPoolShouldTakeUIBackgroundAssertion()
+{
+    for (auto* processPool : WebProcessPool::allProcessPools()) {
+        if (processPool->shouldTakeUIBackgroundAssertion())
+            return true;
+    }
+    return false;
+}
+
+NetworkProcessProxy::NetworkProcessProxy()
+    : AuxiliaryProcessProxy(anyProcessPoolAlwaysRunsAtBackgroundPriority())
 #if ENABLE(LEGACY_CUSTOM_PROTOCOL_MANAGER)
+    , m_customProtocolManagerClient(makeUniqueRef<LegacyCustomProtocolManagerClient>())
     , m_customProtocolManagerProxy(*this)
+#else
+    , m_customProtocolManagerClient(makeUniqueRef<API::CustomProtocolManagerClient>())
 #endif
-    , m_throttler(*this, processPool.shouldTakeUIBackgroundAssertion())
+    , m_throttler(*this, anyProcessPoolShouldTakeUIBackgroundAssertion())
+    , m_cookieManager(WebCookieManagerProxy::create(*this))
 {
     connect();
+    sendCreationParametersToNewProcess();
+    updateProcessAssertion();
+    networkProcessesSet().add(this);
 }
 
 NetworkProcessProxy::~NetworkProcessProxy()
@@ -98,6 +207,7 @@ NetworkProcessProxy::~NetworkProcessProxy()
 
     if (m_downloadProxyMap)
         m_downloadProxyMap->invalidate();
+    networkProcessesSet().remove(this);
 }
 
 void NetworkProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)
@@ -105,15 +215,8 @@ void NetworkProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launc
     launchOptions.processType = ProcessLauncher::ProcessType::Network;
     AuxiliaryProcessProxy::getLaunchOptions(launchOptions);
 
-    if (processPool().shouldMakeNextNetworkProcessLaunchFailForTesting()) {
-        processPool().setShouldMakeNextNetworkProcessLaunchFailForTesting(false);
+    if (WebsiteDataStore::shouldMakeNextNetworkProcessLaunchFailForTesting())
         launchOptions.shouldMakeProcessLaunchFailForTesting = true;
-    }
-
-#if PLATFORM(PLAYSTATION)
-    launchOptions.processPath = m_processPool.networkProcessPath();
-    launchOptions.userId = m_processPool.userId();
-#endif
 }
 
 void NetworkProcessProxy::connectionWillOpen(IPC::Connection& connection)
@@ -166,12 +269,12 @@ void NetworkProcessProxy::synthesizeAppIsBackground(bool background)
     }
 }
 
-DownloadProxy& NetworkProcessProxy::createDownloadProxy(WebsiteDataStore& dataStore, const ResourceRequest& resourceRequest, const FrameInfoData& frameInfo, WebPageProxy* originatingPage)
+DownloadProxy& NetworkProcessProxy::createDownloadProxy(WebsiteDataStore& dataStore, WebProcessPool& processPool, const ResourceRequest& resourceRequest, const FrameInfoData& frameInfo, WebPageProxy* originatingPage)
 {
     if (!m_downloadProxyMap)
         m_downloadProxyMap = makeUnique<DownloadProxyMap>(*this);
 
-    return m_downloadProxyMap->createDownloadProxy(dataStore, m_processPool, resourceRequest, frameInfo, originatingPage);
+    return m_downloadProxyMap->createDownloadProxy(dataStore, processPool, resourceRequest, frameInfo, originatingPage);
 }
 
 void NetworkProcessProxy::fetchWebsiteData(PAL::SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, CompletionHandler<void (WebsiteData)>&& completionHandler)
@@ -237,8 +340,11 @@ void NetworkProcessProxy::networkProcessCrashed()
 {
     clearCallbackStates();
 
-    // Tell the network process manager to forget about this network process proxy. This will cause us to be deleted.
-    m_processPool.networkProcessCrashed(*this);
+    Ref<NetworkProcessProxy> protectedThis(*this);
+    for (auto* processPool : WebProcessPool::allProcessPools())
+        processPool->networkProcessCrashed(*this);
+    for (auto& websiteDataStore : m_websiteDataStores)
+        websiteDataStore.networkProcessCrashed(*this);
 }
 
 void NetworkProcessProxy::clearCallbackStates()
@@ -258,9 +364,6 @@ void NetworkProcessProxy::didReceiveMessage(IPC::Connection& connection, IPC::De
     if (dispatchMessage(connection, decoder))
         return;
 
-    if (m_processPool.dispatchMessage(connection, decoder))
-        return;
-
     didReceiveNetworkProcessProxyMessage(connection, decoder);
 }
 
@@ -274,8 +377,6 @@ void NetworkProcessProxy::didReceiveSyncMessage(IPC::Connection& connection, IPC
 
 void NetworkProcessProxy::didClose(IPC::Connection&)
 {
-    auto protectedProcessPool = makeRef(m_processPool);
-
     if (m_downloadProxyMap)
         m_downloadProxyMap->invalidate();
 #if ENABLE(LEGACY_CUSTOM_PROTOCOL_MANAGER)
@@ -331,11 +432,6 @@ void NetworkProcessProxy::didReceiveAuthenticationChallenge(PAL::SessionID sessi
         return;
     }
 
-    if (!topOrigin || !m_processPool.isServiceWorkerPageID(pageID)) {
-        processAuthenticationChallenge(sessionID, WTFMove(authenticationChallenge));
-        return;
-    }
-
     WebPageProxy::forMostVisibleWebPageIfAny(sessionID, *topOrigin, [this, weakThis = makeWeakPtr(this), sessionID, authenticationChallenge = WTFMove(authenticationChallenge), negotiatedLegacyTLS](auto* page) mutable {
         if (!weakThis)
             return;
@@ -392,11 +488,6 @@ void NetworkProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Con
         networkProcessCrashed();
         return;
     }
-
-#if PLATFORM(COCOA)
-    if (m_processPool.processSuppressionEnabled())
-        setProcessSuppressionEnabled(true);
-#endif
     
 #if PLATFORM(IOS_FAMILY)
     if (xpc_connection_t connection = this->connection()->xpcConnection())
@@ -1198,7 +1289,8 @@ void NetworkProcessProxy::setThirdPartyCNAMEDomainForTesting(PAL::SessionID sess
 }
 void NetworkProcessProxy::setDomainsWithUserInteraction(HashSet<WebCore::RegistrableDomain>&& domains)
 {
-    processPool().setDomainsWithUserInteraction(WTFMove(domains));
+    for (auto* processPool : WebProcessPool::allProcessPools())
+        processPool->setDomainsWithUserInteraction(HashSet<WebCore::RegistrableDomain> { domains });
 }
 #endif // ENABLE(RESOURCE_LOAD_STATISTICS)
 
@@ -1245,45 +1337,31 @@ void NetworkProcessProxy::flushCookies(const PAL::SessionID& sessionID, Completi
     sendWithAsyncReply(Messages::NetworkProcess::FlushCookies(sessionID), WTFMove(completionHandler));
 }
 
-void NetworkProcessProxy::addSession(Ref<WebsiteDataStore>&& store)
+void NetworkProcessProxy::addSession(WebsiteDataStore& store)
 {
-    m_sessionIDs.add(store->sessionID());
+    m_websiteDataStores.add(store);
 
     if (canSendMessage())
-        send(Messages::NetworkProcess::AddWebsiteDataStore { store->parameters() }, 0);
-    auto sessionID = store->sessionID();
+        send(Messages::NetworkProcess::AddWebsiteDataStore { store.parameters() }, 0);
+    auto sessionID = store.sessionID();
     if (!sessionID.isEphemeral()) {
 #if ENABLE(INDEXED_DATABASE)
-        createSymLinkForFileUpgrade(store->resolvedIndexedDatabaseDirectory());
+        createSymLinkForFileUpgrade(store.resolvedIndexedDatabaseDirectory());
 #endif
     }
 }
 
-bool NetworkProcessProxy::hasSession(PAL::SessionID sessionID) const
-{
-    return m_sessionIDs.contains(sessionID);
-}
-
-void NetworkProcessProxy::removeSession(PAL::SessionID sessionID)
+void NetworkProcessProxy::removeSession(WebsiteDataStore& websiteDataStore)
 {
-    m_sessionIDs.remove(sessionID);
+    m_websiteDataStores.remove(websiteDataStore);
 
     if (canSendMessage())
-        send(Messages::NetworkProcess::DestroySession { sessionID }, 0);
+        send(Messages::NetworkProcess::DestroySession { websiteDataStore.sessionID() }, 0);
 }
 
 WebsiteDataStore* NetworkProcessProxy::websiteDataStoreFromSessionID(PAL::SessionID sessionID)
 {
-    if (sessionID == PAL::SessionID::defaultSessionID()) {
-        if (!WebsiteDataStore::defaultDataStoreExists()) {
-            auto* websiteDataStore = m_processPool.websiteDataStore();
-            if (websiteDataStore && websiteDataStore->sessionID() == sessionID)
-                return websiteDataStore;
-        }
-
-        return WebsiteDataStore::defaultDataStore().ptr();
-    }
-    return WebsiteDataStore::existingNonDefaultDataStoreForSessionID(sessionID);
+    return WebsiteDataStore::existingDataStoreForSessionID(sessionID);
 }
 
 void NetworkProcessProxy::retrieveCacheStorageParameters(PAL::SessionID sessionID)
@@ -1330,7 +1408,7 @@ void NetworkProcessProxy::didDestroyWebUserContentControllerProxy(WebUserContent
 #if ENABLE(SERVICE_WORKER)
 void NetworkProcessProxy::establishWorkerContextConnectionToNetworkProcess(RegistrableDomain&& registrableDomain, PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
 {
-    m_processPool.establishWorkerContextConnectionToNetworkProcess(*this, WTFMove(registrableDomain), sessionID, WTFMove(completionHandler));
+    WebProcessPool::establishWorkerContextConnectionToNetworkProcess(*this, RegistrableDomain {registrableDomain}, sessionID, WTFMove(completionHandler));
 }
 
 void NetworkProcessProxy::workerContextConnectionNoLongerNeeded(WebCore::ProcessIdentifier identifier)
@@ -1493,16 +1571,34 @@ void NetworkProcessProxy::preconnectTo(PAL::SessionID sessionID, WebPageProxyIde
     send(Messages::NetworkProcess::PreconnectTo(sessionID, webPageProxyID, webPageID, url, userAgent, storedCredentialsPolicy, isNavigatingToAppBoundDomain), 0);
 }
 
+static bool anyProcessPoolHasForegroundWebProcesses()
+{
+    for (auto* processPool : WebProcessPool::allProcessPools()) {
+        if (processPool->hasForegroundWebProcesses())
+            return true;
+    }
+    return false;
+}
+
+static bool anyProcessPoolHasBackgroundWebProcesses()
+{
+    for (auto* processPool : WebProcessPool::allProcessPools()) {
+        if (processPool->hasBackgroundWebProcesses())
+            return true;
+    }
+    return false;
+}
+
 void NetworkProcessProxy::updateProcessAssertion()
 {
-    if (processPool().hasForegroundWebProcesses()) {
+    if (anyProcessPoolHasForegroundWebProcesses()) {
         if (!ProcessThrottler::isValidForegroundActivity(m_activityFromWebProcesses)) {
             m_activityFromWebProcesses = throttler().foregroundActivity("Networking for foreground view(s)"_s);
             send(Messages::NetworkProcess::ProcessDidTransitionToForeground(), 0);
         }
         return;
     }
-    if (processPool().hasBackgroundWebProcesses()) {
+    if (anyProcessPoolHasBackgroundWebProcesses()) {
         if (!ProcessThrottler::isValidBackgroundActivity(m_activityFromWebProcesses)) {
             m_activityFromWebProcesses = throttler().backgroundActivity("Networking for background view(s)"_s);
             send(Messages::NetworkProcess::ProcessDidTransitionToBackground(), 0);
index 590f56c..0022ee4 100644 (file)
 
 #if PLATFORM(COCOA)
 #include "XPCEventHandler.h"
+#include <wtf/OSObjectPtr.h>
 #endif
 
 namespace IPC {
 class FormDataReference;
 }
 
+namespace API {
+class CustomProtocolManagerClient;
+}
+
 namespace PAL {
 class SessionID;
 }
@@ -73,8 +78,8 @@ namespace WebKit {
 
 class DownloadProxy;
 class DownloadProxyMap;
+class WebCookieManagerProxy;
 class WebPageProxy;
-class WebProcessPool;
 class WebUserContentControllerProxy;
 
 enum class ShouldGrandfatherStatistics : bool;
@@ -86,8 +91,9 @@ struct FrameInfoData;
 struct NetworkProcessCreationParameters;
 struct ResourceLoadInfo;
 struct WebsiteData;
+struct WebsiteDataStoreParameters;
 
-class NetworkProcessProxy final : public AuxiliaryProcessProxy, private ProcessThrottlerClient, public CanMakeWeakPtr<NetworkProcessProxy> {
+class NetworkProcessProxy final : public AuxiliaryProcessProxy, private ProcessThrottlerClient, public CanMakeWeakPtr<NetworkProcessProxy>, public RefCounted<NetworkProcessProxy> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     using RegistrableDomain = WebCore::RegistrableDomain;
@@ -102,12 +108,18 @@ public:
     using DomainInNeedOfStorageAccess = WebCore::RegistrableDomain;
     using OpenerDomain = WebCore::RegistrableDomain;
 
-    explicit NetworkProcessProxy(WebProcessPool&);
+    static Ref<NetworkProcessProxy> defaultNetworkProcess();
+    static Ref<NetworkProcessProxy> create() { return adoptRef(*new NetworkProcessProxy); }
     ~NetworkProcessProxy();
 
+    static Vector<Ref<NetworkProcessProxy>> allNetworkProcesses();
+    
+    void terminate() final;
+    void didTerminate();
+
     void getNetworkProcessConnection(WebProcessProxy&, Messages::WebProcessProxy::GetNetworkProcessConnectionDelayedReply&&);
 
-    DownloadProxy& createDownloadProxy(WebsiteDataStore&, const WebCore::ResourceRequest&, const FrameInfoData&, WebPageProxy* originatingPage);
+    DownloadProxy& createDownloadProxy(WebsiteDataStore&, WebProcessPool&, const WebCore::ResourceRequest&, const FrameInfoData&, WebPageProxy* originatingPage);
 
     void fetchWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, CompletionHandler<void(WebsiteData)>&&);
     void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, CompletionHandler<void()>&& completionHandler);
@@ -205,15 +217,12 @@ public:
     ProcessThrottler& throttler() final { return m_throttler; }
     void updateProcessAssertion();
 
-    WebProcessPool& processPool() { return m_processPool; }
-
 #if ENABLE(CONTENT_EXTENSIONS)
     void didDestroyWebUserContentControllerProxy(WebUserContentControllerProxy&);
 #endif
 
-    void addSession(Ref<WebsiteDataStore>&&);
-    bool hasSession(PAL::SessionID) const;
-    void removeSession(PAL::SessionID);
+    void addSession(WebsiteDataStore&);
+    void removeSession(WebsiteDataStore&);
     
 #if ENABLE(INDEXED_DATABASE)
     void createSymLinkForFileUpgrade(const String& indexedDatabaseDirectory);
@@ -228,6 +237,8 @@ public:
     void registerSchemeForLegacyCustomProtocol(const String&);
     void unregisterSchemeForLegacyCustomProtocol(const String&);
 
+    void networkProcessCrashed();
+    
     void resetQuota(PAL::SessionID, CompletionHandler<void()>&&);
 
     void resourceLoadDidSendRequest(WebPageProxyIdentifier, ResourceLoadInfo&&, WebCore::ResourceRequest&&, Optional<IPC::FormDataReference>&&);
@@ -247,7 +258,19 @@ public:
     void updateBundleIdentifier(const String&, CompletionHandler<void()>&&);
     void clearBundleIdentifier(CompletionHandler<void()>&&);
 
+    WebCookieManagerProxy& cookieManager() { return m_cookieManager.get(); }
+
+    API::CustomProtocolManagerClient& customProtocolManagerClient() { return m_customProtocolManagerClient.get(); }
+
+#if PLATFORM(COCOA)
+    xpc_object_t xpcEndpointMessage() const { return m_endpointMessage.get(); }
+#endif
+
 private:
+    explicit NetworkProcessProxy();
+
+    void sendCreationParametersToNewProcess();
+
     // AuxiliaryProcessProxy
     ASCIILiteral processName() const final { return "Networking"_s; }
 
@@ -255,7 +278,6 @@ private:
     void connectionWillOpen(IPC::Connection&) override;
     void processWillShutDown(IPC::Connection&) override;
 
-    void networkProcessCrashed();
     void clearCallbackStates();
 
     // IPC::Connection::Client
@@ -311,16 +333,17 @@ private:
 
     void processAuthenticationChallenge(PAL::SessionID, Ref<AuthenticationChallengeProxy>&&);
 
-    WebProcessPool& m_processPool;
-
     HashMap<CallbackID, CompletionHandler<void(WebsiteData)>> m_pendingFetchWebsiteDataCallbacks;
     HashMap<CallbackID, CompletionHandler<void()>> m_pendingDeleteWebsiteDataCallbacks;
     HashMap<CallbackID, CompletionHandler<void()>> m_pendingDeleteWebsiteDataForOriginsCallbacks;
 
     std::unique_ptr<DownloadProxyMap> m_downloadProxyMap;
+
+    UniqueRef<API::CustomProtocolManagerClient> m_customProtocolManagerClient;
 #if ENABLE(LEGACY_CUSTOM_PROTOCOL_MANAGER)
     LegacyCustomProtocolManagerProxy m_customProtocolManagerProxy;
 #endif
+
     ProcessThrottler m_throttler;
     std::unique_ptr<ProcessThrottler::BackgroundActivity> m_activityForHoldingLockedFiles;
     ProcessThrottler::ActivityVariant m_activityFromWebProcesses;
@@ -346,9 +369,11 @@ private:
     private:
         WeakPtr<NetworkProcessProxy> m_networkProcess;
     };
+    OSObjectPtr<xpc_object_t> m_endpointMessage;
 #endif
 
-    HashSet<PAL::SessionID> m_sessionIDs;
+    WeakHashSet<WebsiteDataStore> m_websiteDataStores;
+    Ref<WebCookieManagerProxy> m_cookieManager;
 };
 
 } // namespace WebKit
index b8daedf..0e5faec 100644 (file)
@@ -51,8 +51,11 @@ bool NetworkProcessProxy::XPCEventHandler::handleXPCEvent(xpc_object_t event) co
     if (messageName.isEmpty())
         return false;
 
-    if (messageName == LaunchServicesDatabaseXPCConstants::xpcLaunchServicesDatabaseXPCEndpointMessageName)
-        m_networkProcess->processPool().sendNetworkProcessXPCEndpointToWebProcess(event);
+    if (messageName == LaunchServicesDatabaseXPCConstants::xpcLaunchServicesDatabaseXPCEndpointMessageName) {
+        m_networkProcess->m_endpointMessage = event;
+        for (auto& dataStore : m_networkProcess->m_websiteDataStores)
+            dataStore.sendNetworkProcessXPCEndpointToAllWebProcesses();
+    }
 
     return true;
 }
index cc526aa..085e7d2 100644 (file)
@@ -29,6 +29,7 @@
 #include "APIArray.h"
 #include "APISecurityOrigin.h"
 #include "NetworkProcessMessages.h"
+#include "NetworkProcessProxy.h"
 #include "OptionalCallbackID.h"
 #include "WebCookieManagerMessages.h"
 #include "WebCookieManagerProxyMessages.h"
 namespace WebKit {
 using namespace WebCore;
 
-const char* WebCookieManagerProxy::supplementName()
+WebCookieManagerProxy::WebCookieManagerProxy(NetworkProcessProxy& networkProcess)
+    : m_networkProcess(makeWeakPtr(networkProcess))
 {
-    return "WebCookieManagerProxy";
-}
-
-Ref<WebCookieManagerProxy> WebCookieManagerProxy::create(WebProcessPool* processPool)
-{
-    return adoptRef(*new WebCookieManagerProxy(processPool));
-}
-
-WebCookieManagerProxy::WebCookieManagerProxy(WebProcessPool* processPool)
-    : WebContextSupplement(processPool)
-{
-    WebContextSupplement::processPool()->addMessageReceiver(Messages::WebCookieManagerProxy::messageReceiverName(), *this);
+    networkProcess.addMessageReceiver(Messages::WebCookieManagerProxy::messageReceiverName(), *this);
 }
 
 WebCookieManagerProxy::~WebCookieManagerProxy()
 {
+    if (m_networkProcess)
+        m_networkProcess->removeMessageReceiver(Messages::WebCookieManagerProxy::messageReceiverName());
     ASSERT(m_cookieObservers.isEmpty());
 }
 
@@ -65,102 +58,84 @@ void WebCookieManagerProxy::initializeClient(const WKCookieManagerClientBase* cl
     m_client.initialize(client);
 }
 
-// WebContextSupplement
-
-void WebCookieManagerProxy::processPoolDestroyed()
-{
-    Vector<Observer*> observers;
-    for (auto& observerSet : m_cookieObservers.values()) {
-        for (auto* observer : observerSet)
-            observers.append(observer);
-    }
-
-    for (auto* observer : observers)
-        observer->managerDestroyed();
-
-    ASSERT(m_cookieObservers.isEmpty());
-}
-
-void WebCookieManagerProxy::processDidClose(WebProcessProxy*)
-{
-}
-
-void WebCookieManagerProxy::processDidClose(NetworkProcessProxy*)
-{
-}
-
-void WebCookieManagerProxy::refWebContextSupplement()
-{
-    API::Object::ref();
-}
-
-void WebCookieManagerProxy::derefWebContextSupplement()
-{
-    API::Object::deref();
-}
-
 void WebCookieManagerProxy::getHostnamesWithCookies(PAL::SessionID sessionID, CompletionHandler<void(Vector<String>&&)>&& callbackFunction)
 {
-    auto& networkProcess = processPool()->ensureNetworkProcess();
-    networkProcess.sendWithAsyncReply(Messages::WebCookieManager::GetHostnamesWithCookies(sessionID), WTFMove(callbackFunction));
+    if (m_networkProcess)
+        m_networkProcess->sendWithAsyncReply(Messages::WebCookieManager::GetHostnamesWithCookies(sessionID), WTFMove(callbackFunction));
+    else
+        callbackFunction({ });
 }
 
 void WebCookieManagerProxy::deleteCookiesForHostnames(PAL::SessionID sessionID, const Vector<String>& hostnames)
 {
-    processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteCookiesForHostnames(sessionID, hostnames));
+    if (m_networkProcess)
+        m_networkProcess->send(Messages::WebCookieManager::DeleteCookiesForHostnames(sessionID, hostnames), 0);
 }
 
 void WebCookieManagerProxy::deleteAllCookies(PAL::SessionID sessionID)
 {
-    processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::DeleteAllCookies(sessionID));
+    if (m_networkProcess)
+        m_networkProcess->send(Messages::WebCookieManager::DeleteAllCookies(sessionID), 0);
 }
 
 void WebCookieManagerProxy::deleteCookie(PAL::SessionID sessionID, const Cookie& cookie, CompletionHandler<void()>&& callbackFunction)
 {
-    auto& networkProcess = processPool()->ensureNetworkProcess();
-    networkProcess.sendWithAsyncReply(Messages::WebCookieManager::DeleteCookie(sessionID, cookie), [callbackFunction = WTFMove(callbackFunction)]() mutable {
+    if (m_networkProcess)
+        m_networkProcess->sendWithAsyncReply(Messages::WebCookieManager::DeleteCookie(sessionID, cookie), WTFMove(callbackFunction));
+    else
         callbackFunction();
-    });
 }
 
 void WebCookieManagerProxy::deleteAllCookiesModifiedSince(PAL::SessionID sessionID, WallTime time, CompletionHandler<void()>&& callbackFunction)
 {
-    auto& networkProcess = processPool()->ensureNetworkProcess();
-    networkProcess.sendWithAsyncReply(Messages::WebCookieManager::DeleteAllCookiesModifiedSince(sessionID, time), WTFMove(callbackFunction));
+    if (m_networkProcess)
+        m_networkProcess->sendWithAsyncReply(Messages::WebCookieManager::DeleteAllCookiesModifiedSince(sessionID, time), WTFMove(callbackFunction));
+    else
+        callbackFunction();
 }
 
 void WebCookieManagerProxy::setCookies(PAL::SessionID sessionID, const Vector<Cookie>& cookies, CompletionHandler<void()>&& callbackFunction)
 {
-    auto& networkProcess = processPool()->ensureNetworkProcess();
-    networkProcess.sendWithAsyncReply(Messages::WebCookieManager::SetCookie(sessionID, cookies), WTFMove(callbackFunction));
+    if (m_networkProcess)
+        m_networkProcess->sendWithAsyncReply(Messages::WebCookieManager::SetCookie(sessionID, cookies), WTFMove(callbackFunction));
+    else
+        callbackFunction();
 }
 
 void WebCookieManagerProxy::setCookies(PAL::SessionID sessionID, const Vector<Cookie>& cookies, const URL& url, const URL& mainDocumentURL, CompletionHandler<void()>&& callbackFunction)
 {
-    auto& networkProcess = processPool()->ensureNetworkProcess();
-    networkProcess.sendWithAsyncReply(Messages::WebCookieManager::SetCookies(sessionID, cookies, url, mainDocumentURL), WTFMove(callbackFunction));
+    if (m_networkProcess)
+        m_networkProcess->sendWithAsyncReply(Messages::WebCookieManager::SetCookies(sessionID, cookies, url, mainDocumentURL), WTFMove(callbackFunction));
+    else
+        callbackFunction();
 }
 
 void WebCookieManagerProxy::getAllCookies(PAL::SessionID sessionID, CompletionHandler<void(Vector<Cookie>&&)>&& callbackFunction)
 {
-    auto& networkProcess = processPool()->ensureNetworkProcess();
-    networkProcess.sendWithAsyncReply(Messages::WebCookieManager::GetAllCookies(sessionID), WTFMove(callbackFunction));
+    if (m_networkProcess)
+        m_networkProcess->sendWithAsyncReply(Messages::WebCookieManager::GetAllCookies(sessionID), WTFMove(callbackFunction));
+    else
+        callbackFunction({ });
 }
 
 void WebCookieManagerProxy::getCookies(PAL::SessionID sessionID, const URL& url, CompletionHandler<void(Vector<Cookie>&&)>&& callbackFunction)
 {
-    auto& networkProcess = processPool()->ensureNetworkProcess();
-    networkProcess.sendWithAsyncReply(Messages::WebCookieManager::GetCookies(sessionID, url), WTFMove(callbackFunction));
+    if (m_networkProcess)
+        m_networkProcess->sendWithAsyncReply(Messages::WebCookieManager::GetCookies(sessionID, url), WTFMove(callbackFunction));
+    else
+        callbackFunction({ });
 }
 
 void WebCookieManagerProxy::startObservingCookieChanges(PAL::SessionID sessionID)
 {
-    processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::StartObservingCookieChanges(sessionID));
+    if (m_networkProcess)
+        m_networkProcess->send(Messages::WebCookieManager::StartObservingCookieChanges(sessionID), 0);
 }
 
 void WebCookieManagerProxy::stopObservingCookieChanges(PAL::SessionID sessionID)
 {
-    processPool()->sendToNetworkingProcessRelaunchingIfNecessary(Messages::WebCookieManager::StopObservingCookieChanges(sessionID));
+    if (m_networkProcess)
+        m_networkProcess->send(Messages::WebCookieManager::StopObservingCookieChanges(sessionID), 0);
 }
 
 void WebCookieManagerProxy::setCookieObserverCallback(PAL::SessionID sessionID, WTF::Function<void ()>&& callback)
@@ -211,18 +186,18 @@ void WebCookieManagerProxy::cookiesDidChange(PAL::SessionID sessionID)
 
 void WebCookieManagerProxy::setHTTPCookieAcceptPolicy(PAL::SessionID, HTTPCookieAcceptPolicy policy, CompletionHandler<void()>&& callbackFunction)
 {
-#if USE(SOUP)
-    processPool()->setInitialHTTPCookieAcceptPolicy(policy);
-#endif
-
-    auto& networkProcess = processPool()->ensureNetworkProcess();
-    networkProcess.sendWithAsyncReply(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy), WTFMove(callbackFunction));
+    if (m_networkProcess)
+        m_networkProcess->sendWithAsyncReply(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy), WTFMove(callbackFunction));
+    else
+        callbackFunction();
 }
 
-void WebCookieManagerProxy::getHTTPCookieAcceptPolicy(PAL::SessionID, CompletionHandler<void(HTTPCookieAcceptPolicy)>&& callbackFunction)
+void WebCookieManagerProxy::getHTTPCookieAcceptPolicy(PAL::SessionID sessionID, CompletionHandler<void(HTTPCookieAcceptPolicy)>&& callbackFunction)
 {
-    auto& networkProcess = processPool()->ensureNetworkProcess();
-    networkProcess.sendWithAsyncReply(Messages::WebCookieManager::GetHTTPCookieAcceptPolicy(), WTFMove(callbackFunction));
+    if (m_networkProcess)
+        m_networkProcess->sendWithAsyncReply(Messages::WebCookieManager::GetHTTPCookieAcceptPolicy(sessionID), WTFMove(callbackFunction));
+    else
+        callbackFunction(HTTPCookieAcceptPolicy::Never);
 }
 
 } // namespace WebKit
index 0bdfc0d..6f51f03 100644 (file)
@@ -56,11 +56,9 @@ typedef GenericCallback<API::Array*> ArrayCallback;
 typedef GenericCallback<WebCore::HTTPCookieAcceptPolicy> HTTPCookieAcceptPolicyCallback;
 typedef GenericCallback<const Vector<WebCore::Cookie>&> GetCookiesCallback;
 
-class WebCookieManagerProxy : public API::ObjectImpl<API::Object::Type::CookieManager>, public WebContextSupplement, private IPC::MessageReceiver {
+class WebCookieManagerProxy : public API::ObjectImpl<API::Object::Type::CookieManager>, private IPC::MessageReceiver {
 public:
-    static const char* supplementName();
-
-    static Ref<WebCookieManagerProxy> create(WebProcessPool*);
+    static Ref<WebCookieManagerProxy> create(NetworkProcessProxy& networkProcess) { return adoptRef(*new WebCookieManagerProxy(networkProcess)); }
     virtual ~WebCookieManagerProxy();
 
     void initializeClient(const WKCookieManagerClientBase*);
@@ -104,17 +102,10 @@ public:
     using API::Object::deref;
 
 private:
-    WebCookieManagerProxy(WebProcessPool*);
+    WebCookieManagerProxy(NetworkProcessProxy&);
 
     void cookiesDidChange(PAL::SessionID);
 
-    // WebContextSupplement
-    void processPoolDestroyed() override;
-    void processDidClose(WebProcessProxy*) override;
-    void processDidClose(NetworkProcessProxy*) override;
-    void refWebContextSupplement() override;
-    void derefWebContextSupplement() override;
-
     // IPC::MessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 
@@ -125,6 +116,7 @@ private:
     HashMap<PAL::SessionID, WTF::Function<void ()>> m_legacyCookieObservers;
     HashMap<PAL::SessionID, HashSet<Observer*>> m_cookieObservers;
 
+    WeakPtr<NetworkProcessProxy> m_networkProcess;
     WebCookieManagerProxyClient m_client;
 
 #if USE(SOUP)
index 5289623..dd17f21 100644 (file)
@@ -1746,7 +1746,7 @@ void WebPageProxy::setControlledByAutomation(bool controlled)
         return;
 
     send(Messages::WebPage::SetControlledByAutomation(controlled));
-    m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::SetSessionIsControlledByAutomation(m_websiteDataStore->sessionID(), m_controlledByAutomation));
+    websiteDataStore().networkProcess().send(Messages::NetworkProcess::SetSessionIsControlledByAutomation(m_websiteDataStore->sessionID(), m_controlledByAutomation), 0);
 }
 
 void WebPageProxy::createInspectorTarget(const String& targetId, Inspector::InspectorTargetType type)
@@ -3207,11 +3207,7 @@ void WebPageProxy::isForcedIntoAppBoundModeTesting(CompletionHandler<void(bool)>
 void WebPageProxy::disableServiceWorkerEntitlementInNetworkProcess()
 {
 #if ENABLE(APP_BOUND_DOMAINS) && !PLATFORM(MACCATALYST)
-    if (auto* networkProcess = m_process->processPool().networkProcess()) {
-        if (!networkProcess->canSendMessage())
-            return;
-        networkProcess->send(Messages::NetworkProcess::DisableServiceWorkerEntitlement(), 0);
-    }
+    websiteDataStore().networkProcess().send(Messages::NetworkProcess::DisableServiceWorkerEntitlement(), 0);
 #endif
 }
 
@@ -3220,13 +3216,7 @@ void WebPageProxy::clearServiceWorkerEntitlementOverride(CompletionHandler<void(
 #if ENABLE(APP_BOUND_DOMAINS) && !PLATFORM(MACCATALYST)
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     sendWithAsyncReply(Messages::WebPage::ClearServiceWorkerEntitlementOverride(), [callbackAggregator] { });
-    if (auto* networkProcess = m_process->processPool().networkProcess()) {
-        if (!networkProcess->canSendMessage()) {
-            completionHandler();
-            return;
-        }
-        networkProcess->sendWithAsyncReply(Messages::NetworkProcess::ClearServiceWorkerEntitlementOverride(), [callbackAggregator] { });
-    }
+    websiteDataStore().networkProcess().sendWithAsyncReply(Messages::NetworkProcess::ClearServiceWorkerEntitlementOverride(), [callbackAggregator] { });
 #else
     completionHandler();
 #endif
@@ -4420,7 +4410,7 @@ void WebPageProxy::preconnectTo(const URL& url)
         return;
 
     auto storedCredentialsPolicy = m_canUseCredentialStorage ? WebCore::StoredCredentialsPolicy::Use : WebCore::StoredCredentialsPolicy::DoNotUse;
-    m_process->processPool().ensureNetworkProcess().preconnectTo(sessionID(), identifier(), webPageID(), url, userAgent(), storedCredentialsPolicy, isNavigatingToAppBoundDomain());
+    websiteDataStore().networkProcess().preconnectTo(sessionID(), identifier(), webPageID(), url, userAgent(), storedCredentialsPolicy, isNavigatingToAppBoundDomain());
 }
 
 void WebPageProxy::setCanUseCredentialStorage(bool canUseCredentialStorage)
@@ -4716,7 +4706,7 @@ void WebPageProxy::didCommitLoadForFrame(FrameIdentifier frameID, FrameInfoData&
             RegistrableDomain currentDomain { currentRequest.url() };
             URL requesterURL { URL(), requesterOrigin.toString() };
             if (!currentDomain.matches(requesterURL))
-                m_process->processPool().didCommitCrossSiteLoadWithDataTransfer(m_websiteDataStore->sessionID(), RegistrableDomain { requesterURL }, currentDomain, navigationDataTransfer, m_identifier, m_webPageID);
+                m_websiteDataStore->networkProcess().didCommitCrossSiteLoadWithDataTransfer(m_websiteDataStore->sessionID(), RegistrableDomain { requesterURL }, currentDomain, navigationDataTransfer, m_identifier, m_webPageID);
         }
 #endif
     }
@@ -4754,7 +4744,7 @@ void WebPageProxy::didCommitLoadForFrame(FrameIdentifier frameID, FrameInfoData&
     if (navigation && frame->isMainFrame()) {
         if (auto& adClickAttribution = navigation->adClickAttribution()) {
             if (adClickAttribution->destination().matches(frame->url()))
-                m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::StoreAdClickAttribution(m_websiteDataStore->sessionID(), *adClickAttribution));
+                websiteDataStore().networkProcess().send(Messages::NetworkProcess::StoreAdClickAttribution(m_websiteDataStore->sessionID(), *adClickAttribution), 0);
         }
     }
 
@@ -5368,7 +5358,7 @@ void WebPageProxy::logFrameNavigation(const WebFrameProxy& frame, const URL& pag
     if (targetHost.isEmpty() || mainFrameHost.isEmpty() || targetHost == sourceURL.host())
         return;
 
-    m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::LogFrameNavigation(m_websiteDataStore->sessionID(), RegistrableDomain { targetURL }, RegistrableDomain { pageURL }, RegistrableDomain { sourceURL }, isRedirect, frame.isMainFrame(), MonotonicTime::now() - m_didFinishDocumentLoadForMainFrameTimestamp, wasPotentiallyInitiatedByUser));
+    websiteDataStore().networkProcess().send(Messages::NetworkProcess::LogFrameNavigation(m_websiteDataStore->sessionID(), RegistrableDomain { targetURL }, RegistrableDomain { pageURL }, RegistrableDomain { sourceURL }, isRedirect, frame.isMainFrame(), MonotonicTime::now() - m_didFinishDocumentLoadForMainFrameTimestamp, wasPotentiallyInitiatedByUser), 0);
 }
 #endif
 
@@ -9993,58 +9983,27 @@ void WebPageProxy::systemPreviewActionTriggered(const WebCore::SystemPreviewInfo
 
 void WebPageProxy::dumpAdClickAttribution(CompletionHandler<void(const String&)>&& completionHandler)
 {
-    if (auto* networkProcess = m_process->processPool().networkProcess()) {
-        if (!networkProcess->canSendMessage()) {
-            completionHandler(emptyString());
-            return;
-        }
-        networkProcess->sendWithAsyncReply(Messages::NetworkProcess::DumpAdClickAttribution(m_websiteDataStore->sessionID()), WTFMove(completionHandler));
-    }
+    websiteDataStore().networkProcess().sendWithAsyncReply(Messages::NetworkProcess::DumpAdClickAttribution(m_websiteDataStore->sessionID()), WTFMove(completionHandler));
 }
 
 void WebPageProxy::clearAdClickAttribution(CompletionHandler<void()>&& completionHandler)
 {
-    if (auto* networkProcess = m_process->processPool().networkProcess()) {
-        if (!networkProcess->canSendMessage()) {
-            completionHandler();
-            return;
-        }
-        networkProcess->sendWithAsyncReply(Messages::NetworkProcess::ClearAdClickAttribution(m_websiteDataStore->sessionID()), WTFMove(completionHandler));
-    } else
-        completionHandler();
+    websiteDataStore().networkProcess().sendWithAsyncReply(Messages::NetworkProcess::ClearAdClickAttribution(m_websiteDataStore->sessionID()), WTFMove(completionHandler));
 }
 
 void WebPageProxy::setAdClickAttributionOverrideTimerForTesting(bool value, CompletionHandler<void()>&& completionHandler)
 {
-    if (auto* networkProcess = m_process->processPool().networkProcess()) {
-        if (!networkProcess->canSendMessage()) {
-            completionHandler();
-            return;
-        }
-        networkProcess->sendWithAsyncReply(Messages::NetworkProcess::SetAdClickAttributionOverrideTimerForTesting(m_websiteDataStore->sessionID(), value), WTFMove(completionHandler));
-    }
+    websiteDataStore().networkProcess().sendWithAsyncReply(Messages::NetworkProcess::SetAdClickAttributionOverrideTimerForTesting(m_websiteDataStore->sessionID(), value), WTFMove(completionHandler));
 }
 
 void WebPageProxy::setAdClickAttributionConversionURLForTesting(const URL& url, CompletionHandler<void()>&& completionHandler)
 {
-    if (auto* networkProcess = m_process->processPool().networkProcess()) {
-        if (!networkProcess->canSendMessage()) {
-            completionHandler();
-            return;
-        }
-        networkProcess->sendWithAsyncReply(Messages::NetworkProcess::SetAdClickAttributionConversionURLForTesting(m_websiteDataStore->sessionID(), url), WTFMove(completionHandler));
-    }
+    websiteDataStore().networkProcess().sendWithAsyncReply(Messages::NetworkProcess::SetAdClickAttributionConversionURLForTesting(m_websiteDataStore->sessionID(), url), WTFMove(completionHandler));
 }
 
 void WebPageProxy::markAdClickAttributionsAsExpiredForTesting(CompletionHandler<void()>&& completionHandler)
 {
-    if (auto* networkProcess = m_process->processPool().networkProcess()) {
-        if (!networkProcess->canSendMessage()) {
-            completionHandler();
-            return;
-        }
-        networkProcess->sendWithAsyncReply(Messages::NetworkProcess::MarkAdClickAttributionsAsExpiredForTesting(m_websiteDataStore->sessionID()), WTFMove(completionHandler));
-    }
+    websiteDataStore().networkProcess().sendWithAsyncReply(Messages::NetworkProcess::MarkAdClickAttributionsAsExpiredForTesting(m_websiteDataStore->sessionID()), WTFMove(completionHandler));
 }
 
 #if ENABLE(SPEECH_SYNTHESIS)
index d926b33..71f1f63 100644 (file)
@@ -45,7 +45,6 @@
 #include "LegacyGlobalSettings.h"
 #include "LogInitialization.h"
 #include "Logging.h"
-#include "NetworkProcessConnectionInfo.h"
 #include "NetworkProcessCreationParameters.h"
 #include "NetworkProcessMessages.h"
 #include "NetworkProcessProxy.h"
 #endif
 
 #define WEBPROCESSPOOL_RELEASE_LOG(channel, fmt, ...) RELEASE_LOG(channel, "%p - WebProcessPool::" fmt, this, ##__VA_ARGS__)
+#define WEBPROCESSPOOL_RELEASE_LOG_STATIC(channel, fmt, ...) RELEASE_LOG(channel, "WebProcessPool::" fmt, ##__VA_ARGS__)
 #define WEBPROCESSPOOL_RELEASE_LOG_ERROR(channel, fmt, ...) RELEASE_LOG_ERROR(channel, "%p - WebProcessPool::" fmt, this, ##__VA_ARGS__)
 #define WEBPROCESSPOOL_RELEASE_LOG_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), channel, "%p - WebProcessPool::" fmt, this, ##__VA_ARGS__)
+#define WEBPROCESSPOOL_RELEASE_LOG_IF_ALLOWED_STATIC(channel, fmt, ...) RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), channel, "WebProcessPool::" fmt, ##__VA_ARGS__)
 
 namespace WebKit {
 using namespace WebCore;
@@ -232,6 +233,11 @@ static HashSet<String, ASCIICaseInsensitiveHash>& globalURLSchemesWithCustomProt
     return set;
 }
 
+Vector<String> WebProcessPool::urlSchemesWithCustomProtocolHandlers()
+{
+    return copyToVector(globalURLSchemesWithCustomProtocolHandlers());
+}
+
 WebProcessPool::WebProcessPool(API::ProcessPoolConfiguration& configuration)
     : m_configuration(configuration.copy())
     , m_defaultPageGroup(WebPageGroup::create())
@@ -239,7 +245,6 @@ WebProcessPool::WebProcessPool(API::ProcessPoolConfiguration& configuration)
     , m_automationClient(makeUnique<API::AutomationClient>())
     , m_downloadClient(makeUniqueRef<API::DownloadClient>())
     , m_historyClient(makeUnique<API::LegacyContextHistoryClient>())
-    , m_customProtocolManagerClient(makeUnique<API::CustomProtocolManagerClient>())
     , m_visitedLinkStore(VisitedLinkStore::create())
 #if PLATFORM(MAC)
     , m_highPerformanceGraphicsUsageSampler(makeUnique<HighPerformanceGraphicsUsageSampler>(*this))
@@ -267,9 +272,6 @@ WebProcessPool::WebProcessPool(API::ProcessPoolConfiguration& configuration)
 #endif
     });
 
-    if (!m_websiteDataStore && WebKit::WebsiteDataStore::defaultDataStoreExists())
-        m_websiteDataStore = WebKit::WebsiteDataStore::defaultDataStore();
-
     for (auto& scheme : m_configuration->alwaysRevalidatedURLSchemes())
         m_schemesToRegisterAsAlwaysRevalidated.add(scheme);
 
@@ -285,7 +287,6 @@ WebProcessPool::WebProcessPool(API::ProcessPoolConfiguration& configuration)
     addMessageReceiver(Messages::WebProcessPool::messageReceiverName(), *this);
 
     // NOTE: These sub-objects must be initialized after m_messageReceiverMap..
-    addSupplement<WebCookieManagerProxy>();
     addSupplement<WebGeolocationManagerProxy>();
     addSupplement<WebNotificationManagerProxy>();
 #if ENABLE(MEDIA_SESSION)
@@ -342,9 +343,6 @@ WebProcessPool::~WebProcessPool()
     processPoolCounter.decrement();
 #endif
 
-    if (m_networkProcess)
-        m_networkProcess->shutDownProcess();
-
 #if ENABLE(GAMEPAD)
     if (!m_processesUsingGamepads.isEmpty())
         UIGamepadProvider::singleton().processPoolStoppedUsingGamepads(*this);
@@ -402,16 +400,6 @@ void WebProcessPool::setAutomationClient(std::unique_ptr<API::AutomationClient>&
         m_automationClient = WTFMove(automationClient);
 }
 
-void WebProcessPool::setLegacyCustomProtocolManagerClient(std::unique_ptr<API::CustomProtocolManagerClient>&& customProtocolManagerClient)
-{
-#if ENABLE(LEGACY_CUSTOM_PROTOCOL_MANAGER)
-    if (!customProtocolManagerClient)
-        m_customProtocolManagerClient = makeUnique<API::CustomProtocolManagerClient>();
-    else
-        m_customProtocolManagerClient = WTFMove(customProtocolManagerClient);
-#endif
-}
-
 void WebProcessPool::setCustomWebContentServiceBundleIdentifier(const String& customWebContentServiceBundleIdentifier)
 {
     // Guard against API misuse.
@@ -421,11 +409,6 @@ void WebProcessPool::setCustomWebContentServiceBundleIdentifier(const String& cu
     m_configuration->setCustomWebContentServiceBundleIdentifier(customWebContentServiceBundleIdentifier);
 }
 
-IPC::Connection* WebProcessPool::networkingProcessConnection()
-{
-    return m_networkProcess->connection();
-}
-
 void WebProcessPool::languageChanged(void* context)
 {
     static_cast<WebProcessPool*>(context)->languageChanged();
@@ -435,8 +418,7 @@ void WebProcessPool::languageChanged()
 {
     sendToAllProcesses(Messages::WebProcess::UserPreferredLanguagesChanged());
 #if USE(SOUP)
-    if (m_networkProcess)
-        m_networkProcess->send(Messages::NetworkProcess::UserPreferredLanguagesChanged(userPreferredLanguages()), 0);
+    WebsiteDataStore::defaultDataStore()->networkProcess().send(Messages::NetworkProcess::UserPreferredLanguagesChanged(userPreferredLanguages()), 0);
 #endif
 }
 
@@ -449,7 +431,8 @@ void WebProcessPool::fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnable
 void WebProcessPool::sendMemoryPressureEvent(bool isCritical)
 {
     sendToAllProcesses(Messages::AuxiliaryProcess::DidReceiveMemoryPressureEvent(isCritical));
-    sendToNetworkingProcess(Messages::AuxiliaryProcess::DidReceiveMemoryPressureEvent(isCritical));
+    for (auto networkProcess : NetworkProcessProxy::allNetworkProcesses())
+        networkProcess->send(Messages::AuxiliaryProcess::DidReceiveMemoryPressureEvent(isCritical), 0);
 #if ENABLE(NETSCAPE_PLUGIN_API)
     PluginProcessManager::singleton().sendMemoryPressureEvent(isCritical);
 #endif
@@ -474,275 +457,8 @@ void WebProcessPool::screenPropertiesStateChanged()
 #endif
 }
 
-NetworkProcessProxy& WebProcessPool::ensureNetworkProcess(WebsiteDataStore* withWebsiteDataStore)
-{
-    ASSERT(RunLoop::isMain());
-    
-    // FIXME: This is a temporary workaround for apps using WebKit API on non-main threads.
-    // We should remove this once we enforce threading violation check on our APIs.
-    // https://bugs.webkit.org/show_bug.cgi?id=200246.
-    if (!RunLoop::isMain()) {
-        callOnMainRunLoopAndWait([this, protectedThis = makeRef(*this)] {
-            ensureNetworkProcess();
-        });
-        return *m_networkProcess;
-    }
-
-    if (m_networkProcess) {
-        if (withWebsiteDataStore) {
-            m_networkProcess->addSession(makeRef(*withWebsiteDataStore));
-            withWebsiteDataStore->clearPendingCookies();
-        }
-        return *m_networkProcess;
-    }
-
-    auto networkProcess = makeUnique<NetworkProcessProxy>(*this);
-
-    NetworkProcessCreationParameters parameters;
-
-    if (m_websiteDataStore) {
-        parameters.defaultDataStoreParameters.pendingCookies = copyToVector(m_websiteDataStore->pendingCookies());
-        m_websiteDataStore->clearPendingCookies();
-#if PLATFORM(COCOA)
-        parameters.defaultDataStoreParameters.networkSessionParameters.sourceApplicationBundleIdentifier = m_websiteDataStore->configuration().sourceApplicationBundleIdentifier();
-        parameters.defaultDataStoreParameters.networkSessionParameters.sourceApplicationSecondaryIdentifier = m_websiteDataStore->configuration().sourceApplicationSecondaryIdentifier();
-#endif
-    }
-
-    parameters.cacheModel = LegacyGlobalSettings::singleton().cacheModel();
-
-    for (auto& scheme : globalURLSchemesWithCustomProtocolHandlers())
-        parameters.urlSchemesRegisteredForCustomProtocols.append(scheme);
-
-#if PLATFORM(IOS_FAMILY)
-    String cookieStorageDirectory = WebProcessPool::cookieStorageDirectory();
-    if (!cookieStorageDirectory.isEmpty())
-        SandboxExtension::createHandleForReadWriteDirectory(cookieStorageDirectory, parameters.cookieStorageDirectoryExtensionHandle);
-
-    String containerCachesDirectory = WebProcessPool::networkingCachesDirectory();
-    if (!containerCachesDirectory.isEmpty())
-        SandboxExtension::createHandleForReadWriteDirectory(containerCachesDirectory, parameters.containerCachesDirectoryExtensionHandle);
-
-    String parentBundleDirectory = WebProcessPool::parentBundleDirectory();
-    if (!parentBundleDirectory.isEmpty())
-        SandboxExtension::createHandle(parentBundleDirectory, SandboxExtension::Type::ReadOnly, parameters.parentBundleDirectoryExtensionHandle);
-
-#if ENABLE(INDEXED_DATABASE)
-    SandboxExtension::createHandleForTemporaryFile(emptyString(), SandboxExtension::Type::ReadWrite, parameters.defaultDataStoreParameters.indexedDatabaseTempBlobDirectoryExtensionHandle);
-#endif
-#endif
-
-    parameters.urlSchemesRegisteredAsSecure = copyToVector(LegacyGlobalSettings::singleton().schemesToRegisterAsSecure());
-    parameters.urlSchemesRegisteredAsBypassingContentSecurityPolicy = copyToVector(LegacyGlobalSettings::singleton().schemesToRegisterAsBypassingContentSecurityPolicy());
-    parameters.urlSchemesRegisteredAsLocal = copyToVector(LegacyGlobalSettings::singleton().schemesToRegisterAsLocal());
-    parameters.urlSchemesRegisteredAsNoAccess = copyToVector(LegacyGlobalSettings::singleton().schemesToRegisterAsNoAccess());
-
-#if ENABLE(INDEXED_DATABASE)
-    // *********
-    // IMPORTANT: Do not change the directory structure for indexed databases on disk without first consulting a reviewer from Apple (<rdar://problem/17454712>)
-    // *********
-    if (m_websiteDataStore)
-        parameters.defaultDataStoreParameters.indexedDatabaseDirectory = m_websiteDataStore->resolvedIndexedDatabaseDirectory();
-    else if (WebKit::WebsiteDataStore::defaultDataStoreExists())
-        parameters.defaultDataStoreParameters.indexedDatabaseDirectory = WebKit::WebsiteDataStore::defaultDataStore()->parameters().indexedDatabaseDirectory;
-    
-    if (!parameters.defaultDataStoreParameters.indexedDatabaseDirectory.isEmpty()) {
-        SandboxExtension::createHandleForReadWriteDirectory(parameters.defaultDataStoreParameters.indexedDatabaseDirectory, parameters.defaultDataStoreParameters.indexedDatabaseDirectoryExtensionHandle);
-        networkProcess->createSymLinkForFileUpgrade(parameters.defaultDataStoreParameters.indexedDatabaseDirectory);
-    }
-#endif
-
-#if ENABLE(SERVICE_WORKER)
-    if (m_websiteDataStore)
-        parameters.serviceWorkerRegistrationDirectory = m_websiteDataStore->resolvedServiceWorkerRegistrationDirectory();
-    if (!parameters.serviceWorkerRegistrationDirectory)
-        parameters.serviceWorkerRegistrationDirectory =  WebKit::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory();
-    SandboxExtension::createHandleForReadWriteDirectory(parameters.serviceWorkerRegistrationDirectory, parameters.serviceWorkerRegistrationDirectoryExtensionHandle);
-#endif
-
-    auto localStorageDirectory = m_websiteDataStore ? m_websiteDataStore->resolvedLocalStorageDirectory() : nullString();
-    if (!localStorageDirectory)
-        localStorageDirectory = WebKit::WebsiteDataStore::defaultLocalStorageDirectory();
-    parameters.defaultDataStoreParameters.localStorageDirectory = localStorageDirectory;
-    SandboxExtension::createHandleForReadWriteDirectory(localStorageDirectory, parameters.defaultDataStoreParameters.localStorageDirectoryExtensionHandle);
-
-    auto cacheStorageDirectory = m_websiteDataStore ? m_websiteDataStore->cacheStorageDirectory() : nullString();
-    if (!cacheStorageDirectory.isEmpty()) {
-        SandboxExtension::createHandleForReadWriteDirectory(cacheStorageDirectory, parameters.defaultDataStoreParameters.cacheStorageDirectoryExtensionHandle);
-        parameters.defaultDataStoreParameters.cacheStorageDirectory = WTFMove(cacheStorageDirectory);
-    }
-
-    String resourceLoadStatisticsDirectory;
-    SandboxExtension::Handle resourceLoadStatisticsDirectoryExtensionHandle;
-    if (m_websiteDataStore)
-        resourceLoadStatisticsDirectory = m_websiteDataStore->resolvedResourceLoadStatisticsDirectory();
-    else if (WebKit::WebsiteDataStore::defaultDataStoreExists())
-        resourceLoadStatisticsDirectory = WebKit::WebsiteDataStore::defaultDataStore()->parameters().networkSessionParameters.resourceLoadStatisticsParameters.directory;
-    
-    if (!resourceLoadStatisticsDirectory.isEmpty())
-        SandboxExtension::createHandleForReadWriteDirectory(resourceLoadStatisticsDirectory, resourceLoadStatisticsDirectoryExtensionHandle);
-
-    bool enableResourceLoadStatistics = false;
-    bool enableResourceLoadStatisticsLogTestingEvent = false;
-    bool shouldIncludeLocalhost = true;
-    bool enableResourceLoadStatisticsDebugMode = false;
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-    WebCore::ThirdPartyCookieBlockingMode thirdPartyCookieBlockingMode = WebCore::ThirdPartyCookieBlockingMode::All;
-    WebCore::SameSiteStrictEnforcementEnabled sameSiteStrictEnforcementEnabled = WebCore::SameSiteStrictEnforcementEnabled::No;
-#endif
-    WebCore::FirstPartyWebsiteDataRemovalMode firstPartyWebsiteDataRemovalMode = WebCore::FirstPartyWebsiteDataRemovalMode::AllButCookies;
-    WebCore::RegistrableDomain standaloneApplicationDomain;
-    HashSet<WebCore::RegistrableDomain> appBoundDomains;
-    WebCore::RegistrableDomain manualPrevalentResource;
-
-#if PLATFORM(COCOA)
-    m_tccPreferenceEnabled = doesAppHaveITPEnabled();
-    if (withWebsiteDataStore && !withWebsiteDataStore->isItpStateExplicitlySet()) {
-        enableResourceLoadStatistics = m_tccPreferenceEnabled;
-        withWebsiteDataStore->setResourceLoadStatisticsEnabled(enableResourceLoadStatistics);
-    } else if (m_websiteDataStore && !m_websiteDataStore->isItpStateExplicitlySet()) {
-        enableResourceLoadStatistics = m_tccPreferenceEnabled;
-        m_websiteDataStore->setResourceLoadStatisticsEnabled(enableResourceLoadStatistics);
-    } else if (WebsiteDataStore::defaultDataStoreExists() && !WebsiteDataStore::defaultDataStore()->isItpStateExplicitlySet()) {
-        enableResourceLoadStatistics = m_tccPreferenceEnabled;
-        WebsiteDataStore::defaultDataStore()->setResourceLoadStatisticsEnabled(enableResourceLoadStatistics);
-    } else
-        enableResourceLoadStatistics = m_tccPreferenceEnabled;
-#endif
-
-    if (withWebsiteDataStore) {
-        enableResourceLoadStatistics = withWebsiteDataStore->resourceLoadStatisticsEnabled();
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-        enableResourceLoadStatisticsLogTestingEvent = withWebsiteDataStore->hasStatisticsTestingCallback();
-#endif
-        if (enableResourceLoadStatistics) {
-            auto networkSessionParameters = withWebsiteDataStore->parameters().networkSessionParameters;
-            shouldIncludeLocalhost = networkSessionParameters.resourceLoadStatisticsParameters.shouldIncludeLocalhost;
-            enableResourceLoadStatisticsDebugMode = networkSessionParameters.resourceLoadStatisticsParameters.enableDebugMode;
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-            thirdPartyCookieBlockingMode = networkSessionParameters.resourceLoadStatisticsParameters.thirdPartyCookieBlockingMode;
-            sameSiteStrictEnforcementEnabled = networkSessionParameters.resourceLoadStatisticsParameters.sameSiteStrictEnforcementEnabled;
-#endif
-            firstPartyWebsiteDataRemovalMode = networkSessionParameters.resourceLoadStatisticsParameters.firstPartyWebsiteDataRemovalMode;
-            standaloneApplicationDomain = networkSessionParameters.resourceLoadStatisticsParameters.standaloneApplicationDomain;
-            appBoundDomains = networkSessionParameters.resourceLoadStatisticsParameters.appBoundDomains;
-            manualPrevalentResource = networkSessionParameters.resourceLoadStatisticsParameters.manualPrevalentResource;
-        }
-
-        parameters.defaultDataStoreParameters.perOriginStorageQuota = withWebsiteDataStore->perOriginStorageQuota();
-        parameters.defaultDataStoreParameters.perThirdPartyOriginStorageQuota = withWebsiteDataStore->perThirdPartyOriginStorageQuota();
-        
-        const auto& networkCacheDirectory = withWebsiteDataStore->resolvedNetworkCacheDirectory();
-        if (!networkCacheDirectory.isNull()) {
-            parameters.defaultDataStoreParameters.networkSessionParameters.networkCacheDirectory = networkCacheDirectory;
-            SandboxExtension::createHandle(networkCacheDirectory, SandboxExtension::Type::ReadWrite, parameters.defaultDataStoreParameters.networkSessionParameters.networkCacheDirectoryExtensionHandle);
-        }
-
-        const auto& hstsStorageDirectory = withWebsiteDataStore->resolvedHSTSStorageDirectory();
-        if (!hstsStorageDirectory.isNull()) {
-            parameters.defaultDataStoreParameters.networkSessionParameters.hstsStorageDirectory = hstsStorageDirectory;
-            SandboxExtension::createHandle(hstsStorageDirectory, SandboxExtension::Type::ReadWrite, parameters.defaultDataStoreParameters.networkSessionParameters.hstsStorageDirectoryExtensionHandle);
-        }
-    } else if (m_websiteDataStore) {
-        enableResourceLoadStatistics = m_websiteDataStore->resourceLoadStatisticsEnabled();
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-        enableResourceLoadStatisticsLogTestingEvent = m_websiteDataStore->hasStatisticsTestingCallback();
-#endif
-        if (enableResourceLoadStatistics) {
-            auto networkSessionParameters = m_websiteDataStore->parameters().networkSessionParameters;
-            shouldIncludeLocalhost = networkSessionParameters.resourceLoadStatisticsParameters.shouldIncludeLocalhost;
-            enableResourceLoadStatisticsDebugMode = networkSessionParameters.resourceLoadStatisticsParameters.enableDebugMode;
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-            thirdPartyCookieBlockingMode = networkSessionParameters.resourceLoadStatisticsParameters.thirdPartyCookieBlockingMode;
-            sameSiteStrictEnforcementEnabled = networkSessionParameters.resourceLoadStatisticsParameters.sameSiteStrictEnforcementEnabled;
-#endif
-            firstPartyWebsiteDataRemovalMode = networkSessionParameters.resourceLoadStatisticsParameters.firstPartyWebsiteDataRemovalMode;
-            standaloneApplicationDomain = networkSessionParameters.resourceLoadStatisticsParameters.standaloneApplicationDomain;
-            appBoundDomains = networkSessionParameters.resourceLoadStatisticsParameters.appBoundDomains;
-            manualPrevalentResource = networkSessionParameters.resourceLoadStatisticsParameters.manualPrevalentResource;
-        }
-
-        parameters.defaultDataStoreParameters.perOriginStorageQuota = m_websiteDataStore->perOriginStorageQuota();
-        parameters.defaultDataStoreParameters.perThirdPartyOriginStorageQuota = m_websiteDataStore->perThirdPartyOriginStorageQuota();
-
-        const auto& networkCacheDirectory = m_websiteDataStore->resolvedNetworkCacheDirectory();
-        if (!networkCacheDirectory.isNull()) {
-            parameters.defaultDataStoreParameters.networkSessionParameters.networkCacheDirectory = networkCacheDirectory;
-            SandboxExtension::createHandle(networkCacheDirectory, SandboxExtension::Type::ReadWrite, parameters.defaultDataStoreParameters.networkSessionParameters.networkCacheDirectoryExtensionHandle);
-        }
-
-        const auto& hstsStorageDirectory = m_websiteDataStore->resolvedHSTSStorageDirectory();
-        if (!hstsStorageDirectory.isNull()) {
-            parameters.defaultDataStoreParameters.networkSessionParameters.hstsStorageDirectory = hstsStorageDirectory;
-            SandboxExtension::createHandle(hstsStorageDirectory, SandboxExtension::Type::ReadWrite, parameters.defaultDataStoreParameters.networkSessionParameters.hstsStorageDirectoryExtensionHandle);
-        }
-    } else {
-        if (WebsiteDataStore::defaultDataStoreExists())
-            enableResourceLoadStatistics = WebsiteDataStore::defaultDataStore()->resourceLoadStatisticsEnabled();
-        auto networkCacheDirectory = WebsiteDataStore::defaultNetworkCacheDirectory();
-        parameters.defaultDataStoreParameters.networkSessionParameters.networkCacheDirectory = networkCacheDirectory;
-        SandboxExtension::createHandle(networkCacheDirectory, SandboxExtension::Type::ReadWrite, parameters.defaultDataStoreParameters.networkSessionParameters.networkCacheDirectoryExtensionHandle);
-    }
-
-#if HAVE(CFNETWORK_ALTERNATIVE_SERVICE)
-    if (WebsiteDataStore::http3Enabled()) {
-        parameters.defaultDataStoreParameters.networkSessionParameters.alternativeServiceDirectory = WebsiteDataStore::defaultAlternativeServicesDirectory();
-        if (!parameters.defaultDataStoreParameters.networkSessionParameters.alternativeServiceDirectory.isEmpty())
-            SandboxExtension::createHandleForReadWriteDirectory(parameters.defaultDataStoreParameters.networkSessionParameters.alternativeServiceDirectory, parameters.defaultDataStoreParameters.networkSessionParameters.alternativeServiceDirectoryExtensionHandle);
-        parameters.defaultDataStoreParameters.networkSessionParameters.http3Enabled = true;
-    }
-#endif
-    bool isItpStateExplicitlySet = false;
-    parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsParameters = ResourceLoadStatisticsParameters {
-        WTFMove(resourceLoadStatisticsDirectory),
-        WTFMove(resourceLoadStatisticsDirectoryExtensionHandle),
-        enableResourceLoadStatistics,
-        isItpStateExplicitlySet,
-        enableResourceLoadStatisticsLogTestingEvent,
-        shouldIncludeLocalhost,
-        enableResourceLoadStatisticsDebugMode,
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-        thirdPartyCookieBlockingMode,
-        sameSiteStrictEnforcementEnabled,
-#endif
-        firstPartyWebsiteDataRemovalMode,
-        standaloneApplicationDomain,
-        appBoundDomains,
-        manualPrevalentResource,
-    };
-
-    // Add any platform specific parameters
-    platformInitializeNetworkProcess(parameters);
-
-    // Initialize the network process.
-    networkProcess->send(Messages::NetworkProcess::InitializeNetworkProcess(parameters), 0);
-
-#if PLATFORM(COCOA)
-    networkProcess->send(Messages::NetworkProcess::SetQOS(networkProcessLatencyQOS(), networkProcessThroughputQOS()), 0);
-#endif
-
-    networkProcess->updateProcessAssertion();
-
-    if (withWebsiteDataStore) {
-        networkProcess->addSession(makeRef(*withWebsiteDataStore));
-        withWebsiteDataStore->clearPendingCookies();
-    }
-
-    // Make sure the network process knows about all the sessions that have been registered before it started.
-    for (auto& sessionID : m_sessionToPageIDsMap.keys()) {
-        if (auto* websiteDataStore = WebsiteDataStore::existingNonDefaultDataStoreForSessionID(sessionID))
-            networkProcess->addSession(*websiteDataStore);
-    }
-
-    m_networkProcess = WTFMove(networkProcess);
-    return *m_networkProcess;
-}
-
 void WebProcessPool::networkProcessCrashed(NetworkProcessProxy& networkProcessProxy)
 {
-    ASSERT(m_networkProcess);
-    ASSERT(&networkProcessProxy == m_networkProcess.get());
-
     for (auto& supplement : m_supplements.values())
         supplement->processDidClose(&networkProcessProxy);
 
@@ -751,9 +467,6 @@ void WebProcessPool::networkProcessCrashed(NetworkProcessProxy& networkProcessPr
     if (m_automationSession)
         m_automationSession->terminate();
 
-    // Leave the process proxy around during client call, so that the client could query the process identifier.
-    m_networkProcess = nullptr;
-
     terminateServiceWorkers();
 }
 
@@ -764,20 +477,6 @@ void WebProcessPool::serviceWorkerProcessCrashed(WebProcessProxy& proxy)
 #endif
 }
 
-void WebProcessPool::getNetworkProcessConnection(WebProcessProxy& webProcessProxy, Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply&& reply)
-{
-    ensureNetworkProcess();
-    m_networkProcess->getNetworkProcessConnection(webProcessProxy, [this, weakThis = makeWeakPtr(*this), webProcessProxy = makeWeakPtr(webProcessProxy), reply = WTFMove(reply)] (auto& connectionInfo) mutable {
-        if (UNLIKELY(!IPC::Connection::identifierIsValid(connectionInfo.identifier()) && webProcessProxy && weakThis)) {
-            WEBPROCESSPOOL_RELEASE_LOG_ERROR(Process, "getNetworkProcessConnection: Failed first attempt, retrying");
-            ensureNetworkProcess();
-            m_networkProcess->getNetworkProcessConnection(*webProcessProxy, WTFMove(reply));
-            return;
-        }
-        reply(connectionInfo);
-    });
-}
-
 #if ENABLE(GPU_PROCESS)
 void WebProcessPool::gpuProcessCrashed(ProcessID identifier)
 {
@@ -801,23 +500,26 @@ void WebProcessPool::getGPUProcessConnection(WebProcessProxy& webProcessProxy, M
 }
 #endif
 
+bool WebProcessPool::s_useSeparateServiceWorkerProcess = false;
+
 #if ENABLE(SERVICE_WORKER)
 void WebProcessPool::establishWorkerContextConnectionToNetworkProcess(NetworkProcessProxy& proxy, RegistrableDomain&& registrableDomain, PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
 {
-    ASSERT_UNUSED(proxy, &proxy == m_networkProcess.get());
+    auto* websiteDataStore = WebsiteDataStore::existingDataStoreForSessionID(sessionID);
+    if (!websiteDataStore)
+        websiteDataStore = WebsiteDataStore::defaultDataStore().ptr();
+    if (!processPools().size())
+        static NeverDestroyed<Ref<WebProcessPool>> serviceWorkerProcessPool(WebProcessPool::create(API::ProcessPoolConfiguration::create().get()));
 
-    auto* websiteDataStore = WebsiteDataStore::existingNonDefaultDataStoreForSessionID(sessionID);
-
-    if (!websiteDataStore) {
-        if (!m_websiteDataStore)
-            m_websiteDataStore = WebKit::WebsiteDataStore::defaultDataStore().ptr();
-        websiteDataStore = m_websiteDataStore.get();
-    }
+    // Arbitrarily choose the first process pool to host the service worker process.
+    auto* processPool = processPools()[0];
+    ASSERT(processPool);
 
     WebProcessProxy* serviceWorkerProcessProxy { nullptr };
-    if (!m_useSeparateServiceWorkerProcess) {
-        for (auto& process : m_processes) {
-            if (process == m_prewarmedProcess || process->isDummyProcessProxy())
+
+    if (!s_useSeparateServiceWorkerProcess) {
+        for (auto& process : processPool->m_processes) {
+            if (process == processPool->m_prewarmedProcess || process->isDummyProcessProxy())
                 continue;
             if (&process->websiteDataStore() != websiteDataStore)
                 continue;
@@ -825,35 +527,35 @@ void WebProcessPool::establishWorkerContextConnectionToNetworkProcess(NetworkPro
                 continue;
 
             serviceWorkerProcessProxy = process.get();
-            serviceWorkerProcessProxy->enableServiceWorkers(userContentControllerIdentifierForServiceWorkers());
+            serviceWorkerProcessProxy->enableServiceWorkers(processPool->userContentControllerIdentifierForServiceWorkers());
 
-            WEBPROCESSPOOL_RELEASE_LOG_IF_ALLOWED(ServiceWorker, "establishWorkerContextConnectionToNetworkProcess reusing an existing web process (process=%p, PID=%d)", serviceWorkerProcessProxy, serviceWorkerProcessProxy->processIdentifier());
+            WEBPROCESSPOOL_RELEASE_LOG_IF_ALLOWED_STATIC(ServiceWorker, "establishWorkerContextConnectionToNetworkProcess reusing an existing web process (process=%p, PID=%d)", serviceWorkerProcessProxy, serviceWorkerProcessProxy->processIdentifier());
             break;
         }
     }
 
     if (!serviceWorkerProcessProxy) {
-        auto newProcessProxy = WebProcessProxy::createForServiceWorkers(*this, WTFMove(registrableDomain), *websiteDataStore);
+        auto newProcessProxy = WebProcessProxy::createForServiceWorkers(*processPool, WTFMove(registrableDomain), *websiteDataStore);
         serviceWorkerProcessProxy = newProcessProxy.ptr();
 
-        WEBPROCESSPOOL_RELEASE_LOG_IF_ALLOWED(ServiceWorker, "establishWorkerContextConnectionToNetworkProcess creating a new service worker process (proces=%p, PID=%d)", serviceWorkerProcessProxy, serviceWorkerProcessProxy->processIdentifier());
+        WEBPROCESSPOOL_RELEASE_LOG_IF_ALLOWED_STATIC(ServiceWorker, "establishWorkerContextConnectionToNetworkProcess creating a new service worker process (proces=%p, PID=%d)", serviceWorkerProcessProxy, serviceWorkerProcessProxy->processIdentifier());
 
-        initializeNewWebProcess(newProcessProxy, websiteDataStore);
-        m_processes.append(WTFMove(newProcessProxy));
+        processPool->initializeNewWebProcess(newProcessProxy, websiteDataStore);
+        processPool->m_processes.append(WTFMove(newProcessProxy));
     }
 
-    ASSERT(!m_serviceWorkerProcesses.contains(*serviceWorkerProcessProxy));
-    m_serviceWorkerProcesses.add(*serviceWorkerProcessProxy);
+    ASSERT(!serviceWorkerProcesses().contains(*serviceWorkerProcessProxy));
+    serviceWorkerProcesses().add(*serviceWorkerProcessProxy);
 
-    serviceWorkerProcessProxy->establishServiceWorkerContext(m_serviceWorkerPreferences ? m_serviceWorkerPreferences.value() : m_defaultPageGroup->preferences().store(), WTFMove(completionHandler));
-    if (!m_serviceWorkerUserAgent.isNull())
-        serviceWorkerProcessProxy->setServiceWorkerUserAgent(m_serviceWorkerUserAgent);
+    serviceWorkerProcessProxy->establishServiceWorkerContext(processPool->m_serviceWorkerPreferences ? processPool->m_serviceWorkerPreferences.value() : processPool->m_defaultPageGroup->preferences().store(), WTFMove(completionHandler));
+    if (!processPool->m_serviceWorkerUserAgent.isNull())
+        serviceWorkerProcessProxy->setServiceWorkerUserAgent(processPool->m_serviceWorkerUserAgent);
 }
 
 void WebProcessPool::removeFromServiceWorkerProcesses(WebProcessProxy& process)
 {
-    ASSERT(m_serviceWorkerProcesses.contains(process));
-    m_serviceWorkerProcesses.remove(process);
+    ASSERT(serviceWorkerProcesses().contains(process));
+    serviceWorkerProcesses().remove(process);
 }
 #endif
 
@@ -922,7 +624,7 @@ RefPtr<WebProcessProxy> WebProcessPool::tryTakePrewarmedProcess(WebsiteDataStore
 #if PLATFORM(GTK) || PLATFORM(WPE)
     // In platforms using Bubblewrap for sandboxing, prewarmed process is launched using the WebProcessPool primary WebsiteDataStore,
     // so we don't use it in case of using a different WebsiteDataStore.
-    if (m_sandboxEnabled && m_websiteDataStore && m_websiteDataStore.get() != &websiteDataStore)
+    if (m_sandboxEnabled)
         return nullptr;
 #endif
 
@@ -1032,8 +734,6 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa
         process.isResponsive([initializationActivity = WTFMove(initializationActivity)] (bool) { });
     });
 
-    ensureNetworkProcess();
-
     WebProcessCreationParameters parameters;
 
     parameters.injectedBundlePath = m_resolvedPaths.injectedBundlePath;
@@ -1198,9 +898,6 @@ void WebProcessPool::processDidFinishLaunching(WebProcessProxy* process)
         process->connection()->ignoreTimeoutsForTesting();
 
     m_connectionClient.didCreateConnection(this, process->webConnection());
-
-    if (m_websiteDataStore)
-        m_websiteDataStore->didCreateNetworkProcess();
 }
 
 void WebProcessPool::disconnectProcess(WebProcessProxy* process)
@@ -1295,10 +992,7 @@ Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API:
     if (!pageConfiguration->websiteDataStore()) {
         // We try to avoid creating the default data store as long as possible.
         // But if there is an attempt to create a web page without any specified data store, then we have to create it.
-        if (!m_websiteDataStore)
-            m_websiteDataStore = WebKit::WebsiteDataStore::defaultDataStore().ptr();
-
-        pageConfiguration->setWebsiteDataStore(m_websiteDataStore.get());
+        pageConfiguration->setWebsiteDataStore(WebKit::WebsiteDataStore::defaultDataStore().ptr());
     }
 
     RefPtr<WebProcessProxy> process;
@@ -1329,7 +1023,7 @@ Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API:
 #if ENABLE(SERVICE_WORKER)
     if (!m_serviceWorkerPreferences) {
         m_serviceWorkerPreferences = page->preferencesStore();
-        for (auto& serviceWorkerProcess : m_serviceWorkerProcesses)
+        for (auto& serviceWorkerProcess : serviceWorkerProcesses())
             serviceWorkerProcess.updateServiceWorkerPreferencesStore(*m_serviceWorkerPreferences);
     }
     if (userContentController)
@@ -1356,7 +1050,7 @@ void WebProcessPool::updateServiceWorkerUserAgent(const String& userAgent)
     if (m_serviceWorkerUserAgent == userAgent)
         return;
     m_serviceWorkerUserAgent = userAgent;
-    for (auto& serviceWorkerProcess : m_serviceWorkerProcesses)
+    for (auto& serviceWorkerProcess : serviceWorkerProcesses())
         serviceWorkerProcess.setServiceWorkerUserAgent(m_serviceWorkerUserAgent);
 }
 #endif
@@ -1365,15 +1059,6 @@ void WebProcessPool::pageBeginUsingWebsiteDataStore(WebPageProxyIdentifier pageI
 {
     auto result = m_sessionToPageIDsMap.add(dataStore.sessionID(), HashSet<WebPageProxyIdentifier>()).iterator->value.add(pageID);
     ASSERT_UNUSED(result, result.isNewEntry);
-
-    auto sessionID = dataStore.sessionID();
-    if (sessionID != PAL::SessionID::defaultSessionID()) {
-        ASSERT(!sessionID.isEphemeral() || dataStore.parameters().networkSessionParameters.sessionID == sessionID);
-        if (m_networkProcess) {
-            m_networkProcess->addSession(makeRef(dataStore));
-            dataStore.clearPendingCookies();
-        }
-    }
 }
 
 void WebProcessPool::pageEndUsingWebsiteDataStore(WebPageProxyIdentifier pageID, WebsiteDataStore& dataStore)
@@ -1401,7 +1086,6 @@ bool WebProcessPool::hasPagesUsingWebsiteDataStore(WebsiteDataStore& dataStore)
 DownloadProxy& WebProcessPool::download(WebsiteDataStore& dataStore, WebPageProxy* initiatingPage, const ResourceRequest& request, const String& suggestedFilename)
 {
     auto& downloadProxy = createDownloadProxy(dataStore, request, initiatingPage, { });
-    PAL::SessionID sessionID = dataStore.sessionID();
 
     Optional<NavigatingToAppBoundDomain> isAppBound = NavigatingToAppBoundDomain::No;
     if (initiatingPage) {
@@ -1411,26 +1095,23 @@ DownloadProxy& WebProcessPool::download(WebsiteDataStore& dataStore, WebPageProx
 #endif
     }
 
-    if (networkProcess()) {
-        ResourceRequest updatedRequest(request);
-        // Request's firstPartyForCookies will be used as Original URL of the download request.
-        // We set the value to top level document's URL.
-        if (initiatingPage) {
-            URL initiatingPageURL = URL { URL { }, initiatingPage->pageLoadState().url() };
-            updatedRequest.setFirstPartyForCookies(initiatingPageURL);
-            updatedRequest.setIsSameSite(areRegistrableDomainsEqual(initiatingPageURL, request.url()));
-            if (!updatedRequest.hasHTTPHeaderField(HTTPHeaderName::UserAgent))
-                updatedRequest.setHTTPUserAgent(initiatingPage->userAgentForURL(request.url()));
-        } else {
-            updatedRequest.setFirstPartyForCookies(URL());
-            updatedRequest.setIsSameSite(false);
-            if (!updatedRequest.hasHTTPHeaderField(HTTPHeaderName::UserAgent))
-                updatedRequest.setHTTPUserAgent(WebPageProxy::standardUserAgent());
-        }
-        updatedRequest.setIsTopSite(false);
-        networkProcess()->send(Messages::NetworkProcess::DownloadRequest(sessionID, downloadProxy.downloadID(), updatedRequest, isAppBound, suggestedFilename), 0);
-        return downloadProxy;
+    ResourceRequest updatedRequest(request);
+    // Request's firstPartyForCookies will be used as Original URL of the download request.
+    // We set the value to top level document's URL.
+    if (initiatingPage) {
+        URL initiatingPageURL = URL { URL { }, initiatingPage->pageLoadState().url() };
+        updatedRequest.setFirstPartyForCookies(initiatingPageURL);
+        updatedRequest.setIsSameSite(areRegistrableDomainsEqual(initiatingPageURL, request.url()));
+        if (!updatedRequest.hasHTTPHeaderField(HTTPHeaderName::UserAgent))
+            updatedRequest.setHTTPUserAgent(initiatingPage->userAgentForURL(request.url()));
+    } else {
+        updatedRequest.setFirstPartyForCookies(URL());
+        updatedRequest.setIsSameSite(false);
+        if (!updatedRequest.hasHTTPHeaderField(HTTPHeaderName::UserAgent))
+            updatedRequest.setHTTPUserAgent(WebPageProxy::standardUserAgent());
     }
+    updatedRequest.setIsTopSite(false);
+    dataStore.networkProcess().send(Messages::NetworkProcess::DownloadRequest(dataStore.sessionID(), downloadProxy.downloadID(), updatedRequest, isAppBound, suggestedFilename), 0);
 
     return downloadProxy;
 }
@@ -1438,17 +1119,12 @@ DownloadProxy& WebProcessPool::download(WebsiteDataStore& dataStore, WebPageProx
 DownloadProxy& WebProcessPool::resumeDownload(WebsiteDataStore& dataStore, WebPageProxy* initiatingPage, const API::Data& resumeData, const String& path)
 {
     auto& downloadProxy = createDownloadProxy(dataStore, ResourceRequest(), initiatingPage, { });
-    PAL::SessionID sessionID = dataStore.sessionID();
 
     SandboxExtension::Handle sandboxExtensionHandle;
     if (!path.isEmpty())
         SandboxExtension::createHandle(path, SandboxExtension::Type::ReadWrite, sandboxExtensionHandle);
 
-    if (networkProcess()) {
-        networkProcess()->send(Messages::NetworkProcess::ResumeDownload(sessionID, downloadProxy.downloadID(), resumeData.dataReference(), path, sandboxExtensionHandle), 0);
-        return downloadProxy;
-    }
-
+    dataStore.networkProcess().send(Messages::NetworkProcess::ResumeDownload(dataStore.sessionID(), downloadProxy.downloadID(), resumeData.dataReference(), path, sandboxExtensionHandle), 0);
     return downloadProxy;
 }
 
@@ -1517,11 +1193,6 @@ void WebProcessPool::refreshPlugins()
 
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 
-ProcessID WebProcessPool::networkProcessIdentifier()
-{
-    return m_networkProcess ? m_networkProcess->processIdentifier() : 0;
-}
-
 ProcessID WebProcessPool::prewarmedProcessIdentifier()
 {
     return m_prewarmedProcess ? m_prewarmedProcess->processIdentifier() : 0;
@@ -1558,14 +1229,18 @@ void WebProcessPool::registerURLSchemeAsSecure(const String& urlScheme)
 {
     LegacyGlobalSettings::singleton().registerURLSchemeAsSecure(urlScheme);
     sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsSecure(urlScheme));
-    sendToNetworkingProcess(Messages::NetworkProcess::RegisterURLSchemeAsSecure(urlScheme));
+    WebsiteDataStore::forEachWebsiteDataStore([urlScheme] (WebsiteDataStore& dataStore) {
+        dataStore.networkProcess().send(Messages::NetworkProcess::RegisterURLSchemeAsSecure(urlScheme), 0);
+    });
 }
 
 void WebProcessPool::registerURLSchemeAsBypassingContentSecurityPolicy(const String& urlScheme)
 {
     LegacyGlobalSettings::singleton().registerURLSchemeAsBypassingContentSecurityPolicy(urlScheme);
     sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsBypassingContentSecurityPolicy(urlScheme));
-    sendToNetworkingProcess(Messages::NetworkProcess::RegisterURLSchemeAsBypassingContentSecurityPolicy(urlScheme));
+    WebsiteDataStore::forEachWebsiteDataStore([urlScheme] (WebsiteDataStore& dataStore) {
+        dataStore.networkProcess().send(Messages::NetworkProcess::RegisterURLSchemeAsBypassingContentSecurityPolicy(urlScheme), 0);
+    });
 }
 
 void WebProcessPool::setDomainRelaxationForbiddenForURLScheme(const String& urlScheme)
@@ -1578,14 +1253,18 @@ void WebProcessPool::registerURLSchemeAsLocal(const String& urlScheme)
 {
     LegacyGlobalSettings::singleton().registerURLSchemeAsLocal(urlScheme);
     sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsLocal(urlScheme));
-    sendToNetworkingProcess(Messages::NetworkProcess::RegisterURLSchemeAsLocal(urlScheme));
+    WebsiteDataStore::forEachWebsiteDataStore([urlScheme] (WebsiteDataStore& dataStore) {
+        dataStore.networkProcess().send(Messages::NetworkProcess::RegisterURLSchemeAsLocal(urlScheme), 0);
+    });
 }
 
 void WebProcessPool::registerURLSchemeAsNoAccess(const String& urlScheme)
 {
     LegacyGlobalSettings::singleton().registerURLSchemeAsNoAccess(urlScheme);
     sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsNoAccess(urlScheme));
-    sendToNetworkingProcess(Messages::NetworkProcess::RegisterURLSchemeAsNoAccess(urlScheme));
+    WebsiteDataStore::forEachWebsiteDataStore([urlScheme] (WebsiteDataStore& dataStore) {
+        dataStore.networkProcess().send(Messages::NetworkProcess::RegisterURLSchemeAsNoAccess(urlScheme), 0);
+    });
 }
 
 void WebProcessPool::registerURLSchemeAsDisplayIsolated(const String& urlScheme)
@@ -1606,10 +1285,8 @@ void WebProcessPool::registerGlobalURLSchemeAsHavingCustomProtocolHandlers(const
         return;
 
     globalURLSchemesWithCustomProtocolHandlers().add(urlScheme);
-    for (auto* processPool : allProcessPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->registerSchemeForLegacyCustomProtocol(urlScheme);
-    }
+    for (auto networkProcess : NetworkProcessProxy::allNetworkProcesses())
+        networkProcess->registerSchemeForLegacyCustomProtocol(urlScheme);
 }
 
 void WebProcessPool::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(const String& urlScheme)
@@ -1618,10 +1295,8 @@ void WebProcessPool::unregisterGlobalURLSchemeAsHavingCustomProtocolHandlers(con
         return;
 
     globalURLSchemesWithCustomProtocolHandlers().remove(urlScheme);
-    for (auto* processPool : allProcessPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->unregisterSchemeForLegacyCustomProtocol(urlScheme);
-    }
+    for (auto networkProcess : NetworkProcessProxy::allNetworkProcesses())
+        networkProcess->unregisterSchemeForLegacyCustomProtocol(urlScheme);
 }
 
 void WebProcessPool::registerURLSchemeAsCachePartitioned(const String& urlScheme)
@@ -1655,16 +1330,18 @@ void WebProcessPool::setCacheModel(CacheModel cacheModel)
 
     sendToAllProcesses(Messages::WebProcess::SetCacheModel(cacheModel));
 
-    if (m_networkProcess)
-        m_networkProcess->send(Messages::NetworkProcess::SetCacheModel(cacheModel), 0);
+    WebsiteDataStore::forEachWebsiteDataStore([cacheModel] (WebsiteDataStore& dataStore) {
+        dataStore.networkProcess().send(Messages::NetworkProcess::SetCacheModel(cacheModel), 0);
+    });
 }
 
 void WebProcessPool::setCacheModelSynchronouslyForTesting(CacheModel cacheModel)
 {
     updateBackForwardCacheCapacity();
 
-    if (m_networkProcess)
-        m_networkProcess->sendSync(Messages::NetworkProcess::SetCacheModelSynchronouslyForTesting(cacheModel), { }, { });
+    WebsiteDataStore::forEachWebsiteDataStore([cacheModel] (WebsiteDataStore& dataStore) {
+        dataStore.networkProcess().sendSync(Messages::NetworkProcess::SetCacheModelSynchronouslyForTesting(cacheModel), { }, 0);
+    });
 }
 
 void WebProcessPool::setDefaultRequestTimeoutInterval(double timeoutInterval)
@@ -1674,12 +1351,7 @@ void WebProcessPool::setDefaultRequestTimeoutInterval(double timeoutInterval)
 
 DownloadProxy& WebProcessPool::createDownloadProxy(WebsiteDataStore& dataStore, const ResourceRequest& request, WebPageProxy* originatingPage, const FrameInfoData& frameInfo)
 {
-    return ensureNetworkProcess(&dataStore).createDownloadProxy(dataStore, request, frameInfo, originatingPage);
-}
-
-void WebProcessPool::synthesizeAppIsBackground(bool background)
-{
-    ensureNetworkProcess().synthesizeAppIsBackground(background);
+    return dataStore.networkProcess().createDownloadProxy(dataStore, *this, request, frameInfo, originatingPage);
 }
 
 void WebProcessPool::addMessageReceiver(IPC::ReceiverName messageReceiverName, IPC::MessageReceiver& messageReceiver)
@@ -1750,30 +1422,6 @@ void WebProcessPool::stopMemorySampler()
     sendToAllProcesses(Messages::WebProcess::StopMemorySampler());
 }
 
-template<typename T, typename U>
-void WebProcessPool::sendSyncToNetworkingProcess(T&& message, U&& reply)
-{
-    if (m_networkProcess && m_networkProcess->canSendMessage())
-        m_networkProcess->sendSync(std::forward<T>(message), std::forward<U>(reply), 0);
-}
-
-void WebProcessPool::clearCachedCredentials(const PAL::SessionID& sessionID)
-{
-    if (m_networkProcess)
-        m_networkProcess->send(Messages::NetworkProcess::ClearCachedCredentials(sessionID), 0);
-}
-
-void WebProcessPool::terminateNetworkProcess()
-{
-    terminateServiceWorkers();
-
-    if (!m_networkProcess)
-        return;
-    
-    m_networkProcess->terminate();
-    m_networkProcess = nullptr;
-}
-
 void WebProcessPool::terminateAllWebContentProcesses()
 {
     Vector<RefPtr<WebProcessProxy>> processes = m_processes;
@@ -1781,40 +1429,15 @@ void WebProcessPool::terminateAllWebContentProcesses()
         process->terminate();
 }
 
-void WebProcessPool::sendNetworkProcessPrepareToSuspendForTesting(CompletionHandler<void()>&& completionHandler)
-{
-    if (!m_networkProcess)
-        return completionHandler();
-
-    m_networkProcess->sendPrepareToSuspend(IsSuspensionImminent::No, WTFMove(completionHandler));
-}
-
-void WebProcessPool::sendNetworkProcessWillSuspendImminentlyForTesting()
-{
-    if (m_networkProcess)
-        m_networkProcess->sendProcessWillSuspendImminentlyForTesting();
-}
-
-void WebProcessPool::sendNetworkProcessDidResume()
-{
-    if (m_networkProcess)
-        m_networkProcess->sendProcessDidResume();
-}
-
 void WebProcessPool::terminateServiceWorkers()
 {
 #if ENABLE(SERVICE_WORKER)
     auto protectedThis = makeRef(*this);
-    while (m_serviceWorkerProcesses.computeSize())
-        m_serviceWorkerProcesses.begin()->disableServiceWorkers();
+    while (serviceWorkerProcesses().computeSize())
+        serviceWorkerProcesses().begin()->disableServiceWorkers();
 #endif
 }
 
-void WebProcessPool::flushCookies(const PAL::SessionID& sessionID, CompletionHandler<void()>&& completionHandler)
-{
-    ensureNetworkProcess().flushCookies(sessionID, WTFMove(completionHandler));
-}
-
 void WebProcessPool::updateAutomationCapabilities() const
 {
 #if ENABLE(REMOTE_INSPECTOR)
@@ -2089,15 +1712,21 @@ void WebProcessPool::reportWebContentCPUTime(Seconds cpuTime, uint64_t activityS
 #endif
 }
 
+WeakHashSet<WebProcessProxy>& WebProcessPool::serviceWorkerProcesses()
+{
+    static NeverDestroyed<WeakHashSet<WebProcessProxy>> processes;
+    return processes;
+}
+
 void WebProcessPool::updateProcessAssertions()
 {
-    ensureNetworkProcess().updateProcessAssertion();
+    WebsiteDataStore::forEachWebsiteDataStore([] (WebsiteDataStore& dataStore) {
+        dataStore.networkProcess().updateProcessAssertion();
+    });
 #if ENABLE(SERVICE_WORKER)
     // Check on next run loop since the web process proxy tokens are probably being updated.
-    callOnMainRunLoop([this, weakThis = makeWeakPtr(this)] {
-        if (!weakThis)
-            return;
-        for (auto& serviceWorkerProcess : m_serviceWorkerProcesses)
+    callOnMainRunLoop([] {
+        for (auto& serviceWorkerProcess : serviceWorkerProcesses())
             serviceWorkerProcess.updateServiceWorkerProcessAssertion();
     });
 #endif
@@ -2107,7 +1736,7 @@ bool WebProcessPool::isServiceWorkerPageID(WebPageProxyIdentifier pageID) const
 {
 #if ENABLE(SERVICE_WORKER)
     // FIXME: This is inefficient.
-    return WTF::anyOf(m_serviceWorkerProcesses, [pageID](auto& process) {
+    return WTF::anyOf(serviceWorkerProcesses(), [pageID](auto& process) {
         return process.hasServiceWorkerPageProxy(pageID);
     });
 #endif
@@ -2329,14 +1958,6 @@ void WebProcessPool::clearCurrentModifierStateForTesting()
 }
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-void WebProcessPool::didCommitCrossSiteLoadWithDataTransfer(PAL::SessionID sessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, OptionSet<CrossSiteNavigationDataTransfer::Flag> navigationDataTransfer, WebPageProxyIdentifier webPageProxyID, PageIdentifier webPageID)
-{
-    if (!m_networkProcess)
-        return;
-
-    m_networkProcess->didCommitCrossSiteLoadWithDataTransfer(sessionID, fromDomain, toDomain, navigationDataTransfer, webPageProxyID, webPageID);
-}
-
 void WebProcessPool::setDomainsWithUserInteraction(HashSet<WebCore::RegistrableDomain>&& domains)
 {
     sendToAllProcesses(Messages::WebProcess::SetDomainsWithUserInteraction(domains));
@@ -2387,27 +2008,27 @@ void WebProcessPool::updateAudibleMediaAssertions()
 
 void WebProcessPool::setUseSeparateServiceWorkerProcess(bool useSeparateServiceWorkerProcess)
 {
-    if (m_useSeparateServiceWorkerProcess == useSeparateServiceWorkerProcess)
+    if (s_useSeparateServiceWorkerProcess == useSeparateServiceWorkerProcess)
         return;
 
-    WEBPROCESSPOOL_RELEASE_LOG(ServiceWorker, "setUseSeparateServiceWorkerProcess: (useSeparateServiceWorkerProcess=%d)", useSeparateServiceWorkerProcess);
+    WEBPROCESSPOOL_RELEASE_LOG_STATIC(ServiceWorker, "setUseSeparateServiceWorkerProcess: (useSeparateServiceWorkerProcess=%d)", useSeparateServiceWorkerProcess);
 
-    m_useSeparateServiceWorkerProcess = useSeparateServiceWorkerProcess;
-    terminateServiceWorkers();
-    terminateNetworkProcess();
+    s_useSeparateServiceWorkerProcess = useSeparateServiceWorkerProcess;
+    for (auto* processPool : WebProcessPool::allProcessPools())
+        processPool->terminateServiceWorkers();
 }
 
 #if ENABLE(SERVICE_WORKER)
 bool WebProcessPool::hasServiceWorkerForegroundActivityForTesting() const
 {
-    return WTF::anyOf(m_serviceWorkerProcesses, [](auto& process) {
+    return WTF::anyOf(serviceWorkerProcesses(), [](auto& process) {
         return process.hasServiceWorkerForegroundActivityForTesting();
     });
 }
 
 bool WebProcessPool::hasServiceWorkerBackgroundActivityForTesting() const
 {
-    return WTF::anyOf(m_serviceWorkerProcesses, [](auto& process) {
+    return WTF::anyOf(serviceWorkerProcesses(), [](auto& process) {
         return process.hasServiceWorkerBackgroundActivityForTesting();
     });
 }
index 9906b7d..668c1e6 100644 (file)
@@ -77,7 +77,6 @@ OBJC_CLASS WKPreferenceObserver;
 
 namespace API {
 class AutomationClient;
-class CustomProtocolManagerClient;
 class DownloadClient;
 class HTTPCookieStore;
 class InjectedBundleClient;
@@ -176,7 +175,6 @@ public:
     void setHistoryClient(std::unique_ptr<API::LegacyContextHistoryClient>&&);
     void setDownloadClient(UniqueRef<API::DownloadClient>&&);
     void setAutomationClient(std::unique_ptr<API::AutomationClient>&&);
-    void setLegacyCustomProtocolManagerClient(std::unique_ptr<API::CustomProtocolManagerClient>&&);
 
     void setCustomWebContentServiceBundleIdentifier(const String&);
     const String& customWebContentServiceBundleIdentifier() { return m_configuration->customWebContentServiceBundleIdentifier(); }
@@ -187,17 +185,9 @@ public:
     // null checks in WebPageProxy.
     WebProcessProxy* dummyProcessProxy(PAL::SessionID sessionID) const { return m_dummyProcessProxies.get(sessionID).get(); }
 
-    // WebProcess or NetworkProcess as approporiate for current process model. The connection must be non-null.
-    IPC::Connection* networkingProcessConnection();
-
     template<typename T> void sendToAllProcesses(const T& message);
     template<typename T> void sendToAllProcessesForSession(const T& message, PAL::SessionID);
 
-    // Sends the message to WebProcess or NetworkProcess as approporiate for current process model.
-    template<typename T> void sendToNetworkingProcess(T&& message);
-    template<typename T, typename U> void sendSyncToNetworkingProcess(T&& message, U&& reply);
-    template<typename T> void sendToNetworkingProcessRelaunchingIfNecessary(T&& message);
-
     void processDidFinishLaunching(WebProcessProxy*);
 
     WebProcessCache& webProcessCache() { return m_webProcessCache.get(); }
@@ -205,9 +195,6 @@ public:
     // Disconnect the process from the context.
     void disconnectProcess(WebProcessProxy*);
 
-    WebKit::WebsiteDataStore* websiteDataStore() const { return m_websiteDataStore.get(); }
-    void setPrimaryDataStore(WebKit::WebsiteDataStore& dataStore) { m_websiteDataStore = &dataStore; }
-
     Ref<WebPageProxy> createWebPage(PageClient&, Ref<API::PageConfiguration>&&);
 
     void pageBeginUsingWebsiteDataStore(WebPageProxyIdentifier, WebsiteDataStore&);
@@ -258,10 +245,8 @@ public:
     void addSupportedPlugin(String&& matchingDomain, String&& name, HashSet<String>&& mimeTypes, HashSet<String> extensions);
     void clearSupportedPlugins();
 
-    ProcessID networkProcessIdentifier();
     ProcessID prewarmedProcessIdentifier();
     void activePagesOriginsInWebProcessForTesting(ProcessID, CompletionHandler<void(Vector<String>&&)>&&);
-    bool networkProcessHasEntitlementForTesting(const String&);
 
     WebPageGroup& defaultPageGroup() { return m_defaultPageGroup.get(); }
 
@@ -302,8 +287,6 @@ public:
     API::LegacyContextHistoryClient& historyClient() { return *m_historyClient; }
     WebContextClient& client() { return m_client; }
 
-    API::CustomProtocolManagerClient& customProtocolManagerClient() const { return *m_customProtocolManagerClient; }
-
     struct Statistics {
         unsigned wkViewCount;
         unsigned wkPageCount;
@@ -319,12 +302,8 @@ public:
     void sendNetworkProcessDidResume();
     void terminateServiceWorkers();
 
-    void flushCookies(const PAL::SessionID&, CompletionHandler<void()>&&);
-
     void setShouldMakeNextWebProcessLaunchFailForTesting(bool value) { m_shouldMakeNextWebProcessLaunchFailForTesting = value; }
     bool shouldMakeNextWebProcessLaunchFailForTesting() const { return m_shouldMakeNextWebProcessLaunchFailForTesting; }
-    void setShouldMakeNextNetworkProcessLaunchFailForTesting(bool value) { m_shouldMakeNextNetworkProcessLaunchFailForTesting = value; }
-    bool shouldMakeNextNetworkProcessLaunchFailForTesting() const { return m_shouldMakeNextNetworkProcessLaunchFailForTesting; }
 
     void reportWebContentCPUTime(Seconds cpuTime, uint64_t activityState);
 
@@ -383,19 +362,13 @@ public:
 #endif
 
     // Network Process Management
-    NetworkProcessProxy& ensureNetworkProcess(WebsiteDataStore* withWebsiteDataStore = nullptr);
-    NetworkProcessProxy* networkProcess() const { return m_networkProcess.get(); }
     void networkProcessCrashed(NetworkProcessProxy&);
 
-    void getNetworkProcessConnection(WebProcessProxy&, Messages::WebProcessProxy::GetNetworkProcessConnectionDelayedReply&&);
-
     bool isServiceWorkerPageID(WebPageProxyIdentifier) const;
 #if ENABLE(SERVICE_WORKER)
-    void establishWorkerContextConnectionToNetworkProcess(NetworkProcessProxy&, WebCore::RegistrableDomain&&, PAL::SessionID, CompletionHandler<void()>&&);
+    static void establishWorkerContextConnectionToNetworkProcess(NetworkProcessProxy&, WebCore::RegistrableDomain&&, PAL::SessionID, CompletionHandler<void()>&&);
     void removeFromServiceWorkerProcesses(WebProcessProxy&);
-    size_t serviceWorkerProxiesCount() const { return m_serviceWorkerProcesses.computeSize(); }
-    void setAllowsAnySSLCertificateForServiceWorker(bool allows) { m_allowsAnySSLCertificateForServiceWorker = allows; }
-    bool allowsAnySSLCertificateForServiceWorker() const { return m_allowsAnySSLCertificateForServiceWorker; }
+    size_t serviceWorkerProxiesCount() const { return serviceWorkerProcesses().computeSize(); }
     void updateServiceWorkerUserAgent(const String& userAgent);
     const Optional<UserContentControllerIdentifier>& userContentControllerIdentifierForServiceWorkers() const { return m_userContentControllerIDForServiceWorker; }
     bool hasServiceWorkerForegroundActivityForTesting() const;
@@ -449,8 +422,6 @@ public:
     bool alwaysRunsAtBackgroundPriority() const { return m_alwaysRunsAtBackgroundPriority; }
     bool shouldTakeUIBackgroundAssertion() const { return m_shouldTakeUIBackgroundAssertion; }
 
-    void synthesizeAppIsBackground(bool background);
-    
 #if ENABLE(GAMEPAD)
     void gamepadConnected(const UIGamepad&, WebCore::EventMakesGamepadsVisible);
     void gamepadDisconnected(const UIGamepad&);
@@ -488,7 +459,6 @@ public:
     void clearCurrentModifierStateForTesting();
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    void didCommitCrossSiteLoadWithDataTransfer(PAL::SessionID, const WebCore::RegistrableDomain& fromDomain, const WebCore::RegistrableDomain& toDomain, OptionSet<WebCore::CrossSiteNavigationDataTransfer::Flag>, WebPageProxyIdentifier, WebCore::PageIdentifier);
     void setDomainsWithUserInteraction(HashSet<WebCore::RegistrableDomain>&&);
     void seedResourceLoadStatisticsForTesting(const WebCore::RegistrableDomain& firstPartyDomain, const WebCore::RegistrableDomain& thirdPartyDomain, bool shouldScheduleNotification, CompletionHandler<void()>&&);
     void sendResourceLoadStatisticsDataImmediately(CompletionHandler<void()>&&);
@@ -515,8 +485,8 @@ public:
     
     PlugInAutoStartProvider& plugInAutoStartProvider() { return m_plugInAutoStartProvider; }
 
-    void setUseSeparateServiceWorkerProcess(bool);
-    bool useSeparateServiceWorkerProcess() const { return m_useSeparateServiceWorkerProcess; }
+    static void setUseSeparateServiceWorkerProcess(bool);
+    static bool useSeparateServiceWorkerProcess() { return s_useSeparateServiceWorkerProcess; }
 
 #if ENABLE(CFPREFS_DIRECT_MODE)
     void notifyPreferencesChanged(const String& domain, const String& key, const Optional<String>& encodedValue);
@@ -528,9 +498,15 @@ public:
     int32_t userId() const { return m_userId; }
 #endif
 
-#if PLATFORM(COCOA)
-    OSObjectPtr<xpc_object_t> xpcEndpointMessage() const;
-    void sendNetworkProcessXPCEndpointToWebProcess(OSObjectPtr<xpc_object_t> endpointMessage);
+    static void platformInitializeNetworkProcess(NetworkProcessCreationParameters&);
+    static Vector<String> urlSchemesWithCustomProtocolHandlers();
+
+#if PLATFORM(IOS_FAMILY)
+    static String cookieStorageDirectory();
+    static String parentBundleDirectory();
+    static String networkingCachesDirectory();
+    static String webContentCachesDirectory();
+    static String containerTemporaryDirectory();
 #endif
 
 private:
@@ -546,8 +522,6 @@ private:
     WebProcessProxy& createNewWebProcess(WebsiteDataStore*, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No);
     void initializeNewWebProcess(WebProcessProxy&, WebsiteDataStore*, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No);
 
-    void platformInitializeNetworkProcess(NetworkProcessCreationParameters&);
-
     void handleMessage(IPC::Connection&, const String& messageName, const UserData& messageBody);
     void handleSynchronousMessage(IPC::Connection&, const String& messageName, const UserData& messageBody, CompletionHandler<void(UserData&&)>&&);
 
@@ -571,14 +545,6 @@ private:
 
     bool usesSingleWebProcess() const { return m_configuration->usesSingleWebProcess(); }
 
-#if PLATFORM(IOS_FAMILY)
-    static String cookieStorageDirectory();
-    static String parentBundleDirectory();
-    static String networkingCachesDirectory();
-    static String webContentCachesDirectory();
-    static String containerTemporaryDirectory();
-#endif
-
 #if PLATFORM(COCOA)
     void registerNotificationObservers();
     void unregisterNotificationObservers();
@@ -620,9 +586,8 @@ private:
     HashMap<PAL::SessionID, WeakPtr<WebProcessProxy>> m_dummyProcessProxies; // Lightweight WebProcessProxy objects without backing process.
 
 #if ENABLE(SERVICE_WORKER)
-    WeakHashSet<WebProcessProxy> m_serviceWorkerProcesses;
+    static WeakHashSet<WebProcessProxy>& serviceWorkerProcesses();
     bool m_waitingForWorkerContextProcessConnection { false };
-    bool m_allowsAnySSLCertificateForServiceWorker { false };
     String m_serviceWorkerUserAgent;
     Optional<WebPreferencesStore> m_serviceWorkerPreferences;
     Optional<UserContentControllerIdentifier> m_userContentControllerIDForServiceWorker;
@@ -638,7 +603,6 @@ private:
     std::unique_ptr<API::AutomationClient> m_automationClient;
     UniqueRef<API::DownloadClient> m_downloadClient;
     std::unique_ptr<API::LegacyContextHistoryClient> m_historyClient;
-    std::unique_ptr<API::CustomProtocolManagerClient> m_customProtocolManagerClient;
 
     RefPtr<WebAutomationSession> m_automationSession;
 
@@ -670,8 +634,6 @@ private:
     bool m_memorySamplerEnabled { false };
     double m_memorySamplerInterval { 1400.0 };
 
-    RefPtr<WebKit::WebsiteDataStore> m_websiteDataStore;
-
     typedef HashMap<const char*, RefPtr<WebContextSupplement>, PtrHash<const char*>> WebContextSupplementMap;
     WebContextSupplementMap m_supplements;
 
@@ -703,8 +665,6 @@ private:
 
     bool m_processTerminationEnabled { true };
 
-    std::unique_ptr<NetworkProcessProxy> m_networkProcess;
-
     HashMap<uint64_t, RefPtr<DictionaryCallback>> m_dictionaryCallbacks;
 
     bool m_memoryCacheDisabled { false };
@@ -713,7 +673,6 @@ private:
     bool m_alwaysRunsAtBackgroundPriority;
     bool m_shouldTakeUIBackgroundAssertion;
     bool m_shouldMakeNextWebProcessLaunchFailForTesting { false };
-    bool m_shouldMakeNextNetworkProcessLaunchFailForTesting { false };
     bool m_tccPreferenceEnabled { false };
 
     UserObservablePageCounter m_userObservablePageCounter;
@@ -805,32 +764,14 @@ private:
 #else
     bool m_isDelayedWebProcessLaunchDisabled { false };
 #endif
-    bool m_useSeparateServiceWorkerProcess { false };
+    static bool s_useSeparateServiceWorkerProcess;
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     HashSet<WebCore::RegistrableDomain> m_domainsWithUserInteraction;
 #endif
-
-#if PLATFORM(COCOA)
-    OSObjectPtr<xpc_object_t> m_endpointMessage;
-#endif
 };
 
 template<typename T>
-void WebProcessPool::sendToNetworkingProcess(T&& message)
-{
-    if (m_networkProcess && m_networkProcess->canSendMessage())
-        m_networkProcess->send(std::forward<T>(message), 0);
-}
-
-template<typename T>
-void WebProcessPool::sendToNetworkingProcessRelaunchingIfNecessary(T&& message)
-{
-    ensureNetworkProcess();
-    m_networkProcess->send(std::forward<T>(message), 0);
-}
-
-template<typename T>
 void WebProcessPool::sendToAllProcesses(const T& message)
 {
     size_t processCount = m_processes.size();
index d661033..5e2c708 100644 (file)
@@ -268,6 +268,9 @@ void WebProcessProxy::setWebsiteDataStore(WebsiteDataStore& dataStore)
 {
     ASSERT(!m_websiteDataStore);
     m_websiteDataStore = &dataStore;
+#if PLATFORM(COCOA)
+    dataStore.sendNetworkProcessXPCEndpointToWebProcess(*this);
+#endif
     updateRegistrationWithDataStore();
     send(Messages::WebProcess::SetWebsiteDataStoreParameters(processPool().webProcessDataStoreParameters(*this, dataStore)), 0);
 }
@@ -738,7 +741,7 @@ void WebProcessProxy::getPluginProcessConnection(uint64_t pluginProcessToken, Me
 
 void WebProcessProxy::getNetworkProcessConnection(Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply&& reply)
 {
-    m_processPool->getNetworkProcessConnection(*this, WTFMove(reply));
+    websiteDataStore().getNetworkProcessConnection(*this, WTFMove(reply));
 }
 
 #if ENABLE(GPU_PROCESS)
@@ -955,9 +958,8 @@ void WebProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connect
     }
 
 #if PLATFORM(COCOA)
-    auto endpointMessage = processPool().xpcEndpointMessage();
-    if (endpointMessage)
-        xpc_connection_send_message(connection()->xpcConnection(), endpointMessage.get());
+    if (m_websiteDataStore)
+        m_websiteDataStore->sendNetworkProcessXPCEndpointToWebProcess(*this);
 #endif
 
     RELEASE_ASSERT(!m_webConnection);
index 7c44085..cb8b3ba 100644 (file)
 
 #import "CookieStorageUtilsCF.h"
 #import "DefaultWebBrowserChecks.h"
+#import "NetworkProcessProxy.h"
 #import "SandboxUtilities.h"
 #import "StorageManager.h"
 #import "WebFramePolicyListenerProxy.h"
 #import "WebPreferencesKeys.h"
+#import "WebProcessProxy.h"
 #import "WebResourceLoadStatisticsStore.h"
 #import "WebsiteDataStoreParameters.h"
 #import <WebCore/NetworkStorageSession.h>
@@ -44,6 +46,7 @@
 #import <wtf/NeverDestroyed.h>
 #import <wtf/ProcessPrivilege.h>
 #import <wtf/URL.h>
+#import <wtf/cocoa/Entitlements.h>
 #import <wtf/text/StringBuilder.h>
 
 #if PLATFORM(IOS_FAMILY)
@@ -562,4 +565,28 @@ void WebsiteDataStore::reinitializeAppBoundDomains()
 }
 #endif
 
+bool WebsiteDataStore::networkProcessHasEntitlementForTesting(const String& entitlement)
+{
+    return WTF::hasEntitlement(networkProcess().connection()->xpcConnection(), entitlement.utf8().data());
+}
+
+void WebsiteDataStore::sendNetworkProcessXPCEndpointToWebProcess(WebProcessProxy& process)
+{
+    if (process.state() != AuxiliaryProcessProxy::State::Running)
+        return;
+    auto* connection = process.connection();
+    if (!connection)
+        return;
+    auto message = networkProcess().xpcEndpointMessage();
+    if (!message)
+        return;
+    xpc_connection_send_message(connection->xpcConnection(), message);
+}
+
+void WebsiteDataStore::sendNetworkProcessXPCEndpointToAllWebProcesses()
+{
+    for (auto& process : m_processes)
+        sendNetworkProcessXPCEndpointToWebProcess(process);
+}
+
 }
index 5b0aeb7..41191fe 100644 (file)
 #include "AuthenticatorManager.h"
 #include "DeviceIdHashSaltStorage.h"
 #include "GPUProcessProxy.h"
+#include "Logging.h"
 #include "MockAuthenticatorManager.h"
+#include "NetworkProcessConnectionInfo.h"
 #include "NetworkProcessMessages.h"
 #include "ShouldGrandfatherStatistics.h"
 #include "StorageAccessStatus.h"
 #include "WebBackForwardCache.h"
+#include "WebCookieManagerProxy.h"
 #include "WebKit2Initialize.h"
 #include "WebPageProxy.h"
 #include "WebProcessCache.h"
 #include "SOAuthorizationCoordinator.h"
 #endif
 
+#if PLATFORM(COCOA)
+#include "DefaultWebBrowserChecks.h"
+#endif
+
 namespace WebKit {
 
 static bool allowsWebsiteDataRecordsForAllOrigins;
@@ -83,13 +90,19 @@ void WebsiteDataStore::allowWebsiteDataRecordsForAllOrigins()
     allowsWebsiteDataRecordsForAllOrigins = true;
 }
 
-static HashMap<PAL::SessionID, WebsiteDataStore*>& nonDefaultDataStores()
+static HashMap<PAL::SessionID, WebsiteDataStore*>& allDataStores()
 {
     RELEASE_ASSERT(isUIThread());
     static NeverDestroyed<HashMap<PAL::SessionID, WebsiteDataStore*>> map;
     return map;
 }
 
+void WebsiteDataStore::forEachWebsiteDataStore(Function<void(WebsiteDataStore&)>&& function)
+{
+    for (auto* dataStore : allDataStores().values())
+        function(*dataStore);
+}
+
 Ref<WebsiteDataStore> WebsiteDataStore::createNonPersistent()
 {
     return adoptRef(*new WebsiteDataStore(WebsiteDataStoreConfiguration::create(IsPersistent::No), PAL::SessionID::generateEphemeralSessionID()));
@@ -115,7 +128,7 @@ WebsiteDataStore::WebsiteDataStore(Ref<WebsiteDataStoreConfiguration>&& configur
 #endif
 {
     WTF::setProcessPrivileges(allPrivileges());
-    maybeRegisterWithSessionIDMap();
+    registerWithSessionIDMap();
     platformInitialize();
 
     ASSERT(RunLoop::isMain());
@@ -128,17 +141,12 @@ WebsiteDataStore::~WebsiteDataStore()
 
     platformDestroy();
 
-    if (m_sessionID != PAL::SessionID::defaultSessionID()) {
-        ASSERT(nonDefaultDataStores().get(m_sessionID) == this);
-        nonDefaultDataStores().remove(m_sessionID);
-        for (auto& processPool : WebProcessPool::allProcessPools()) {
-            if (auto* networkProcess = processPool->networkProcess())
-                networkProcess->removeSession(m_sessionID);
-        }
-    }
+    ASSERT(allDataStores().get(m_sessionID) == this);
+    allDataStores().remove(m_sessionID);
+    networkProcess().removeSession(*this);
 #if ENABLE(GPU_PROCESS)
-        if (auto* gpuProcessProxy = GPUProcessProxy::singletonIfCreated())
-            gpuProcessProxy->removeSession(m_sessionID);
+    if (auto* gpuProcessProxy = GPUProcessProxy::singletonIfCreated())
+        gpuProcessProxy->removeSession(m_sessionID);
 #endif
 }
 
@@ -151,7 +159,6 @@ static RefPtr<WebsiteDataStore>& globalDefaultDataStore()
 Ref<WebsiteDataStore> WebsiteDataStore::defaultDataStore()
 {
     InitializeWebKit2();
-
     auto& store = globalDefaultDataStore();
     if (!store)
         store = adoptRef(new WebsiteDataStore(WebsiteDataStoreConfiguration::create(IsPersistent::Yes), PAL::SessionID::defaultSessionID()));
@@ -169,17 +176,47 @@ bool WebsiteDataStore::defaultDataStoreExists()
     return !!globalDefaultDataStore();
 }
 
-void WebsiteDataStore::maybeRegisterWithSessionIDMap()
+void WebsiteDataStore::registerWithSessionIDMap()
 {
-    if (m_sessionID != PAL::SessionID::defaultSessionID()) {
-        auto result = nonDefaultDataStores().add(m_sessionID, this);
-        ASSERT_UNUSED(result, result.isNewEntry);
+    auto result = allDataStores().add(m_sessionID, this);
+    ASSERT_UNUSED(result, result.isNewEntry);
+}
+
+WebsiteDataStore* WebsiteDataStore::existingDataStoreForSessionID(PAL::SessionID sessionID)
+{
+    return allDataStores().get(sessionID);
+}
+
+static Ref<NetworkProcessProxy> networkProcessForSession(PAL::SessionID sessionID)
+{
+#if PLATFORM(GTK) || PLATFORM(WPE)
+    if (sessionID.isEphemeral()) {
+        // Reuse a previous persistent session network process for ephemeral sessions.
+        for (auto* dataStore : allDataStores().values()) {
+            if (dataStore->isPersistent())
+                return makeRef(dataStore->networkProcess());
+        }
     }
+    return NetworkProcessProxy::create();
+#else
+    UNUSED_PARAM(sessionID);
+    return NetworkProcessProxy::defaultNetworkProcess();
+#endif
 }
 
-WebsiteDataStore* WebsiteDataStore::existingNonDefaultDataStoreForSessionID(PAL::SessionID sessionID)
+NetworkProcessProxy& WebsiteDataStore::networkProcess()
 {
-    return sessionID != PAL::SessionID::defaultSessionID() ? nonDefaultDataStores().get(sessionID) : nullptr;
+    if (!m_networkProcess) {
+        m_networkProcess = networkProcessForSession(m_sessionID);
+        m_networkProcess->addSession(*this);
+    }
+
+    return *m_networkProcess;
+}
+
+NetworkProcessProxy& WebsiteDataStore::networkProcess() const
+{
+    return const_cast<WebsiteDataStore&>(*this).networkProcess();
 }
 
 void WebsiteDataStore::registerProcess(WebProcessProxy& process)
@@ -195,12 +232,6 @@ void WebsiteDataStore::unregisterProcess(WebProcessProxy& process)
     m_processes.remove(process);
 }
 
-WebProcessPool* WebsiteDataStore::processPoolForCookieStorageOperations()
-{
-    auto pools = processPools(1);
-    return pools.isEmpty() ? nullptr : pools.begin()->get();
-}
-
 void WebsiteDataStore::resolveDirectoriesIfNecessary()
 {
     if (m_hasResolvedDirectories)
@@ -440,28 +471,21 @@ void WebsiteDataStore::fetchDataAndApply(OptionSet<WebsiteDataType> dataTypes, O
 #endif
 
     auto networkProcessAccessType = computeNetworkProcessAccessTypeForDataFetch(dataTypes, !isPersistent());
-    if (networkProcessAccessType != ProcessAccessType::None) {
-        auto pools = networkProcessAccessType == ProcessAccessType::Launch ? ensureProcessPools() : processPools();
-        for (auto& processPool : pools) {
-            switch (networkProcessAccessType) {
-            case ProcessAccessType::OnlyIfLaunched:
-                if (!processPool->networkProcess())
-                    continue;
-                break;
-
-            case ProcessAccessType::Launch:
-                processPool->ensureNetworkProcess(this);
-                break;
-
-            case ProcessAccessType::None:
-                ASSERT_NOT_REACHED();
-            }
-
+    switch (networkProcessAccessType) {
+    case ProcessAccessType::Launch:
+        networkProcess();
+        ASSERT(m_networkProcess);
+        FALLTHROUGH;
+    case ProcessAccessType::OnlyIfLaunched:
+        if (m_networkProcess) {
             callbackAggregator->addPendingCallback();
-            processPool->networkProcess()->fetchWebsiteData(m_sessionID, dataTypes, fetchOptions, [callbackAggregator, processPool](WebsiteData websiteData) {
+            m_networkProcess->fetchWebsiteData(m_sessionID, dataTypes, fetchOptions, [callbackAggregator](WebsiteData websiteData) {
                 callbackAggregator->removePendingCallback(WTFMove(websiteData));
             });
         }
+        break;
+    case ProcessAccessType::None:
+        break;
     }
 
     auto webProcessAccessType = computeWebProcessAccessTypeForDataFetch(dataTypes, !isPersistent());
@@ -724,31 +748,24 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, WallTime
     bool didNotifyNetworkProcessToDeleteWebsiteData = false;
 #endif
     auto networkProcessAccessType = computeNetworkProcessAccessTypeForDataRemoval(dataTypes, !isPersistent());
-    if (networkProcessAccessType != ProcessAccessType::None) {
-        auto pools = networkProcessAccessType == ProcessAccessType::Launch ? ensureProcessPools() : processPools();
-        for (auto& processPool : pools) {
-            switch (networkProcessAccessType) {
-            case ProcessAccessType::OnlyIfLaunched:
-                if (!processPool->networkProcess())
-                    continue;
-                break;
-
-            case ProcessAccessType::Launch:
-                processPool->ensureNetworkProcess(this);
-                break;
-
-            case ProcessAccessType::None:
-                ASSERT_NOT_REACHED();
-            }
-
+    switch (networkProcessAccessType) {
+    case ProcessAccessType::Launch:
+        networkProcess();
+        ASSERT(m_networkProcess);
+        FALLTHROUGH;
+    case ProcessAccessType::OnlyIfLaunched:
+        if (m_networkProcess) {
             callbackAggregator->addPendingCallback();
-            processPool->networkProcess()->deleteWebsiteData(m_sessionID, dataTypes, modifiedSince, [callbackAggregator, processPool] {
+            m_networkProcess->deleteWebsiteData(m_sessionID, dataTypes, modifiedSince, [callbackAggregator] {
                 callbackAggregator->removePendingCallback();
             });
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
             didNotifyNetworkProcessToDeleteWebsiteData = true;
 #endif
         }
+        break;
+    case ProcessAccessType::None:
+        break;
     }
 
     auto webProcessAccessType = computeWebProcessAccessTypeForDataRemoval(dataTypes, !isPersistent());
@@ -893,14 +910,9 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, WallTime
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) {
         if (!didNotifyNetworkProcessToDeleteWebsiteData) {
-            for (auto& processPool : processPools()) {
-                if (auto* process = processPool->networkProcess()) {
-                    callbackAggregator->addPendingCallback();
-                    process->deleteWebsiteData(m_sessionID, dataTypes, modifiedSince, [callbackAggregator] {
-                        callbackAggregator->removePendingCallback();
-                    });
-                }
-            }
+            networkProcess().deleteWebsiteData(m_sessionID, dataTypes, modifiedSince, [callbackAggregator] {
+                callbackAggregator->removePendingCallback();
+            });
         }
 
         callbackAggregator->addPendingCallback();
@@ -994,12 +1006,10 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
         for (auto& processPool : pools) {
             switch (networkProcessAccessType) {
             case ProcessAccessType::OnlyIfLaunched:
-                if (!processPool->networkProcess())
-                    continue;
                 break;
 
             case ProcessAccessType::Launch:
-                processPool->ensureNetworkProcess(this);
+                networkProcess();
                 break;
 
             case ProcessAccessType::None:
@@ -1021,7 +1031,7 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
             }
 
             callbackAggregator->addPendingCallback();
-            processPool->networkProcess()->deleteWebsiteDataForOrigins(m_sessionID, dataTypes, origins, cookieHostNames, HSTSCacheHostNames, registrableDomains, [callbackAggregator, processPool] {
+            networkProcess().deleteWebsiteDataForOrigins(m_sessionID, dataTypes, origins, cookieHostNames, HSTSCacheHostNames, registrableDomains, [callbackAggregator, processPool] {
                 callbackAggregator->removePendingCallback();
             });
         }
@@ -1180,18 +1190,12 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
 
 void WebsiteDataStore::setServiceWorkerTimeoutForTesting(Seconds seconds)
 {
-    for (auto& processPool : WebProcessPool::allProcessPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->sendSync(Messages::NetworkProcess::SetServiceWorkerFetchTimeoutForTesting(seconds), Messages::NetworkProcess::SetServiceWorkerFetchTimeoutForTesting::Reply(), 0);
-    }
+    networkProcess().sendSync(Messages::NetworkProcess::SetServiceWorkerFetchTimeoutForTesting(seconds), Messages::NetworkProcess::SetServiceWorkerFetchTimeoutForTesting::Reply(), 0);
 }
 
 void WebsiteDataStore::resetServiceWorkerTimeoutForTesting()
 {
-    for (auto& processPool : WebProcessPool::allProcessPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->sendSync(Messages::NetworkProcess::ResetServiceWorkerFetchTimeoutForTesting(), Messages::NetworkProcess::ResetServiceWorkerFetchTimeoutForTesting::Reply(), 0);
-    }
+    networkProcess().sendSync(Messages::NetworkProcess::ResetServiceWorkerFetchTimeoutForTesting(), Messages::NetworkProcess::ResetServiceWorkerFetchTimeoutForTesting::Reply(), 0);
 }
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
@@ -1201,8 +1205,7 @@ void WebsiteDataStore::setMaxStatisticsEntries(size_t maximumEntryCount, Complet
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setMaxStatisticsEntries(m_sessionID, maximumEntryCount, [processPool, callbackAggregator] { });
+    networkProcess().setMaxStatisticsEntries(m_sessionID, maximumEntryCount, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setPruneEntriesDownTo(size_t pruneTargetCount, CompletionHandler<void()>&& completionHandler)
@@ -1211,8 +1214,7 @@ void WebsiteDataStore::setPruneEntriesDownTo(size_t pruneTargetCount, Completion
     
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setPruneEntriesDownTo(m_sessionID, pruneTargetCount, [processPool, callbackAggregator] { });
+    networkProcess().setPruneEntriesDownTo(m_sessionID, pruneTargetCount, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setGrandfatheringTime(Seconds seconds, CompletionHandler<void()>&& completionHandler)
@@ -1221,8 +1223,7 @@ void WebsiteDataStore::setGrandfatheringTime(Seconds seconds, CompletionHandler<
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setGrandfatheringTime(m_sessionID, seconds, [processPool, callbackAggregator] { });
+    networkProcess().setGrandfatheringTime(m_sessionID, seconds, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds, CompletionHandler<void()>&& completionHandler)
@@ -1231,20 +1232,13 @@ void WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds,
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setMinimumTimeBetweenDataRecordsRemoval(m_sessionID, seconds, [processPool, callbackAggregator] { });
+    networkProcess().setMinimumTimeBetweenDataRecordsRemoval(m_sessionID, seconds, [callbackAggregator] { });
 }
     
 void WebsiteDataStore::dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
-
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->dumpResourceLoadStatistics(m_sessionID, WTFMove(completionHandler));
-            break;
-        }
-    }
+    networkProcess().dumpResourceLoadStatistics(m_sessionID, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::isPrevalentResource(const URL& url, CompletionHandler<void(bool isPrevalent)>&& completionHandler)
@@ -1256,12 +1250,7 @@ void WebsiteDataStore::isPrevalentResource(const URL& url, CompletionHandler<voi
         return;
     }
 
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->isPrevalentResource(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
-            break;
-        }
-    }
+    networkProcess().isPrevalentResource(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::isGrandfathered(const URL& url, CompletionHandler<void(bool isPrevalent)>&& completionHandler)
@@ -1273,12 +1262,7 @@ void WebsiteDataStore::isGrandfathered(const URL& url, CompletionHandler<void(bo
         return;
     }
 
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->isGrandfathered(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
-            break;
-        }
-    }
+    networkProcess().isGrandfathered(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::setPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
@@ -1292,8 +1276,7 @@ void WebsiteDataStore::setPrevalentResource(const URL& url, CompletionHandler<vo
     
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : ensureProcessPools())
-        processPool->ensureNetworkProcess().setPrevalentResource(m_sessionID, WebCore::RegistrableDomain { url }, [processPool, callbackAggregator] { });
+    networkProcess().setPrevalentResource(m_sessionID, WebCore::RegistrableDomain { url }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setPrevalentResourceForDebugMode(const URL& url, CompletionHandler<void()>&& completionHandler)
@@ -1307,10 +1290,7 @@ void WebsiteDataStore::setPrevalentResourceForDebugMode(const URL& url, Completi
     
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->setPrevalentResourceForDebugMode(m_sessionID, WebCore::RegistrableDomain { url }, [processPool, callbackAggregator] { });
-    }
+    networkProcess().setPrevalentResourceForDebugMode(m_sessionID, WebCore::RegistrableDomain { url }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::isVeryPrevalentResource(const URL& url, CompletionHandler<void(bool isVeryPrevalent)>&& completionHandler)
@@ -1322,12 +1302,7 @@ void WebsiteDataStore::isVeryPrevalentResource(const URL& url, CompletionHandler
         return;
     }
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->isVeryPrevalentResource(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
-            break;
-        }
-    }
+    networkProcess().isVeryPrevalentResource(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::setVeryPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
@@ -1341,10 +1316,7 @@ void WebsiteDataStore::setVeryPrevalentResource(const URL& url, CompletionHandle
     
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->setVeryPrevalentResource(m_sessionID, WebCore::RegistrableDomain { url }, [processPool, callbackAggregator] { });
-    }
+    networkProcess().setVeryPrevalentResource(m_sessionID, WebCore::RegistrableDomain { url }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value, CompletionHandler<void()>&& completionHandler)
@@ -1353,8 +1325,7 @@ void WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool v
     
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setShouldClassifyResourcesBeforeDataRecordsRemoval(m_sessionID, value, [processPool, callbackAggregator] { });
+    networkProcess().setShouldClassifyResourcesBeforeDataRecordsRemoval(m_sessionID, value, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setSubframeUnderTopFrameDomain(const URL& subFrameURL, const URL& topFrameURL, CompletionHandler<void()>&& completionHandler)
@@ -1368,22 +1339,14 @@ void WebsiteDataStore::setSubframeUnderTopFrameDomain(const URL& subFrameURL, co
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->setSubframeUnderTopFrameDomain(m_sessionID, WebCore::RegistrableDomain { subFrameURL }, WebCore::RegistrableDomain { topFrameURL }, [processPool, callbackAggregator] { });
-    }
+    networkProcess().setSubframeUnderTopFrameDomain(m_sessionID, WebCore::RegistrableDomain { subFrameURL }, WebCore::RegistrableDomain { topFrameURL }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::isRegisteredAsSubFrameUnder(const URL& subFrameURL, const URL& topFrameURL, CompletionHandler<void(bool)>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->isRegisteredAsSubFrameUnder(m_sessionID, WebCore::RegistrableDomain { subFrameURL }, WebCore::RegistrableDomain { topFrameURL }, WTFMove(completionHandler));
-            break;
-        }
-    }
+    networkProcess().isRegisteredAsSubFrameUnder(m_sessionID, WebCore::RegistrableDomain { subFrameURL }, WebCore::RegistrableDomain { topFrameURL }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::setSubresourceUnderTopFrameDomain(const URL& subresourceURL, const URL& topFrameURL, CompletionHandler<void()>&& completionHandler)
@@ -1397,23 +1360,14 @@ void WebsiteDataStore::setSubresourceUnderTopFrameDomain(const URL& subresourceU
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->setSubresourceUnderTopFrameDomain(m_sessionID, WebCore::RegistrableDomain { subresourceURL }, WebCore::RegistrableDomain { topFrameURL }, [processPool, callbackAggregator] { });
-    }
+    networkProcess().setSubresourceUnderTopFrameDomain(m_sessionID, WebCore::RegistrableDomain { subresourceURL }, WebCore::RegistrableDomain { topFrameURL }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::isRegisteredAsSubresourceUnder(const URL& subresourceURL, const URL& topFrameURL, CompletionHandler<void(bool)>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->isRegisteredAsSubresourceUnder(m_sessionID, WebCore::RegistrableDomain { subresourceURL }, WebCore::RegistrableDomain { topFrameURL }, WTFMove(completionHandler));
-            return;
-        }
-    }
-    completionHandler(false);
+    networkProcess().isRegisteredAsSubresourceUnder(m_sessionID, WebCore::RegistrableDomain { subresourceURL }, WebCore::RegistrableDomain { topFrameURL }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::setSubresourceUniqueRedirectTo(const URL& subresourceURL, const URL& urlRedirectedTo, CompletionHandler<void()>&& completionHandler)
@@ -1427,10 +1381,7 @@ void WebsiteDataStore::setSubresourceUniqueRedirectTo(const URL& subresourceURL,
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->setSubresourceUniqueRedirectTo(m_sessionID, WebCore::RegistrableDomain { subresourceURL }, WebCore::RegistrableDomain { urlRedirectedTo }, [processPool, callbackAggregator] { });
-    }
+    networkProcess().setSubresourceUniqueRedirectTo(m_sessionID, WebCore::RegistrableDomain { subresourceURL }, WebCore::RegistrableDomain { urlRedirectedTo }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setSubresourceUniqueRedirectFrom(const URL& subresourceURL, const URL& urlRedirectedFrom, CompletionHandler<void()>&& completionHandler)
@@ -1442,12 +1393,7 @@ void WebsiteDataStore::setSubresourceUniqueRedirectFrom(const URL& subresourceUR
         return;
     }
 
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-    
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->setSubresourceUniqueRedirectFrom(m_sessionID, WebCore::RegistrableDomain { subresourceURL }, WebCore::RegistrableDomain { urlRedirectedFrom }, [processPool, callbackAggregator] { });
-    }
+    networkProcess().setSubresourceUniqueRedirectFrom(m_sessionID, WebCore::RegistrableDomain { subresourceURL }, WebCore::RegistrableDomain { urlRedirectedFrom }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::setTopFrameUniqueRedirectTo(const URL& topFrameURL, const URL& urlRedirectedTo, CompletionHandler<void()>&& completionHandler)
@@ -1459,12 +1405,7 @@ void WebsiteDataStore::setTopFrameUniqueRedirectTo(const URL& topFrameURL, const
         return;
     }
 
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-    
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->setTopFrameUniqueRedirectTo(m_sessionID, WebCore::RegistrableDomain { topFrameURL }, WebCore::RegistrableDomain { urlRedirectedTo }, [processPool, callbackAggregator] { });
-    }
+    networkProcess().setTopFrameUniqueRedirectTo(m_sessionID, WebCore::RegistrableDomain { topFrameURL }, WebCore::RegistrableDomain { urlRedirectedTo }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::setTopFrameUniqueRedirectFrom(const URL& topFrameURL, const URL& urlRedirectedFrom, CompletionHandler<void()>&& completionHandler)
@@ -1476,25 +1417,14 @@ void WebsiteDataStore::setTopFrameUniqueRedirectFrom(const URL& topFrameURL, con
         return;
     }
 
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-    
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->setTopFrameUniqueRedirectFrom(m_sessionID, WebCore::RegistrableDomain { topFrameURL }, WebCore::RegistrableDomain { urlRedirectedFrom }, [processPool, callbackAggregator] { });
-    }
+    networkProcess().setTopFrameUniqueRedirectFrom(m_sessionID, WebCore::RegistrableDomain { topFrameURL }, WebCore::RegistrableDomain { urlRedirectedFrom }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::isRegisteredAsRedirectingTo(const URL& urlRedirectedFrom, const URL& urlRedirectedTo, CompletionHandler<void(bool)>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->isRegisteredAsRedirectingTo(m_sessionID, WebCore::RegistrableDomain { urlRedirectedFrom }, WebCore::RegistrableDomain { urlRedirectedTo }, WTFMove(completionHandler));
-            return;
-        }
-    }
-    completionHandler(false);
+    networkProcess().isRegisteredAsRedirectingTo(m_sessionID, WebCore::RegistrableDomain { urlRedirectedFrom }, WebCore::RegistrableDomain { urlRedirectedTo }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::clearPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
@@ -1506,60 +1436,41 @@ void WebsiteDataStore::clearPrevalentResource(const URL& url, CompletionHandler<
         return;
     }
 
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->clearPrevalentResource(m_sessionID, WebCore::RegistrableDomain { url }, [processPool, callbackAggregator] { });
-    }
+    networkProcess().clearPrevalentResource(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::resetParametersToDefaultValues(CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
-
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-    
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->resetParametersToDefaultValues(m_sessionID, [processPool, callbackAggregator] { });
-    }
+    networkProcess().resetParametersToDefaultValues(m_sessionID, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::submitTelemetry()
 {
     ASSERT(RunLoop::isMain());
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->submitTelemetry(m_sessionID, [] { });
-    }
+    networkProcess().submitTelemetry(m_sessionID, [] { });
 }
 
 void WebsiteDataStore::scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfatherStatistics shouldGrandfather, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
     
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->scheduleClearInMemoryAndPersistent(m_sessionID, modifiedSince, shouldGrandfather, [processPool, callbackAggregator] { });
-    }
+    networkProcess().scheduleClearInMemoryAndPersistent(m_sessionID, modifiedSince, shouldGrandfather, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::getResourceLoadStatisticsDataSummary(CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
-    struct CallbackAggregator : RefCounted<CallbackAggregator> {
-        CallbackAggregator(CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&& completionHandler)
+    struct LocalCallbackAggregator : RefCounted<LocalCallbackAggregator> {
+        LocalCallbackAggregator(CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&& completionHandler)
             : m_completionHandler(WTFMove(completionHandler))
         {
             ASSERT(RunLoop::isMain());
         };
 
-        ~CallbackAggregator()
+        ~LocalCallbackAggregator()
         {
             ASSERT(RunLoop::isMain());
 
@@ -1574,38 +1485,31 @@ void WebsiteDataStore::getResourceLoadStatisticsDataSummary(CompletionHandler<vo
         CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)> m_completionHandler;
         Vector<WebResourceLoadStatisticsStore::ThirdPartyData> m_results;
     };
-
-    RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(WTFMove(completionHandler)));
-
-    for (auto& processPool : ensureProcessPools()) {
-        processPool->sendResourceLoadStatisticsDataImmediately([this, protectedThis = makeRef(*this), processPool, callbackAggregator] {
-            processPool->ensureNetworkProcess(this).getResourceLoadStatisticsDataSummary(m_sessionID, [callbackAggregator, processPool](Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&& data) {
-                callbackAggregator->addResult(WTFMove(data));
-            });
+    
+    auto localCallbackAggregator = adoptRef(new LocalCallbackAggregator(WTFMove(completionHandler)));
+    
+    auto wtfCallbackAggregator = WTF::CallbackAggregator::create([this, protectedThis = makeRef(*this), localCallbackAggregator] {
+        networkProcess().getResourceLoadStatisticsDataSummary(m_sessionID, [localCallbackAggregator](Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&& data) {
+            localCallbackAggregator->addResult(WTFMove(data));
         });
-    }
+    });
+    
+    for (auto* processPool : WebProcessPool::allProcessPools())
+        processPool->sendResourceLoadStatisticsDataImmediately([wtfCallbackAggregator] { });
 }
 
 void WebsiteDataStore::scheduleClearInMemoryAndPersistent(ShouldGrandfatherStatistics shouldGrandfather, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
     
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->scheduleClearInMemoryAndPersistent(m_sessionID, { }, shouldGrandfather, [processPool, callbackAggregator] { });
-    }
+    networkProcess().scheduleClearInMemoryAndPersistent(m_sessionID, { }, shouldGrandfather, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::scheduleCookieBlockingUpdate(CompletionHandler<void()>&& completionHandler)
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->scheduleCookieBlockingUpdate(m_sessionID, [processPool, callbackAggregator] { });
-    }
+    networkProcess().scheduleCookieBlockingUpdate(m_sessionID, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&& completionHandler)
@@ -1614,24 +1518,13 @@ void WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing(CompletionHand
     
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->scheduleStatisticsAndDataRecordsProcessing(m_sessionID, [processPool, callbackAggregator] { });
-    }
+    networkProcess().scheduleStatisticsAndDataRecordsProcessing(m_sessionID, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::statisticsDatabaseHasAllTables(CompletionHandler<void(bool)>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
-
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->statisticsDatabaseHasAllTables(m_sessionID, WTFMove(completionHandler));
-            return;
-        }
-    }
-
-    completionHandler(false);
+    networkProcess().statisticsDatabaseHasAllTables(m_sessionID, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::setLastSeen(const URL& url, Seconds seconds, CompletionHandler<void()>&& completionHandler)
@@ -1643,22 +1536,14 @@ void WebsiteDataStore::setLastSeen(const URL& url, Seconds seconds, CompletionHa
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->setLastSeen(m_sessionID, WebCore::RegistrableDomain { url }, seconds, [processPool, callbackAggregator] { });
-    }
+    networkProcess().setLastSeen(m_sessionID, WebCore::RegistrableDomain { url }, seconds, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::domainIDExistsInDatabase(int domainID, CompletionHandler<void(bool)>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->domainIDExistsInDatabase(m_sessionID, domainID, WTFMove(completionHandler));
-            break;
-        }
-    }
+    networkProcess().domainIDExistsInDatabase(m_sessionID, domainID, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::mergeStatisticForTesting(const URL& url, const URL& topFrameUrl1, const URL& topFrameUrl2, Seconds lastSeen, bool hadUserInteraction, Seconds mostRecentUserInteraction, bool isGrandfathered, bool isPrevalent, bool isVeryPrevalent, unsigned dataRecordsRemoved, CompletionHandler<void()>&& completionHandler)
@@ -1670,10 +1555,7 @@ void WebsiteDataStore::mergeStatisticForTesting(const URL& url, const URL& topFr
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->mergeStatisticForTesting(m_sessionID, WebCore::RegistrableDomain { url }, WebCore::RegistrableDomain { topFrameUrl1 }, WebCore::RegistrableDomain { topFrameUrl2 }, lastSeen, hadUserInteraction, mostRecentUserInteraction, isGrandfathered, isPrevalent, isVeryPrevalent, dataRecordsRemoved, [processPool, callbackAggregator] { });
-    }
+    networkProcess().mergeStatisticForTesting(m_sessionID, WebCore::RegistrableDomain { url }, WebCore::RegistrableDomain { topFrameUrl1 }, WebCore::RegistrableDomain { topFrameUrl2 }, lastSeen, hadUserInteraction, mostRecentUserInteraction, isGrandfathered, isPrevalent, isVeryPrevalent, dataRecordsRemoved, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::insertExpiredStatisticForTesting(const URL& url, bool hadUserInteraction, bool isScheduledForAllButCookieDataRemoval, bool isPrevalent, CompletionHandler<void()>&& completionHandler)
@@ -1685,18 +1567,14 @@ void WebsiteDataStore::insertExpiredStatisticForTesting(const URL& url, bool had
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->insertExpiredStatisticForTesting(m_sessionID, WebCore::RegistrableDomain { url }, hadUserInteraction, isScheduledForAllButCookieDataRemoval, isPrevalent, [processPool, callbackAggregator] { });
-    }
+    networkProcess().insertExpiredStatisticForTesting(m_sessionID, WebCore::RegistrableDomain { url }, hadUserInteraction, isScheduledForAllButCookieDataRemoval, isPrevalent, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned(bool value, CompletionHandler<void()>&& completionHandler)
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setNotifyPagesWhenDataRecordsWereScanned(m_sessionID, value, [processPool, callbackAggregator] { });
+    networkProcess().setNotifyPagesWhenDataRecordsWereScanned(m_sessionID, value, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setIsRunningResourceLoadStatisticsTest(bool value, CompletionHandler<void()>&& completionHandler)
@@ -1704,8 +1582,7 @@ void WebsiteDataStore::setIsRunningResourceLoadStatisticsTest(bool value, Comple
     useExplicitITPState();
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setIsRunningResourceLoadStatisticsTest(m_sessionID, value, [processPool, callbackAggregator] { });
+    networkProcess().setIsRunningResourceLoadStatisticsTest(m_sessionID, value, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::getAllStorageAccessEntries(WebPageProxyIdentifier pageID, CompletionHandler<void(Vector<String>&& domains)>&& completionHandler)
@@ -1716,7 +1593,7 @@ void WebsiteDataStore::getAllStorageAccessEntries(WebPageProxyIdentifier pageID,
         return;
     }
 
-    webPage->process().processPool().ensureNetworkProcess().getAllStorageAccessEntries(m_sessionID, WTFMove(completionHandler));
+    networkProcess().getAllStorageAccessEntries(m_sessionID, WTFMove(completionHandler));
 }
 
 
@@ -1724,8 +1601,7 @@ void WebsiteDataStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionH
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setTimeToLiveUserInteraction(m_sessionID, seconds, [callbackAggregator] { });
+    networkProcess().setTimeToLiveUserInteraction(m_sessionID, seconds, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::logUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
@@ -1739,10 +1615,7 @@ void WebsiteDataStore::logUserInteraction(const URL& url, CompletionHandler<void
     
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->logUserInteraction(m_sessionID, WebCore::RegistrableDomain { url }, [callbackAggregator] { });
-    }
+    networkProcess().logUserInteraction(m_sessionID, WebCore::RegistrableDomain { url }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::hasHadUserInteraction(const URL& url, CompletionHandler<void(bool)>&& completionHandler)
@@ -1754,13 +1627,7 @@ void WebsiteDataStore::hasHadUserInteraction(const URL& url, CompletionHandler<v
         return;
     }
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->hasHadUserInteraction(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
-            return;
-        }
-    }
-    completionHandler(false);
+    networkProcess().hasHadUserInteraction(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::isRelationshipOnlyInDatabaseOnce(const URL& subUrl, const URL& topUrl, CompletionHandler<void(bool)>&& completionHandler)
@@ -1772,13 +1639,7 @@ void WebsiteDataStore::isRelationshipOnlyInDatabaseOnce(const URL& subUrl, const
         return;
     }
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess()) {
-            process->isRelationshipOnlyInDatabaseOnce(m_sessionID, WebCore::RegistrableDomain { subUrl }, WebCore::RegistrableDomain { topUrl }, WTFMove(completionHandler));
-            return;
-        }
-    }
-    completionHandler(false);
+    networkProcess().isRelationshipOnlyInDatabaseOnce(m_sessionID, WebCore::RegistrableDomain { subUrl }, WebCore::RegistrableDomain { topUrl }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::clearUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
@@ -1792,10 +1653,7 @@ void WebsiteDataStore::clearUserInteraction(const URL& url, CompletionHandler<vo
     
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->clearUserInteraction(m_sessionID, WebCore::RegistrableDomain { url }, [callbackAggregator] { });
-    }
+    networkProcess().clearUserInteraction(m_sessionID, WebCore::RegistrableDomain { url }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setGrandfathered(const URL& url, bool isGrandfathered, CompletionHandler<void()>&& completionHandler)
@@ -1809,10 +1667,7 @@ void WebsiteDataStore::setGrandfathered(const URL& url, bool isGrandfathered, Co
     
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->setGrandfathered(m_sessionID, WebCore::RegistrableDomain { url }, isGrandfathered, [callbackAggregator] { });
-    }
+    networkProcess().setGrandfathered(m_sessionID, WebCore::RegistrableDomain { url }, isGrandfathered, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setCrossSiteLoadWithLinkDecorationForTesting(const URL& fromURL, const URL& toURL, CompletionHandler<void()>&& completionHandler)
@@ -1821,62 +1676,38 @@ void WebsiteDataStore::setCrossSiteLoadWithLinkDecorationForTesting(const URL& f
     
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->setCrossSiteLoadWithLinkDecorationForTesting(m_sessionID, WebCore::RegistrableDomain { fromURL }, WebCore::RegistrableDomain { toURL }, [processPool, callbackAggregator] { });
-    }
+    networkProcess().setCrossSiteLoadWithLinkDecorationForTesting(m_sessionID, WebCore::RegistrableDomain { fromURL }, WebCore::RegistrableDomain { toURL }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::resetCrossSiteLoadsWithLinkDecorationForTesting(CompletionHandler<void()>&& completionHandler)
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->resetCrossSiteLoadsWithLinkDecorationForTesting(m_sessionID, [callbackAggregator] { });
-    }
+    networkProcess().resetCrossSiteLoadsWithLinkDecorationForTesting(m_sessionID, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::deleteCookiesForTesting(const URL& url, bool includeHttpOnlyCookies, CompletionHandler<void()>&& completionHandler)
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->deleteCookiesForTesting(m_sessionID, WebCore::RegistrableDomain { url }, includeHttpOnlyCookies, [callbackAggregator] { });
-    }
+    networkProcess().deleteCookiesForTesting(m_sessionID, WebCore::RegistrableDomain { url }, includeHttpOnlyCookies, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::hasLocalStorageForTesting(const URL& url, CompletionHandler<void(bool)>&& completionHandler) const
 {
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess()) {
-            networkProcess->hasLocalStorage(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
-            return;
-        }
-    }
-    completionHandler(false);
+    networkProcess().hasLocalStorage(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::hasIsolatedSessionForTesting(const URL& url, CompletionHandler<void(bool)>&& completionHandler) const
 {
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess()) {
-            networkProcess->hasIsolatedSession(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
-            return;
-        }
-    }
-    completionHandler(false);
+    networkProcess().hasIsolatedSession(m_sessionID, WebCore::RegistrableDomain { url }, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::setResourceLoadStatisticsShouldDowngradeReferrerForTesting(bool enabled, CompletionHandler<void()>&& completionHandler)
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->setShouldDowngradeReferrerForTesting(enabled, [callbackAggregator] { });
-    }
+    networkProcess().setShouldDowngradeReferrerForTesting(enabled, [callbackAggregator] { });
 }
 
 #if !PLATFORM(COCOA)
@@ -1907,10 +1738,7 @@ void WebsiteDataStore::setThirdPartyCookieBlockingMode(WebCore::ThirdPartyCookie
             webProcess.setThirdPartyCookieBlockingMode(blockingMode, [callbackAggregator] { });
     }
 
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->setThirdPartyCookieBlockingMode(m_sessionID, blockingMode, [callbackAggregator] { });
-    }
+    networkProcess().setThirdPartyCookieBlockingMode(m_sessionID, blockingMode, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setResourceLoadStatisticsShouldEnbleSameSiteStrictEnforcementForTesting(bool enabled, CompletionHandler<void()>&& completionHandler)
@@ -1918,10 +1746,7 @@ void WebsiteDataStore::setResourceLoadStatisticsShouldEnbleSameSiteStrictEnforce
     auto flag = enabled ? WebCore::SameSiteStrictEnforcementEnabled::Yes : WebCore::SameSiteStrictEnforcementEnabled::No;
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->setShouldEnbleSameSiteStrictEnforcementForTesting(m_sessionID, flag, [callbackAggregator] { });
-    }
+    networkProcess().setShouldEnbleSameSiteStrictEnforcementForTesting(m_sessionID, flag, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setResourceLoadStatisticsFirstPartyWebsiteDataRemovalModeForTesting(bool enabled, CompletionHandler<void()>&& completionHandler)
@@ -1929,20 +1754,14 @@ void WebsiteDataStore::setResourceLoadStatisticsFirstPartyWebsiteDataRemovalMode
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     auto mode = enabled ? WebCore::FirstPartyWebsiteDataRemovalMode::AllButCookies : WebCore::FirstPartyWebsiteDataRemovalMode::None;
 
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->setFirstPartyWebsiteDataRemovalModeForTesting(m_sessionID, mode, [callbackAggregator] { });
-    }
+    networkProcess().setFirstPartyWebsiteDataRemovalModeForTesting(m_sessionID, mode, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setResourceLoadStatisticsToSameSiteStrictCookiesForTesting(const URL& url, CompletionHandler<void()>&& completionHandler)
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->setToSameSiteStrictCookiesForTesting(m_sessionID, WebCore::RegistrableDomain { url }, [callbackAggregator] { });
-    }
+    networkProcess().setToSameSiteStrictCookiesForTesting(m_sessionID, WebCore::RegistrableDomain { url }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setResourceLoadStatisticsFirstPartyHostCNAMEDomainForTesting(const URL& firstPartyURL, const URL& cnameURL, CompletionHandler<void()>&& completionHandler)
@@ -1954,8 +1773,7 @@ void WebsiteDataStore::setResourceLoadStatisticsFirstPartyHostCNAMEDomainForTest
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setFirstPartyHostCNAMEDomainForTesting(m_sessionID, firstPartyURL.host().toString(), WebCore::RegistrableDomain { cnameURL }, [callbackAggregator] { });
+    networkProcess().setFirstPartyHostCNAMEDomainForTesting(m_sessionID, firstPartyURL.host().toString(), WebCore::RegistrableDomain { cnameURL }, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::setResourceLoadStatisticsThirdPartyCNAMEDomainForTesting(const URL& cnameURL, CompletionHandler<void()>&& completionHandler)
@@ -1967,18 +1785,13 @@ void WebsiteDataStore::setResourceLoadStatisticsThirdPartyCNAMEDomainForTesting(
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setThirdPartyCNAMEDomainForTesting(m_sessionID, WebCore::RegistrableDomain { cnameURL }, [callbackAggregator] { });
+    networkProcess().setThirdPartyCNAMEDomainForTesting(m_sessionID, WebCore::RegistrableDomain { cnameURL }, [callbackAggregator] { });
 }
 #endif // ENABLE(RESOURCE_LOAD_STATISTICS)
 
 void WebsiteDataStore::syncLocalStorage(CompletionHandler<void()>&& completionHandler)
 {
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->sendWithAsyncReply(Messages::NetworkProcess::SyncLocalStorage(), [callbackAggregator] { });
-    }
+    networkProcess().sendWithAsyncReply(Messages::NetworkProcess::SyncLocalStorage(), WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources(Seconds seconds, CompletionHandler<void()>&& completionHandler)
@@ -1986,8 +1799,7 @@ void WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources(Seconds seconds, C
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setCacheMaxAgeCapForPrevalentResources(m_sessionID, seconds, [callbackAggregator] { });
+    networkProcess().setCacheMaxAgeCapForPrevalentResources(m_sessionID, seconds, [callbackAggregator] { });
 #else
     UNUSED_PARAM(seconds);
     completionHandler();
@@ -1997,26 +1809,12 @@ void WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources(Seconds seconds, C
 void WebsiteDataStore::resetCacheMaxAgeCapForPrevalentResources(CompletionHandler<void()>&& completionHandler)
 {
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-    
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->resetCacheMaxAgeCapForPrevalentResources(m_sessionID, [callbackAggregator] { });
-    }
+    networkProcess().resetCacheMaxAgeCapForPrevalentResources(m_sessionID, WTFMove(completionHandler));
 #else
     completionHandler();
 #endif
 }
 
-bool WebsiteDataStore::isAssociatedProcessPool(WebProcessPool& processPool) const
-{
-    if (auto* processPoolDataStore = processPool.websiteDataStore())
-        return processPoolDataStore == this;
-    if (auto* networkProcessProxy = processPool.networkProcess())
-        return networkProcessProxy->hasSession(m_sessionID);
-    return false;
-}
-
 HashSet<RefPtr<WebProcessPool>> WebsiteDataStore::processPools(size_t limit) const
 {
     HashSet<RefPtr<WebProcessPool>> processPools;
@@ -2031,9 +1829,6 @@ HashSet<RefPtr<WebProcessPool>> WebsiteDataStore::processPools(size_t limit) con
     if (processPools.isEmpty()) {
         // Check if we're one of the legacy data stores.
         for (auto& processPool : WebProcessPool::allProcessPools()) {
-            if (!isAssociatedProcessPool(*processPool))
-                continue;
-
             processPools.add(processPool);
             if (processPools.size() == limit)
                 break;
@@ -2072,8 +1867,7 @@ static String computeMediaKeyFile(const String& mediaKeyDirectory)
 
 void WebsiteDataStore::allowSpecificHTTPSCertificateForHost(const WebCertificateInfo* certificate, const String& host)
 {
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().send(Messages::NetworkProcess::AllowSpecificHTTPSCertificateForHost(certificate->certificateInfo(), host), 0);
+    networkProcess().send(Messages::NetworkProcess::AllowSpecificHTTPSCertificateForHost(certificate->certificateInfo(), host), 0);
 }
 
 Vector<WebCore::SecurityOriginData> WebsiteDataStore::mediaKeyOrigins(const String& mediaKeysStorageDirectory)
@@ -2128,6 +1922,52 @@ void WebsiteDataStore::removeMediaKeys(const String& mediaKeysStorageDirectory,
     }
 }
 
+void WebsiteDataStore::getNetworkProcessConnection(WebProcessProxy& webProcessProxy, CompletionHandler<void(const NetworkProcessConnectionInfo&)>&& reply)
+{
+    networkProcess().getNetworkProcessConnection(webProcessProxy, [this, weakThis = makeWeakPtr(*this), webProcessProxy = makeWeakPtr(webProcessProxy), reply = WTFMove(reply)] (auto& connectionInfo) mutable {
+        if (UNLIKELY(!IPC::Connection::identifierIsValid(connectionInfo.identifier()) && webProcessProxy && weakThis)) {
+            terminateNetworkProcess();
+            RELEASE_LOG_IF(isPersistent(), Process, "getNetworkProcessConnection: Failed first attempt, retrying");
+            networkProcess().getNetworkProcessConnection(*webProcessProxy, WTFMove(reply));
+            return;
+        }
+        reply(connectionInfo);
+    });
+}
+
+void WebsiteDataStore::networkProcessCrashed(NetworkProcessProxy&)
+{
+    if (m_networkProcess)
+        m_networkProcess->didTerminate();
+    m_networkProcess = nullptr;
+}
+
+void WebsiteDataStore::terminateNetworkProcess()
+{
+    for (auto* processPool : WebProcessPool::allProcessPools())
+        processPool->terminateServiceWorkers();
+
+    if (!m_networkProcess)
+        return;
+    m_networkProcess->terminate();
+    m_networkProcess = nullptr;
+}
+
+void WebsiteDataStore::sendNetworkProcessPrepareToSuspendForTesting(CompletionHandler<void()>&& completionHandler)
+{
+    networkProcess().sendPrepareToSuspend(IsSuspensionImminent::No, WTFMove(completionHandler));
+}
+
+void WebsiteDataStore::sendNetworkProcessWillSuspendImminentlyForTesting()
+{
+    networkProcess().sendProcessWillSuspendImminentlyForTesting();
+}
+
+void WebsiteDataStore::sendNetworkProcessDidResume()
+{
+    networkProcess().sendProcessDidResume();
+}
+
 bool WebsiteDataStore::resourceLoadStatisticsEnabled() const
 {
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
@@ -2157,17 +1997,15 @@ void WebsiteDataStore::setResourceLoadStatisticsEnabled(bool enabled)
         
         resolveDirectoriesIfNecessary();
         
-        for (auto& processPool : processPools()) {
-            processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, true));
+        networkProcess().send(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, true), 0);
+        for (auto& processPool : processPools())
             processPool->sendToAllProcessesForSession(Messages::WebProcess::SetResourceLoadStatisticsEnabled(true), m_sessionID);
-        }
         return;
     }
 
-    for (auto& processPool : processPools()) {
-        processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, false));
+    networkProcess().send(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(m_sessionID, false), 0);
+    for (auto& processPool : processPools())
         processPool->sendToAllProcessesForSession(Messages::WebProcess::SetResourceLoadStatisticsEnabled(false), m_sessionID);
-    }
 
     m_resourceLoadStatisticsEnabled = false;
 #else
@@ -2179,8 +2017,7 @@ void WebsiteDataStore::setResourceLoadStatisticsEnabled(bool enabled)
 void WebsiteDataStore::setStatisticsTestingCallback(Function<void(const String&)>&& callback)
 {
     if (callback) {
-        for (auto& processPool : processPools())
-            processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsLogTestingEvent(true));
+        networkProcess().send(Messages::NetworkProcess::SetResourceLoadStatisticsLogTestingEvent(true), 0);
     }
     
     m_statisticsTestingCallback = WTFMove(callback);
@@ -2199,8 +2036,7 @@ void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled, Completi
 
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setResourceLoadStatisticsDebugMode(m_sessionID, enabled, [callbackAggregator] { });
+    networkProcess().setResourceLoadStatisticsDebugMode(m_sessionID, enabled, [callbackAggregator] { });
 #else
     UNUSED_PARAM(enabled);
     UNUSED_PARAM(completionHandler);
@@ -2215,20 +2051,15 @@ void WebsiteDataStore::isResourceLoadStatisticsEphemeral(CompletionHandler<void(
         return;
     }
 
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess()) {
-            networkProcess->isResourceLoadStatisticsEphemeral(m_sessionID, WTFMove(completionHandler));
-            return;
-        }
-    }
-#endif
+    networkProcess().isResourceLoadStatisticsEphemeral(m_sessionID, WTFMove(completionHandler));
+#else
     completionHandler(false);
+#endif
 }
 
 void WebsiteDataStore::setAdClickAttributionDebugMode(bool enabled)
 {
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().setAdClickAttributionDebugMode(enabled);
+    networkProcess().setAdClickAttributionDebugMode(enabled);
 }
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
@@ -2250,48 +2081,19 @@ void WebsiteDataStore::clearResourceLoadStatisticsInWebProcesses(CompletionHandl
 }
 #endif
 
-Vector<WebCore::Cookie> WebsiteDataStore::pendingCookies() const
-{
-    return copyToVector(m_pendingCookies);
-}
-
-void WebsiteDataStore::addPendingCookie(const WebCore::Cookie& cookie)
-{
-    m_pendingCookies.removeIf([&cookie](auto& pendingCookie) {
-        return pendingCookie.isKeyEqual(cookie);
-    });
-    m_pendingCookies.add(cookie);
-}
-
-void WebsiteDataStore::removePendingCookie(const WebCore::Cookie& cookie)
-{
-    m_pendingCookies.remove(cookie);
-}
-    
-void WebsiteDataStore::clearPendingCookies()
-{
-    m_pendingCookies.clear();
-}
-
 void WebsiteDataStore::flushCookies(CompletionHandler<void()>&& completionHandler)
 {
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-    for (auto processPool : WebProcessPool::allProcessPools())
-        processPool->flushCookies(sessionID(), [callbackAggregator] { });
+    networkProcess().flushCookies(sessionID(), WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::setAllowsAnySSLCertificateForWebSocket(bool allows)
 {
-    for (auto processPool : WebProcessPool::allProcessPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->sendSync(Messages::NetworkProcess::SetAllowsAnySSLCertificateForWebSocket(allows), Messages::NetworkProcess::SetAllowsAnySSLCertificateForWebSocket::Reply(), 0);
-    }
+    networkProcess().sendSync(Messages::NetworkProcess::SetAllowsAnySSLCertificateForWebSocket(allows), Messages::NetworkProcess::SetAllowsAnySSLCertificateForWebSocket::Reply(), 0);
 }
 
 void WebsiteDataStore::clearCachedCredentials()
 {
-    for (auto processPool : WebProcessPool::allProcessPools())
-        processPool->clearCachedCredentials(sessionID());
+    networkProcess().send(Messages::NetworkProcess::ClearCachedCredentials(sessionID()), 0);
 }
 
 void WebsiteDataStore::dispatchOnQueue(Function<void()>&& function)
@@ -2317,8 +2119,6 @@ WebsiteDataStoreParameters WebsiteDataStore::parameters()
 
     resolveDirectoriesIfNecessary();
 
-    parameters.pendingCookies = pendingCookies();
-
     auto resourceLoadStatisticsDirectory = m_configuration->resourceLoadStatisticsDirectory();
     SandboxExtension::Handle resourceLoadStatisticsDirectoryHandle;
     if (!resourceLoadStatisticsDirectory.isEmpty())
@@ -2423,7 +2223,10 @@ WebsiteDataStoreParameters WebsiteDataStore::parameters()
     parameters.networkSessionParameters.resourceLoadStatisticsParameters.enabled = m_resourceLoadStatisticsEnabled;
 #endif
     platformSetNetworkParameters(parameters);
-
+#if PLATFORM(COCOA)
+    parameters.networkSessionParameters.appHasRequestedCrossWebsiteTrackingPermission = hasRequestedCrossWebsiteTrackingPermission();
+#endif
+    
     return parameters;
 }
 
@@ -2453,10 +2256,6 @@ API::HTTPCookieStore& WebsiteDataStore::cookieStore()
     return *m_cookieStore;
 }
 
-void WebsiteDataStore::didCreateNetworkProcess()
-{
-}
-
 void WebsiteDataStore::getLocalStorageDetails(Function<void(Vector<LocalStorageDatabaseTracker::OriginDetails>&&)>&& completionHandler)
 {
     if (!isPersistent()) {
@@ -2464,23 +2263,15 @@ void WebsiteDataStore::getLocalStorageDetails(Function<void(Vector<LocalStorageD
         return;
     }
 
-    for (auto& processPool : ensureProcessPools()) {
-        processPool->ensureNetworkProcess(this).getLocalStorageDetails(m_sessionID, [completionHandler = WTFMove(completionHandler)](auto&& details) {
-            completionHandler(WTFMove(details));
-        });
-        // FIXME: Support fetching from multiple pools.
-        break;
-    }
-    ASSERT(!completionHandler);
+    networkProcess().getLocalStorageDetails(m_sessionID, [completionHandler = WTFMove(completionHandler)](auto&& details) {
+        completionHandler(WTFMove(details));
+    });
 }
 
 void WebsiteDataStore::resetQuota(CompletionHandler<void()>&& completionHandler)
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-    for (auto& processPool : processPools()) {
-        if (auto* process = processPool->networkProcess())
-            process->resetQuota(m_sessionID, [callbackAggregator] { });
-    }
+    networkProcess().resetQuota(m_sessionID, [callbackAggregator] { });
 }
 
 #if !PLATFORM(COCOA)
@@ -2506,7 +2297,12 @@ bool WebsiteDataStore::http3Enabled()
 {
     return false;
 }
-#endif
+
+bool WebsiteDataStore::networkProcessHasEntitlementForTesting(const String&)
+{
+    return false;
+}
+#endif // !PLATFORM(COCOA)
 
 #if !USE(GLIB)
 WTF::String WebsiteDataStore::defaultDeviceIdHashSaltsStorageDirectory()
@@ -2518,35 +2314,18 @@ WTF::String WebsiteDataStore::defaultDeviceIdHashSaltsStorageDirectory()
 
 void WebsiteDataStore::renameOriginInWebsiteData(URL&& oldName, URL&& newName, OptionSet<WebsiteDataType> dataTypes, CompletionHandler<void()>&& completionHandler)
 {
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-    for (auto& processPool : WebProcessPool::allProcessPools()) {
-        if (auto* networkProcess = processPool->networkProcess()) {
-            networkProcess->addSession(*this);
-            networkProcess->renameOriginInWebsiteData(m_sessionID, oldName, newName, dataTypes, [callbackAggregator] { });
-        }
-    }
+    networkProcess().renameOriginInWebsiteData(m_sessionID, oldName, newName, dataTypes, WTFMove(completionHandler));
 }
 
 #if ENABLE(APP_BOUND_DOMAINS)
 void WebsiteDataStore::hasAppBoundSession(CompletionHandler<void(bool)>&& completionHandler) const
 {
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess()) {
-            networkProcess->hasAppBoundSession(m_sessionID, WTFMove(completionHandler));
-            return;
-        }
-    }
-    completionHandler(false);
+    networkProcess().hasAppBoundSession(m_sessionID, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::clearAppBoundSession(CompletionHandler<void()>&& completionHandler)
 {
-    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
-
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->clearAppBoundSession(m_sessionID, [processPool, callbackAggregator] { });
-    }
+    networkProcess().clearAppBoundSession(m_sessionID, WTFMove(completionHandler));
 }
 
 void WebsiteDataStore::forwardAppBoundDomainsToITPIfInitialized(CompletionHandler<void()>&& completionHandler)
@@ -2568,7 +2347,7 @@ void WebsiteDataStore::forwardAppBoundDomainsToITPIfInitialized(CompletionHandle
 
     propagateAppBoundDomains(globalDefaultDataStore().get(), *appBoundDomains);
 
-    for (auto* store : nonDefaultDataStores().values())
+    for (auto* store : allDataStores().values())
         propagateAppBoundDomains(store, *appBoundDomains);
 }
 
@@ -2576,10 +2355,7 @@ void WebsiteDataStore::setAppBoundDomainsForITP(const HashSet<WebCore::Registrab
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools()) {
-        if (auto* networkProcess = processPool->networkProcess())
-            networkProcess->setAppBoundDomainsForResourceLoadStatistics(m_sessionID, domains, [callbackAggregator] { });
-    }
+    networkProcess().setAppBoundDomainsForResourceLoadStatistics(m_sessionID, domains, [callbackAggregator] { });
 }
 #endif
 
@@ -2587,16 +2363,26 @@ void WebsiteDataStore::updateBundleIdentifierInNetworkProcess(const String& bund
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().updateBundleIdentifier(bundleIdentifier, [callbackAggregator] { });
+    networkProcess().updateBundleIdentifier(bundleIdentifier, [callbackAggregator] { });
 }
 
 void WebsiteDataStore::clearBundleIdentifierInNetworkProcess(CompletionHandler<void()>&& completionHandler)
 {
     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
 
-    for (auto& processPool : processPools())
-        processPool->ensureNetworkProcess().clearBundleIdentifier([callbackAggregator] { });
+    networkProcess().clearBundleIdentifier([callbackAggregator] { });
+}
+
+static bool nextNetworkProcessLaunchShouldFailForTesting { false };
+
+void WebsiteDataStore::makeNextNetworkProcessLaunchFailForTesting()
+{
+    nextNetworkProcessLaunchShouldFailForTesting = true;
+}
+
+bool WebsiteDataStore::shouldMakeNextNetworkProcessLaunchFailForTesting()
+{
+    return std::exchange(nextNetworkProcessLaunchShouldFailForTesting, false);
 }
 
 }
index 4f04e90..ae8e313 100644 (file)
@@ -53,6 +53,8 @@
 
 #if PLATFORM(COCOA)
 #include <pal/spi/cf/CFNetworkSPI.h>
+#include <wtf/OSObjectPtr.h>
+#include <wtf/spi/darwin/XPCSPI.h>
 #endif
 
 #if USE(CURL)
@@ -79,6 +81,7 @@ namespace WebKit {
 class AuthenticatorManager;
 class SecKeyProxyStore;
 class DeviceIdHashSaltStorage;
+class NetworkProcessProxy;
 class SOAuthorizationCoordinator;
 class WebCertificateInfo;
 class WebPageProxy;
@@ -88,6 +91,8 @@ class WebResourceLoadStatisticsStore;
 enum class CacheModel : uint8_t;
 enum class WebsiteDataFetchOption : uint8_t;
 enum class WebsiteDataType : uint32_t;
+
+struct NetworkProcessConnectionInfo;
 struct WebsiteDataRecord;
 struct WebsiteDataStoreParameters;
 
@@ -113,7 +118,12 @@ public:
     WebsiteDataStore(Ref<WebsiteDataStoreConfiguration>&&, PAL::SessionID);
     ~WebsiteDataStore();
 
-    static WebsiteDataStore* existingNonDefaultDataStoreForSessionID(PAL::SessionID);
+    static void forEachWebsiteDataStore(Function<void(WebsiteDataStore&)>&&);
+    
+    NetworkProcessProxy& networkProcess() const;
+    NetworkProcessProxy& networkProcess();
+
+    static WebsiteDataStore* existingDataStoreForSessionID(PAL::SessionID);
 
     bool isPersistent() const { return !m_sessionID.isEphemeral(); }
     PAL::SessionID sessionID() const { return m_sessionID; }
@@ -123,6 +133,15 @@ public:
     
     const WeakHashSet<WebProcessProxy>& processes() const { return m_processes; }
 
+    void getNetworkProcessConnection(WebProcessProxy&, CompletionHandler<void(const NetworkProcessConnectionInfo&)>&&);
+    void terminateNetworkProcess();
+    void sendNetworkProcessPrepareToSuspendForTesting(CompletionHandler<void()>&&);
+    void sendNetworkProcessWillSuspendImminentlyForTesting();
+    void sendNetworkProcessDidResume();
+    void networkProcessCrashed(NetworkProcessProxy&);
+    static void makeNextNetworkProcessLaunchFailForTesting();
+    static bool shouldMakeNextNetworkProcessLaunchFailForTesting();
+
     bool resourceLoadStatisticsEnabled() const;
     void setResourceLoadStatisticsEnabled(bool);
     bool resourceLoadStatisticsDebugMode() const;
@@ -238,15 +257,8 @@ public:
 
     DeviceIdHashSaltStorage& deviceIdHashSaltStorage() { return m_deviceIdHashSaltStorage.get(); }
 
-    WebProcessPool* processPoolForCookieStorageOperations();
-    bool isAssociatedProcessPool(WebProcessPool&) const;
-
     WebsiteDataStoreParameters parameters();
 
-    Vector<WebCore::Cookie> pendingCookies() const;
-    void addPendingCookie(const WebCore::Cookie&);
-    void removePendingCookie(const WebCore::Cookie&);
-    void clearPendingCookies();
     void flushCookies(CompletionHandler<void()>&&);
     void clearCachedCredentials();
 
@@ -254,6 +266,11 @@ public:
 
     void dispatchOnQueue(Function<void()>&&);
 
+#if PLATFORM(COCOA)
+    void sendNetworkProcessXPCEndpointToWebProcess(WebProcessProxy&);
+    void sendNetworkProcessXPCEndpointToAllWebProcesses();
+#endif
+
 #if USE(CURL)
     void setNetworkProxySettings(WebCore::CurlProxySettings&&);
     const WebCore::CurlProxySettings& networkProxySettings() const { return m_proxySettings; }
@@ -279,8 +296,6 @@ public:
     void setMockWebAuthenticationConfiguration(WebCore::MockWebAuthenticationConfiguration&&);
 #endif
 
-    void didCreateNetworkProcess();
-
     const WebsiteDataStoreConfiguration& configuration() { return m_configuration.get(); }
 
     WebsiteDataStoreClient& client() { return m_client.get(); }
@@ -290,6 +305,8 @@ public:
 
     void renameOriginInWebsiteData(URL&&, URL&&, OptionSet<WebsiteDataType>, CompletionHandler<void()>&&);
 
+    bool networkProcessHasEntitlementForTesting(const String&);
+
 #if ENABLE(DEVICE_ORIENTATION)
     WebDeviceOrientationAndMotionAccessController& deviceOrientationAndMotionAccessController() { return m_deviceOrientationAndMotionAccessController; }
 #endif
@@ -366,7 +383,7 @@ private:
     static void removeMediaKeys(const String& mediaKeysStorageDirectory, WallTime modifiedSince);
     static void removeMediaKeys(const String& mediaKeysStorageDirectory, const HashSet<WebCore::SecurityOriginData>&);
 
-    void maybeRegisterWithSessionIDMap();
+    void registerWithSessionIDMap();
 
 #if ENABLE(APP_BOUND_DOMAINS)
     static Optional<HashSet<WebCore::RegistrableDomain>> appBoundDomainsIfInitialized();
@@ -406,8 +423,6 @@ private:
     WebCore::SoupNetworkProxySettings m_networkProxySettings;
 #endif
 
-    HashSet<WebCore::Cookie> m_pendingCookies;
-    
     WeakHashSet<WebProcessProxy> m_processes;
 
     bool m_isItpStateExplicitlySet { false };
@@ -428,6 +443,7 @@ private:
     UniqueRef<WebsiteDataStoreClient> m_client;
 
     RefPtr<API::HTTPCookieStore> m_cookieStore;
+    RefPtr<NetworkProcessProxy> m_networkProcess;
 
 #if HAVE(APP_SSO)
     UniqueRef<SOAuthorizationCoordinator> m_soAuthorizationCoordinator;
index 0e0c06e..64b6c74 100644 (file)
@@ -42,8 +42,7 @@ void WebsiteDataStore::setNetworkProxySettings(WebCore::CurlProxySettings&& prox
 {
     m_proxySettings = WTFMove(proxySettings);
 
-    for (auto& processPool : processPools())
-        processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetNetworkProxySettings(m_sessionID, m_proxySettings));
+    networkProcess().send(Messages::NetworkProcess::SetNetworkProxySettings(m_sessionID, m_proxySettings), 0);
 }
 
 }
index 14d7ff4..704a9b6 100644 (file)
@@ -42,8 +42,7 @@ void WebsiteDataStore::platformSetNetworkParameters(WebsiteDataStoreParameters&
     networkSessionParameters.ignoreTLSErrors = m_ignoreTLSErrors;
     networkSessionParameters.proxySettings = m_networkProxySettings;
 
-    if (auto* processPool = processPoolForCookieStorageOperations())
-        processPool->supplement<WebCookieManagerProxy>()->getCookiePersistentStorage(m_sessionID, networkSessionParameters.cookiePersistentStoragePath, networkSessionParameters.cookiePersistentStorageType);
+    networkProcess().cookieManager().getCookiePersistentStorage(m_sessionID, networkSessionParameters.cookiePersistentStoragePath, networkSessionParameters.cookiePersistentStorageType);
 }
 
 void WebsiteDataStore::setPersistentCredentialStorageEnabled(bool enabled)
@@ -55,8 +54,7 @@ void WebsiteDataStore::setPersistentCredentialStorageEnabled(bool enabled)
         return;
 
     m_persistentCredentialStorageEnabled = enabled;
-    for (auto& processPool : processPools())
-        processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetPersistentCredentialStorageEnabled(m_sessionID, m_persistentCredentialStorageEnabled));
+    networkProcess().send(Messages::NetworkProcess::SetPersistentCredentialStorageEnabled(m_sessionID, m_persistentCredentialStorageEnabled), 0);
 }
 
 void WebsiteDataStore::setIgnoreTLSErrors(bool ignoreTLSErrors)
@@ -65,15 +63,13 @@ void WebsiteDataStore::setIgnoreTLSErrors(bool ignoreTLSErrors)
         return;
 
     m_ignoreTLSErrors = ignoreTLSErrors;
-    for (auto& processPool : processPools())
-        processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetIgnoreTLSErrors(m_sessionID, m_ignoreTLSErrors));
+    networkProcess().send(Messages::NetworkProcess::SetIgnoreTLSErrors(m_sessionID, m_ignoreTLSErrors), 0);
 }
 
 void WebsiteDataStore::setNetworkProxySettings(WebCore::SoupNetworkProxySettings&& settings)
 {
     m_networkProxySettings = WTFMove(settings);
-    for (auto& processPool : processPools())
-        processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetNetworkProxySettings(m_sessionID, m_networkProxySettings));
+    networkProcess().send(Messages::NetworkProcess::SetNetworkProxySettings(m_sessionID, m_networkProxySettings), 0);
 }
 
 } // namespace WebKit
index 0a84a75..27f23ea 100644 (file)
@@ -44,7 +44,7 @@ void WebProcessProxy::platformGetLaunchOptions(ProcessLauncher::LaunchOptions& l
         if (!dataStore) {
             // Prewarmed processes don't have a WebsiteDataStore yet, so use the primary WebsiteDataStore from the WebProcessPool.
             // The process won't be used if current WebsiteDataStore is different than the WebProcessPool primary one.
-            dataStore = m_processPool->websiteDataStore();
+            dataStore = WebsiteDataStore::defaultDataStore().ptr();
         }
 
         ASSERT(dataStore);
index 9f7be3c..ac04e38 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WebCookieManagerProxy.h"
 
+#include "NetworkProcessProxy.h"
 #include "WebCookieManagerMessages.h"
 #include "WebProcessPool.h"
 
@@ -33,8 +34,8 @@ namespace WebKit {
 
 void WebCookieManagerProxy::setCookiePersistentStorage(PAL::SessionID sessionID, const String& storagePath, SoupCookiePersistentStorageType storageType)
 {
-    m_cookiePersistentStorageMap.set(sessionID, std::make_pair(storagePath, storageType));
-    processPool()->sendToNetworkingProcess(Messages::WebCookieManager::SetCookiePersistentStorage(sessionID, storagePath, storageType));
+    if (m_networkProcess)
+        m_networkProcess->send(Messages::WebCookieManager::SetCookiePersistentStorage(sessionID, storagePath, storageType), 0);
 }
 
 void WebCookieManagerProxy::getCookiePersistentStorage(PAL::SessionID sessionID, String& storagePath, SoupCookiePersistentStorageType& storageType) const
index 03a9b36..05bd2f6 100644 (file)
@@ -37,15 +37,6 @@ namespace WebKit {
 
 void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)
 {
-    NetworkSessionCreationParameters& defaultSessionParameters = parameters.defaultDataStoreParameters.networkSessionParameters;
-    supplement<WebCookieManagerProxy>()->getCookiePersistentStorage(defaultSessionParameters.sessionID, defaultSessionParameters.cookiePersistentStoragePath, defaultSessionParameters.cookiePersistentStorageType);
-    if (m_websiteDataStore) {
-        defaultSessionParameters.persistentCredentialStorageEnabled = m_websiteDataStore->persistentCredentialStorageEnabled();
-        defaultSessionParameters.ignoreTLSErrors = m_websiteDataStore->ignoreTLSErrors();
-        defaultSessionParameters.proxySettings = m_websiteDataStore->networkProxySettings();
-    }
-
-    parameters.cookieAcceptPolicy = m_initialHTTPCookieAcceptPolicy;
     parameters.languages = userPreferredLanguages();
 }
 
index a98f9be..07ff336 100644 (file)
@@ -1,3 +1,98 @@
+2020-09-29  Alex Christensen  <achristensen@webkit.org>
+
+        Move NetworkProcessProxy ownership from WebProcessPool to WebsiteDataStore
+        https://bugs.webkit.org/show_bug.cgi?id=216041
+
+        Reviewed by Brady Eidson.
+
+        Most changes to tests are just calling a function on the WKWebsiteDataStore instead of the WKProcessPool
+        because we want to do something with the network process and it has a new owner.
+        Exceptions are noted inline.
+
+        * TestWebKitAPI/Tests/WebKit/NetworkProcessCrashWithPendingConnection.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
+        (TestWebKitAPI::downloadAtRate):
+        * TestWebKitAPI/Tests/WebKitCocoa/IDBCheckpointWAL.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/IDBDeleteRecovery.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/IDBIndexUpgradeToV2.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/IDBObjectStoreInfoUpgradeToV2.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/IndexedDBDatabaseProcessKill.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/IndexedDBMultiProcess.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/IndexedDBPersistence.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/IndexedDBSuspendImminently.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/IndexedDBTempFileSize.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/NetworkProcess.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/NetworkProcessCrashNonPersistentDataStore.mm:
+        (checkRecoveryAfterCrash):
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+        * TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:
+        (TEST):
+        This test was making a WKWebsiteDataStore, getting its resource load statistics directory,
+        putting things in that directory, then starting the network process and making sure everything
+        works when initializing the network process.  Now, network process initialization happens when a
+        WKWebsiteDataStore is instantiated, so we need to put things there before instantiating a WKWebsiteDataStore.
+        * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+        Before this change, each WKProcessPool had its own network process, which holds the service worker registry
+        for the WebsiteDataStores used with that process pool.  Now, the network process still needs to have a service
+        worker registry in it, but when we receive a message from it looking for a web process to run the service
+        worker, we go arbitrarily to the first process pool that has a process we can use.  This logic is in 
+        WebProcessPool::establishWorkerContextConnectionToNetworkProcess.  Because we use the first process pool each
+        time, setting the custom user agent to two different things in two different process pools causes only one
+        to be used.  This is not a problem in practice, though, because the only application that uses the SPI to
+        set a service worker's custom user agent is Safari, which only has one process pool.  This test still verifies
+        that a user ageint is correctly sent.
+        Similarly, the tests that count service worker processes either have different results or need to be run with
+        one process pool per parent process.  To keep the results the same, I separated the tests into different
+        TEST(ServiceWorkers, ...) macros which are run in separate parent processes.
+        The test RestoreFromDiskNonDefaultStore needs to use the same data store for both WKWebViews now because otherwise
+        there was a race condition in the startup of a new network process that wasn't there before because we were using the
+        same process pool and therefore the same network process.  I added spinning the run loop and sleeping to be able to
+        reproduce the race condition failure and I use the same WKWebsiteDataStore to use the same network process, which was
+        the intent of using the same WKProcessPool before.  The test still tests that the registration is re-used when we are
+        not using the default data store.
+        * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+        * TestWebKitAPI/Tests/WebKitCocoa/WKHTTPCookieStore.mm:
+        (-[CheckSessionCookieUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+        (-[CheckSessionCookieUIDelegate waitForMessage]):
+        (-[CheckSessionCookieUIDelegate alertCookieHTML]):
+        (TEST):
+        This is the whole point of me doing this.
+        I took a test that was flaky only on iOS (because of different NSHTTPCookieStorage syncing behavior) and made
+        it flaky nowhere (fingers crossed!) and added a test that correctly handles session cookies like we could not
+        before this change.
+        I also re-used some test infrastructure and made it stop using process-global static variables for test state.
+        * TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-leaks.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/WebsiteDataStoreCustomPaths.mm:
+        (runWebsiteDataStoreCustomPaths):
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitObjC/CustomProtocolsTest.mm:
+        (-[CloseWhileStartingProtocol startLoading]):
+        (TestWebKitAPI::runTest):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetStateToConsistentValues):
+        (WTR::TestController::findAndDumpWebKitProcessIdentifiers):
+        (WTR::TestController::networkProcessDidCrash):
+        (WTR::TestController::terminateNetworkProcess):
+        (WTR::TestController::platformAdjustContext):
+        WKContextSetAllowsAnySSLCertificateForServiceWorkerTesting is not needed, so I removed it.
+        WKContextSetPrimaryWebsiteDataStore isn't needed any more because WKContextRef (WebProcessPool) doesn't
+        own a network process any more, so it doesn't care which is the default WebsiteDataStore.
+        In fact, the "default" WebsiteDataStore isn't really important in the network process any more.
+
 2020-09-26  Darin Adler  <darin@apple.com>
 
         Refactor test runner code to cut down on copy/paste code and long-winded repetitive idioms
index 97389f0..97b72e0 100644 (file)
@@ -32,6 +32,7 @@
 #import <WebKit/WKProcessGroupPrivate.h>
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/WebKit.h>
 #import <wtf/RetainPtr.h>
 
@@ -87,7 +88,7 @@ TEST(WebKit, NetworkProcessCrashWithPendingConnection)
     pid_t webView2PID = [webView2.get() _webProcessIdentifier];
     EXPECT_NE(webView1PID, webView2PID);
 
-    pid_t initialNetworkProcessIdentififer = [processPool.get() _networkProcessIdentifier];
+    pid_t initialNetworkProcessIdentififer = [configuration.get().websiteDataStore _networkProcessIdentifier];
     EXPECT_NE(initialNetworkProcessIdentififer, 0);
     kill(initialNetworkProcessIdentififer, SIGKILL);
     Util::run(&networkProcessCrashed);
@@ -96,7 +97,7 @@ TEST(WebKit, NetworkProcessCrashWithPendingConnection)
     [webView1.get() loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
     [webView1.get() _test_waitForDidFinishNavigation];
 
-    pid_t relaunchedNetworkProcessIdentifier = [processPool.get() _networkProcessIdentifier];
+    pid_t relaunchedNetworkProcessIdentifier = [configuration.get().websiteDataStore _networkProcessIdentifier];
     EXPECT_NE(initialNetworkProcessIdentififer, relaunchedNetworkProcessIdentifier);
     EXPECT_FALSE(networkProcessCrashed);
 
@@ -146,8 +147,8 @@ TEST(WebKit, NetworkProcessRelaunchOnLaunchFailure)
 
     // Constucting a WebView starts a network process so terminate this one. The page load below will then request a network process and we
     // make this new network process launch crash on startup.
-    [processPool _terminateNetworkProcess];
-    [processPool _makeNextNetworkProcessLaunchFailForTesting];
+    [WKWebsiteDataStore _makeNextNetworkProcessLaunchFailForTesting];
+    [configuration.get().websiteDataStore _terminateNetworkProcess];
 
     auto delegate = adoptNS([[MonitorWebContentCrashNavigationDelegate alloc] init]);
     [webView setNavigationDelegate:delegate.get()];
@@ -158,7 +159,7 @@ TEST(WebKit, NetworkProcessRelaunchOnLaunchFailure)
     EXPECT_TRUE(networkProcessCrashed);
     EXPECT_FALSE(webProcessCrashed);
     EXPECT_GT([webView _webProcessIdentifier], 0);
-    EXPECT_GT([processPool.get() _networkProcessIdentifier], 0);
+    EXPECT_GT([configuration.get().websiteDataStore _networkProcessIdentifier], 0);
 }
 
 } // namespace TestWebKitAPI
index b7ed999..1819131 100644 (file)
@@ -889,9 +889,9 @@ void downloadAtRate(double desiredKbps, unsigned speedMultiplier, AppReturnsToFo
     receivedData = false;
     Util::run(&receivedData);
     // Start the DownloadMonitor's timer.
-    [[webView configuration].processPool _synthesizeAppIsBackground:YES];
+    [[webView configuration].websiteDataStore _synthesizeAppIsBackground:YES];
     if (returnToForeground == AppReturnsToForeground::Yes)
-        [[webView configuration].processPool _synthesizeAppIsBackground:NO];
+        [[webView configuration].websiteDataStore _synthesizeAppIsBackground:NO];
     didCancel = false;
     Util::run(&didCancel);
     terminateServer = true;
index 5cd7abd..d77a6fd 100644 (file)
@@ -31,6 +31,7 @@
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKUserContentControllerPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/WebKit.h>
 #import <WebKit/_WKProcessPoolConfiguration.h>
 #import <WebKit/_WKUserStyleSheet.h>
@@ -86,7 +87,7 @@ TEST(IndexedDB, CheckpointsWALAutomatically)
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
 
-    [configuration.get().processPool _terminateNetworkProcess];
+    [configuration.get().websiteDataStore _terminateNetworkProcess];
 
     RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
 
index c8af1d2..bbf1a15 100644 (file)
@@ -30,6 +30,7 @@
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKUserContentControllerPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/WebKit.h>
 #import <WebKit/_WKProcessPoolConfiguration.h>
 #import <WebKit/_WKUserStyleSheet.h>
@@ -57,7 +58,7 @@ TEST(IndexedDB, DeleteRecovery)
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
 
-    [configuration.get().processPool _terminateNetworkProcess];
+    [configuration.get().websiteDataStore _terminateNetworkProcess];
 
     // Copy the inconsistent database files to the database directory
     NSURL *url1 = [[NSBundle mainBundle] URLForResource:@"IDBDeleteRecovery" withExtension:@"sqlite3" subdirectory:@"TestWebKitAPI.resources"];
index 416ca1f..968305b 100644 (file)
@@ -31,6 +31,7 @@
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKUserContentControllerPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/WebKit.h>
 #import <WebKit/_WKProcessPoolConfiguration.h>
 #import <WebKit/_WKUserStyleSheet.h>
@@ -58,7 +59,7 @@ TEST(IndexedDB, IndexUpgradeToV2)
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
 
-    [configuration.get().processPool _terminateNetworkProcess];
+    [configuration.get().websiteDataStore _terminateNetworkProcess];
 
     // Copy the inconsistent database files to the database directory
     NSURL *url1 = [[NSBundle mainBundle] URLForResource:@"IndexUpgrade" withExtension:@"sqlite3" subdirectory:@"TestWebKitAPI.resources"];
@@ -90,7 +91,7 @@ static void runMultipleIndicesTestWithDatabase(NSString* databaseName)
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
 
-    [configuration.get().processPool _terminateNetworkProcess];
+    [configuration.get().websiteDataStore _terminateNetworkProcess];
 
     NSURL *url = [[NSBundle mainBundle] URLForResource:databaseName withExtension:@"sqlite3" subdirectory:@"TestWebKitAPI.resources"];
 
index ffa5a78..403e0ff 100644 (file)
@@ -31,6 +31,7 @@
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKUserContentControllerPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/WebKit.h>
 #import <WebKit/_WKProcessPoolConfiguration.h>
 #import <WebKit/_WKUserStyleSheet.h>
@@ -57,7 +58,7 @@ TEST(IndexedDB, IDBObjectStoreInfoUpgradeToV2)
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
 
-    [configuration.get().processPool _terminateNetworkProcess];
+    [configuration.get().websiteDataStore _terminateNetworkProcess];
 
     // Copy database files with old ObjectStoreInfo schema to the database directory.
     NSURL *url1 = [[NSBundle mainBundle] URLForResource:@"IDBObjectStoreInfoUpgrade" withExtension:@"sqlite3" subdirectory:@"TestWebKitAPI.resources"];
index 6874529..73077ec 100644 (file)
@@ -31,6 +31,7 @@
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKUserContentControllerPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/WebKit.h>
 #import <WebKit/_WKProcessPoolConfiguration.h>
 #import <wtf/RetainPtr.h>
@@ -92,7 +93,7 @@ TEST(IndexedDB, DatabaseProcessKill)
         TestWebKitAPI::Util::run(&receivedScriptMessage);
         if (!killedDBProcess && openRequestUpgradeNeeded) {
             killedDBProcess = true;
-            [configuration.get().processPool _terminateNetworkProcess];
+            [configuration.get().websiteDataStore _terminateNetworkProcess];
         }
     }
 
index 7f62645..6f67dc2 100644 (file)
@@ -32,6 +32,7 @@
 #import <WebKit/WKUserContentControllerPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/_WKProcessPoolConfiguration.h>
 #import <WebKit/_WKUserStyleSheet.h>
 #import <wtf/Deque.h>
@@ -69,7 +70,7 @@ TEST(IndexedDB, IndexedDBMultiProcess)
     RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     [[configuration userContentController] addScriptMessageHandler:handler.get() name:@"testHandler"];
 
-    [configuration.get().processPool _terminateNetworkProcess];
+    [configuration.get().websiteDataStore _terminateNetworkProcess];
 
     RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
 
index b32ce4a..d622032 100644 (file)
@@ -78,7 +78,7 @@ TEST(IndexedDB, IndexedDBPersistence)
     webView = nil;
 
     // Terminate the network process
-    [configuration.get().processPool _terminateNetworkProcess];
+    [configuration.get().websiteDataStore _terminateNetworkProcess];
 
     // Make a new web view to finish the test
     webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -268,7 +268,7 @@ TEST(IndexedDB, IndexedDBThirdPartyFrameHasAccess)
 
     webView = nil;
     secondWebView = nil;
-    [configuration.get().processPool _terminateNetworkProcess];
+    [configuration.get().websiteDataStore _terminateNetworkProcess];
 
     // Third-party IDB storage is stored in the memory of network process.
     auto thirdWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
@@ -385,7 +385,7 @@ TEST(IndexedDB, IndexedDBThirdPartyWorkerHasAccess)
 
     webView = nil;
     secondWebView = nil;
-    [configuration.get().processPool _terminateNetworkProcess];
+    [configuration.get().websiteDataStore _terminateNetworkProcess];
 
     auto thirdWebView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
     loadTestPageInWebView(thirdWebView.get(), @"database is created");
index 8ec65f0..510b24f 100644 (file)
@@ -32,6 +32,7 @@
 #import <WebKit/WKProcessPoolPrivate.h>
 #import <WebKit/WKUserContentControllerPrivate.h>
 #import <WebKit/WKWebViewConfigurationPrivate.h>
+#import <WebKit/WKWebsiteDataStorePrivate.h>
 #import <WebKit/WebKit.h>
 #import <WebKit/_WKProcessPoolConfiguration.h>
 #import <wtf/RetainPtr.h>
@@ -88,8 +89,8 @@ TEST(IndexedDB, IndexedDBSuspendImminently)
 
     runTestAndCheckResult(@"Continue");
 
-    [configuration.get().processPool _sendNetworkProcessWillSuspendImminently];
-    [configuration.get().processPool _sendNetworkProcessDidResume];
+    [configuration.get().websiteDataStore _sendNetworkProcessWillSuspendImminently];
+    [configuration.get().websiteDataStore _sendNetworkProcessDidResume];
 
     runTestAndCheckResult(@"Expected Abort For Suspension");
     runTestAndCheckResult(@"Expected Success After Resume");
@@ -158,8 +159,8 @@ TEST(IndexedDB, SuspendImminentlyForThirdPartyDatabases)
     [webView loadHTMLString:mainFrameString baseURL:[NSURL URLWithString:@"http://webkit.org"]];
     runTestAndCheckResult(@"database is created");
 
-    [configuration.get().processPool _sendNetworkProcessWillSuspendImminently];
-    [configuration.get().processPool _sendNetworkProcessDidResume];
+    [configuration.get().websiteDataStore _sendNetworkProcessWillSuspendImminently];
+    [configuration.get()