Skip to content

Commit

Permalink
Move NetworkProcessProxy ownership from WebProcessPool to WebsiteData…
Browse files Browse the repository at this point in the history
…Store

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.



Canonical link: https://commits.webkit.org/229780@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267608 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
achristensen07 committed Sep 25, 2020
1 parent 0a2ed39 commit e200a84
Show file tree
Hide file tree
Showing 87 changed files with 1,559 additions and 1,892 deletions.
415 changes: 415 additions & 0 deletions Source/WebKit/ChangeLog

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions Source/WebKit/NetworkProcess/Cookies/WebCookieManager.cpp
Expand Up @@ -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>
Expand Down Expand Up @@ -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
10 changes: 8 additions & 2 deletions Source/WebKit/NetworkProcess/Cookies/WebCookieManager.h
Expand Up @@ -37,6 +37,8 @@
#include "SoupCookiePersistentStorageType.h"
#endif

OBJC_CLASS NSHTTPCookieStorage;

namespace WebCore {
struct Cookie;
enum class HTTPCookieAcceptPolicy : uint8_t;
Expand Down Expand Up @@ -79,13 +81,17 @@ class WebCookieManager : public NetworkProcessSupplement, public IPC::MessageRec
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);

NetworkProcess& m_process;
};

#if PLATFORM(COCOA)
void saveCookies(NSHTTPCookieStorage *, CompletionHandler<void()>&&);
#endif

} // namespace WebKit
Expand Up @@ -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)
Expand Down
Expand Up @@ -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) {
Expand All @@ -55,6 +55,7 @@ void WebCookieManager::platformSetHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy
m_process.forEachNetworkStorageSession([curlPolicy] (const auto& networkStorageSession) {
networkStorageSession.setCookieAcceptPolicy(curlPolicy);
});
completionHandler();
}

} // namespace WebKit
Expand Up @@ -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 {
Expand All @@ -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] { });
});
}

Expand Down
Expand Up @@ -37,11 +37,12 @@
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)
Expand Down
39 changes: 2 additions & 37 deletions Source/WebKit/NetworkProcess/NetworkProcess.cpp
Expand Up @@ -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();
});
Expand Down Expand Up @@ -347,30 +348,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);

Expand Down Expand Up @@ -505,8 +482,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;
Expand All @@ -521,7 +496,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()) {
Expand All @@ -544,21 +519,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);
}
Expand Down
3 changes: 0 additions & 3 deletions Source/WebKit/NetworkProcess/NetworkProcess.h
Expand Up @@ -170,7 +170,6 @@ class NetworkProcess : public AuxiliaryProcess, private DownloadManager::Client,

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>&&);
Expand Down Expand Up @@ -375,7 +374,6 @@ class NetworkProcess : public AuxiliaryProcess, private DownloadManager::Client,

private:
void platformInitializeNetworkProcess(const NetworkProcessCreationParameters&);
std::unique_ptr<WebCore::NetworkStorageSession> platformCreateDefaultStorageSession() const;

void didReceiveNetworkProcessMessage(IPC::Connection&, IPC::Decoder&);

Expand Down Expand Up @@ -544,7 +542,6 @@ class NetworkProcess : public AuxiliaryProcess, private DownloadManager::Client,

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;

Expand Down
24 changes: 0 additions & 24 deletions Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp
Expand Up @@ -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;
Expand All @@ -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 << shouldEnableITPDatabase;
encoder << enableAdClickAttributionDebugMode;
}
Expand Down Expand Up @@ -114,12 +110,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;
Expand All @@ -136,20 +126,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.shouldEnableITPDatabase))
return false;

Expand Down
Expand Up @@ -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>
Expand Down Expand Up @@ -70,8 +69,6 @@ struct NetworkProcessCreationParameters {
RetainPtr<CFDataRef> networkATSContext;
#endif

WebsiteDataStoreParameters defaultDataStoreParameters;

#if USE(SOUP)
WebCore::HTTPCookieAcceptPolicy cookieAcceptPolicy { WebCore::HTTPCookieAcceptPolicy::AlwaysAccept };
Vector<String> languages;
Expand All @@ -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 shouldEnableITPDatabase { false };
bool enableAdClickAttributionDebugMode { false };
};
Expand Down
Expand Up @@ -214,7 +214,8 @@ void LocalStorageDatabase::clear()

void LocalStorageDatabase::close()
{
ASSERT(!m_isClosed);
if (m_isClosed)
return;
m_isClosed = true;

if (m_didScheduleDatabaseUpdate) {
Expand Down
11 changes: 2 additions & 9 deletions Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
Expand Up @@ -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>
Expand Down Expand Up @@ -78,9 +79,6 @@ static void initializeNetworkSettings()
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());
Expand All @@ -105,11 +103,6 @@ static void initializeNetworkSettings()
[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)
Expand Down Expand Up @@ -221,7 +214,7 @@ static void filterPreloadHSTSEntry(const void* key, const void* value, void* con
platformFlushCookies(sessionID, WTFMove(completionHandler));
}

static void saveCookies(NSHTTPCookieStorage *cookieStorage, CompletionHandler<void()>&& completionHandler)
void saveCookies(NSHTTPCookieStorage *cookieStorage, CompletionHandler<void()>&& completionHandler)
{
ASSERT(RunLoop::isMain());
ASSERT(cookieStorage);
Expand Down
5 changes: 0 additions & 5 deletions Source/WebKit/NetworkProcess/curl/NetworkProcessCurl.cpp
Expand Up @@ -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();
Expand Down
6 changes: 1 addition & 5 deletions Source/WebKit/NetworkProcess/mac/RemoteNetworkingContext.mm
Expand Up @@ -55,15 +55,11 @@
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)));
}

Expand Down

0 comments on commit e200a84

Please sign in to comment.