Prewarmed processes should be usable with any website data store
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Mar 2019 17:01:14 +0000 (17:01 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Mar 2019 17:01:14 +0000 (17:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196104

Reviewed by Alex Christensen.

Source/WebKit:

Split WebsiteDataStore-specific data out of WebProcessCreationParameters and into a new
WebProcessDataStoreParameters struct so that we do not need a WebsiteDataStore in order
to lauch and initialize a WebProcess. When the process finally gets used and we thus
know which WebsiteDataStore they will be used for, we send the WebProcessDataStoreParameters
to the process to that it can do its data store-specific initialization.

This allows prewarmed processes not not have a WebsiteDataStore assocated with them. They
can then be used for any WebsiteDataStore when we need them.

This is also used by our dummy WebProcessProxy since it does not have a backing process and
thus has no associated WebsiteDataStore.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* Shared/WebProcessDataStoreParameters.h: Added.
(WebKit::WebProcessDataStoreParameters::encode const):
(WebKit::WebProcessDataStoreParameters::decode):
* UIProcess/API/C/WKContext.cpp:
(WKContextWarmInitialProcess):
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _warmInitialProcess]):
* UIProcess/ServiceWorkerProcessProxy.cpp:
(WebKit::ServiceWorkerProcessProxy::ServiceWorkerProcessProxy):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::notifyProcessPoolToPrewarm):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
(WebKit::WebProcessPool::createNewWebProcess):
(WebKit::WebProcessPool::tryTakePrewarmedProcess):
(WebKit::WebProcessPool::sendWebProcessDataStoreParameters):
(WebKit::WebProcessPool::initializeNewWebProcess):
(WebKit::WebProcessPool::prewarmProcess):
(WebKit::WebProcessPool::processForRegistrableDomain):
(WebKit::WebProcessPool::createWebPage):
(WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
* UIProcess/WebProcessPool.h:
(WebKit::WebProcessPool::sendToOneProcess):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::create):
(WebKit::WebProcessProxy::WebProcessProxy):
(WebKit::WebProcessProxy::setWebsiteDataStore):
(WebKit::WebProcessProxy::addExistingWebPage):
* UIProcess/WebProcessProxy.h:
(WebKit::WebProcessProxy::websiteDataStore const):
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/MediaCache/WebMediaKeyStorageManager.cpp:
(WebKit::WebMediaKeyStorageManager::setWebsiteDataStore):
* WebProcess/MediaCache/WebMediaKeyStorageManager.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
(WebKit::WebProcess::setWebsiteDataStoreParameters):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:
* WebProcess/WebProcessSupplement.h:
(WebKit::WebProcessSupplement::initialize):
(WebKit::WebProcessSupplement::setWebsiteDataStore):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):
(WebKit::WebProcess::platformSetWebsiteDataStoreParameters):
* WebProcess/win/WebProcessWin.cpp:
(WebKit::WebProcess::platformInitializeWebProcess):
(WebKit::WebProcess::platformSetWebsiteDataStoreParameters):

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WebKitCocoa/ProcessPreWarming.mm:
(runInitialWarmedProcessUsedTest):
(TEST):

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

24 files changed:
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebProcessCreationParameters.cpp
Source/WebKit/Shared/WebProcessCreationParameters.h
Source/WebKit/Shared/WebProcessDataStoreParameters.h [new file with mode: 0644]
Source/WebKit/UIProcess/API/C/WKContext.cpp
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/UIProcess/WebProcessProxy.h
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/MediaCache/WebMediaKeyStorageManager.cpp
Source/WebKit/WebProcess/MediaCache/WebMediaKeyStorageManager.h
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Source/WebKit/WebProcess/WebProcess.messages.in
Source/WebKit/WebProcess/WebProcessSupplement.h
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm
Source/WebKit/WebProcess/glib/WebProcessGLib.cpp
Source/WebKit/WebProcess/win/WebProcessWin.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessPreWarming.mm

index 50a38be..4e4d85b 100644 (file)
@@ -1,3 +1,75 @@
+2019-03-22  Chris Dumez  <cdumez@apple.com>
+
+        Prewarmed processes should be usable with any website data store
+        https://bugs.webkit.org/show_bug.cgi?id=196104
+
+        Reviewed by Alex Christensen.
+
+        Split WebsiteDataStore-specific data out of WebProcessCreationParameters and into a new
+        WebProcessDataStoreParameters struct so that we do not need a WebsiteDataStore in order
+        to lauch and initialize a WebProcess. When the process finally gets used and we thus
+        know which WebsiteDataStore they will be used for, we send the WebProcessDataStoreParameters
+        to the process to that it can do its data store-specific initialization.
+
+        This allows prewarmed processes not not have a WebsiteDataStore assocated with them. They
+        can then be used for any WebsiteDataStore when we need them.
+
+        This is also used by our dummy WebProcessProxy since it does not have a backing process and
+        thus has no associated WebsiteDataStore.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * Shared/WebProcessDataStoreParameters.h: Added.
+        (WebKit::WebProcessDataStoreParameters::encode const):
+        (WebKit::WebProcessDataStoreParameters::decode):
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextWarmInitialProcess):
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (-[WKProcessPool _warmInitialProcess]):
+        * UIProcess/ServiceWorkerProcessProxy.cpp:
+        (WebKit::ServiceWorkerProcessProxy::ServiceWorkerProcessProxy):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::notifyProcessPoolToPrewarm):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
+        (WebKit::WebProcessPool::createNewWebProcess):
+        (WebKit::WebProcessPool::tryTakePrewarmedProcess):
+        (WebKit::WebProcessPool::sendWebProcessDataStoreParameters):
+        (WebKit::WebProcessPool::initializeNewWebProcess):
+        (WebKit::WebProcessPool::prewarmProcess):
+        (WebKit::WebProcessPool::processForRegistrableDomain):
+        (WebKit::WebProcessPool::createWebPage):
+        (WebKit::WebProcessPool::didReachGoodTimeToPrewarm):
+        * UIProcess/WebProcessPool.h:
+        (WebKit::WebProcessPool::sendToOneProcess):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::create):
+        (WebKit::WebProcessProxy::WebProcessProxy):
+        (WebKit::WebProcessProxy::setWebsiteDataStore):
+        (WebKit::WebProcessProxy::addExistingWebPage):
+        * UIProcess/WebProcessProxy.h:
+        (WebKit::WebProcessProxy::websiteDataStore const):
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/MediaCache/WebMediaKeyStorageManager.cpp:
+        (WebKit::WebMediaKeyStorageManager::setWebsiteDataStore):
+        * WebProcess/MediaCache/WebMediaKeyStorageManager.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+        (WebKit::WebProcess::setWebsiteDataStoreParameters):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+        * WebProcess/WebProcessSupplement.h:
+        (WebKit::WebProcessSupplement::initialize):
+        (WebKit::WebProcessSupplement::setWebsiteDataStore):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        (WebKit::WebProcess::platformSetWebsiteDataStoreParameters):
+        * WebProcess/win/WebProcessWin.cpp:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        (WebKit::WebProcess::platformSetWebsiteDataStoreParameters):
+
 2019-03-22  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r242687): Flicker when pinch-zooming pages in macOS Safari
index 1b6ec16..741ffab 100644 (file)
@@ -48,24 +48,13 @@ void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const
     encoder << injectedBundlePathExtensionHandle;
     encoder << additionalSandboxExtensionHandles;
     encoder << initializationUserData;
-    encoder << applicationCacheDirectory;
-    encoder << applicationCacheFlatFileSubdirectoryName;
-    encoder << applicationCacheDirectoryExtensionHandle;
-    encoder << webSQLDatabaseDirectory;
-    encoder << webSQLDatabaseDirectoryExtensionHandle;
-    encoder << mediaCacheDirectory;
-    encoder << mediaCacheDirectoryExtensionHandle;
-    encoder << javaScriptConfigurationDirectory;
-    encoder << javaScriptConfigurationDirectoryExtensionHandle;
 #if PLATFORM(IOS_FAMILY)
     encoder << cookieStorageDirectoryExtensionHandle;
     encoder << containerCachesDirectoryExtensionHandle;
     encoder << containerTemporaryDirectoryExtensionHandle;
 #endif
-    encoder << mediaKeyStorageDirectory;
     encoder << webCoreLoggingChannels;
     encoder << webKitLoggingChannels;
-    encoder << mediaKeyStorageDirectoryExtensionHandle;
 #if ENABLE(MEDIA_STREAM)
     encoder << audioCaptureExtensionHandle;
     encoder << shouldCaptureAudioInUIProcess;
@@ -89,7 +78,6 @@ void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const
     encoder << shouldEnableMemoryPressureReliefLogging;
     encoder << shouldSuppressMemoryPressureHandler;
     encoder << shouldUseFontSmoothing;
-    encoder << resourceLoadStatisticsEnabled;
     encoder << fontWhitelist;
     encoder << terminationTimeout;
     encoder << languages;
@@ -185,43 +173,6 @@ bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreat
     parameters.additionalSandboxExtensionHandles = WTFMove(*additionalSandboxExtensionHandles);
     if (!decoder.decode(parameters.initializationUserData))
         return false;
-    if (!decoder.decode(parameters.applicationCacheDirectory))
-        return false;
-    if (!decoder.decode(parameters.applicationCacheFlatFileSubdirectoryName))
-        return false;
-    
-    Optional<SandboxExtension::Handle> applicationCacheDirectoryExtensionHandle;
-    decoder >> applicationCacheDirectoryExtensionHandle;
-    if (!applicationCacheDirectoryExtensionHandle)
-        return false;
-    parameters.applicationCacheDirectoryExtensionHandle = WTFMove(*applicationCacheDirectoryExtensionHandle);
-
-    if (!decoder.decode(parameters.webSQLDatabaseDirectory))
-        return false;
-
-    Optional<SandboxExtension::Handle> webSQLDatabaseDirectoryExtensionHandle;
-    decoder >> webSQLDatabaseDirectoryExtensionHandle;
-    if (!webSQLDatabaseDirectoryExtensionHandle)
-        return false;
-    parameters.webSQLDatabaseDirectoryExtensionHandle = WTFMove(*webSQLDatabaseDirectoryExtensionHandle);
-
-    if (!decoder.decode(parameters.mediaCacheDirectory))
-        return false;
-    
-    Optional<SandboxExtension::Handle> mediaCacheDirectoryExtensionHandle;
-    decoder >> mediaCacheDirectoryExtensionHandle;
-    if (!mediaCacheDirectoryExtensionHandle)
-        return false;
-    parameters.mediaCacheDirectoryExtensionHandle = WTFMove(*mediaCacheDirectoryExtensionHandle);
-
-    if (!decoder.decode(parameters.javaScriptConfigurationDirectory))
-        return false;
-    
-    Optional<SandboxExtension::Handle> javaScriptConfigurationDirectoryExtensionHandle;
-    decoder >> javaScriptConfigurationDirectoryExtensionHandle;
-    if (!javaScriptConfigurationDirectoryExtensionHandle)
-        return false;
-    parameters.javaScriptConfigurationDirectoryExtensionHandle = WTFMove(*javaScriptConfigurationDirectoryExtensionHandle);
 
 #if PLATFORM(IOS_FAMILY)
     
@@ -244,18 +195,10 @@ bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreat
     parameters.containerTemporaryDirectoryExtensionHandle = WTFMove(*containerTemporaryDirectoryExtensionHandle);
 
 #endif
-    if (!decoder.decode(parameters.mediaKeyStorageDirectory))
-        return false;
     if (!decoder.decode(parameters.webCoreLoggingChannels))
         return false;
     if (!decoder.decode(parameters.webKitLoggingChannels))
         return false;
-    
-    Optional<SandboxExtension::Handle> mediaKeyStorageDirectoryExtensionHandle;
-    decoder >> mediaKeyStorageDirectoryExtensionHandle;
-    if (!mediaKeyStorageDirectoryExtensionHandle)
-        return false;
-    parameters.mediaKeyStorageDirectoryExtensionHandle = WTFMove(*mediaKeyStorageDirectoryExtensionHandle);
 
 #if ENABLE(MEDIA_STREAM)
 
@@ -306,8 +249,6 @@ bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreat
         return false;
     if (!decoder.decode(parameters.shouldUseFontSmoothing))
         return false;
-    if (!decoder.decode(parameters.resourceLoadStatisticsEnabled))
-        return false;
     if (!decoder.decode(parameters.fontWhitelist))
         return false;
     if (!decoder.decode(parameters.terminationTimeout))
index 33a7830..7096d92 100644 (file)
@@ -75,28 +75,17 @@ struct WebProcessCreationParameters {
 
     UserData initializationUserData;
 
-    String applicationCacheDirectory;
-    String applicationCacheFlatFileSubdirectoryName;
-    SandboxExtension::Handle applicationCacheDirectoryExtensionHandle;
-    String webSQLDatabaseDirectory;
-    SandboxExtension::Handle webSQLDatabaseDirectoryExtensionHandle;
-    String mediaCacheDirectory;
-    SandboxExtension::Handle mediaCacheDirectoryExtensionHandle;
-    String javaScriptConfigurationDirectory;
-    SandboxExtension::Handle javaScriptConfigurationDirectoryExtensionHandle;
 #if PLATFORM(IOS_FAMILY)
     SandboxExtension::Handle cookieStorageDirectoryExtensionHandle;
     SandboxExtension::Handle containerCachesDirectoryExtensionHandle;
     SandboxExtension::Handle containerTemporaryDirectoryExtensionHandle;
 #endif
-    SandboxExtension::Handle mediaKeyStorageDirectoryExtensionHandle;
 #if ENABLE(MEDIA_STREAM)
     SandboxExtension::Handle audioCaptureExtensionHandle;
     bool shouldCaptureAudioInUIProcess { false };
     bool shouldCaptureVideoInUIProcess { false };
     bool shouldCaptureDisplayInUIProcess { false };
 #endif
-    String mediaKeyStorageDirectory;
 
     String webCoreLoggingChannels;
     String webKitLoggingChannels;
@@ -128,7 +117,6 @@ struct WebProcessCreationParameters {
     bool shouldEnableMemoryPressureReliefLogging { false };
     bool shouldSuppressMemoryPressureHandler { false };
     bool shouldUseFontSmoothing { true };
-    bool resourceLoadStatisticsEnabled { false };
     bool fullKeyboardAccessEnabled { false };
     bool memoryCacheDisabled { false };
     bool attrStyleEnabled { false };
diff --git a/Source/WebKit/Shared/WebProcessDataStoreParameters.h b/Source/WebKit/Shared/WebProcessDataStoreParameters.h
new file mode 100644 (file)
index 0000000..2697b9b
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebKit {
+
+struct WebProcessDataStoreParameters {
+    String applicationCacheDirectory;
+    SandboxExtension::Handle applicationCacheDirectoryExtensionHandle;
+    String applicationCacheFlatFileSubdirectoryName;
+    String webSQLDatabaseDirectory;
+    SandboxExtension::Handle webSQLDatabaseDirectoryExtensionHandle;
+    String mediaCacheDirectory;
+    SandboxExtension::Handle mediaCacheDirectoryExtensionHandle;
+    String mediaKeyStorageDirectory;
+    SandboxExtension::Handle mediaKeyStorageDirectoryExtensionHandle;
+    String javaScriptConfigurationDirectory;
+    SandboxExtension::Handle javaScriptConfigurationDirectoryExtensionHandle;
+    bool resourceLoadStatisticsEnabled { false };
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static Optional<WebProcessDataStoreParameters> decode(Decoder&);
+};
+
+template<class Encoder>
+void WebProcessDataStoreParameters::encode(Encoder& encoder) const
+{
+    encoder << applicationCacheDirectory;
+    encoder << applicationCacheDirectoryExtensionHandle;
+    encoder << applicationCacheFlatFileSubdirectoryName;
+    encoder << webSQLDatabaseDirectory;
+    encoder << webSQLDatabaseDirectoryExtensionHandle;
+    encoder << mediaCacheDirectory;
+    encoder << mediaCacheDirectoryExtensionHandle;
+    encoder << mediaKeyStorageDirectory;
+    encoder << mediaKeyStorageDirectoryExtensionHandle;
+    encoder << javaScriptConfigurationDirectory;
+    encoder << javaScriptConfigurationDirectoryExtensionHandle;
+    encoder << resourceLoadStatisticsEnabled;
+}
+
+template<class Decoder>
+Optional<WebProcessDataStoreParameters> WebProcessDataStoreParameters::decode(Decoder& decoder)
+{
+    WebProcessDataStoreParameters parameters;
+
+    if (!decoder.decode(parameters.applicationCacheDirectory))
+        return WTF::nullopt;
+
+    Optional<SandboxExtension::Handle> applicationCacheDirectoryExtensionHandle;
+    decoder >> applicationCacheDirectoryExtensionHandle;
+    if (!applicationCacheDirectoryExtensionHandle)
+        return WTF::nullopt;
+    parameters.applicationCacheDirectoryExtensionHandle = WTFMove(*applicationCacheDirectoryExtensionHandle);
+
+    if (!decoder.decode(parameters.applicationCacheFlatFileSubdirectoryName))
+        return WTF::nullopt;
+
+    if (!decoder.decode(parameters.webSQLDatabaseDirectory))
+        return WTF::nullopt;
+
+    Optional<SandboxExtension::Handle> webSQLDatabaseDirectoryExtensionHandle;
+    decoder >> webSQLDatabaseDirectoryExtensionHandle;
+    if (!webSQLDatabaseDirectoryExtensionHandle)
+        return WTF::nullopt;
+    parameters.webSQLDatabaseDirectoryExtensionHandle = WTFMove(*webSQLDatabaseDirectoryExtensionHandle);
+
+    if (!decoder.decode(parameters.mediaCacheDirectory))
+        return WTF::nullopt;
+
+    Optional<SandboxExtension::Handle> mediaCacheDirectoryExtensionHandle;
+    decoder >> mediaCacheDirectoryExtensionHandle;
+    if (!mediaCacheDirectoryExtensionHandle)
+        return WTF::nullopt;
+    parameters.mediaCacheDirectoryExtensionHandle = WTFMove(*mediaCacheDirectoryExtensionHandle);
+
+    if (!decoder.decode(parameters.mediaKeyStorageDirectory))
+        return WTF::nullopt;
+
+    Optional<SandboxExtension::Handle> mediaKeyStorageDirectoryExtensionHandle;
+    decoder >> mediaKeyStorageDirectoryExtensionHandle;
+    if (!mediaKeyStorageDirectoryExtensionHandle)
+        return WTF::nullopt;
+    parameters.mediaKeyStorageDirectoryExtensionHandle = WTFMove(*mediaKeyStorageDirectoryExtensionHandle);
+
+    if (!decoder.decode(parameters.javaScriptConfigurationDirectory))
+        return WTF::nullopt;
+
+    Optional<SandboxExtension::Handle> javaScriptConfigurationDirectoryExtensionHandle;
+    decoder >> javaScriptConfigurationDirectoryExtensionHandle;
+    if (!javaScriptConfigurationDirectoryExtensionHandle)
+        return WTF::nullopt;
+    parameters.javaScriptConfigurationDirectoryExtensionHandle = WTFMove(*javaScriptConfigurationDirectoryExtensionHandle);
+
+    if (!decoder.decode(parameters.resourceLoadStatisticsEnabled))
+        return WTF::nullopt;
+
+    return parameters;
+}
+
+} // namespace WebKit
index c49ebb8..93f76a7 100644 (file)
@@ -524,7 +524,7 @@ void WKContextSetHTTPPipeliningEnabled(WKContextRef contextRef, bool enabled)
 
 void WKContextWarmInitialProcess(WKContextRef contextRef)
 {
-    WebKit::toImpl(contextRef)->prewarmProcess(nullptr, WebKit::WebProcessPool::MayCreateDefaultDataStore::Yes);
+    WebKit::toImpl(contextRef)->prewarmProcess();
 }
 
 void WKContextGetStatistics(WKContextRef contextRef, void* context, WKContextGetStatisticsFunction callback)
index bc77bb2..c35d534 100644 (file)
@@ -389,7 +389,7 @@ static NSDictionary *policiesHashMapToDictionary(const HashMap<String, HashMap<S
 
 - (void)_warmInitialProcess
 {
-    _processPool->prewarmProcess(nullptr, WebKit::WebProcessPool::MayCreateDefaultDataStore::Yes);
+    _processPool->prewarmProcess();
 }
 
 - (void)_automationCapabilitiesDidChange
index fa8c490..f1ff2f1 100644 (file)
@@ -51,7 +51,7 @@ Ref<ServiceWorkerProcessProxy> ServiceWorkerProcessProxy::create(WebProcessPool&
 }
 
 ServiceWorkerProcessProxy::ServiceWorkerProcessProxy(WebProcessPool& pool, const RegistrableDomain& registrableDomain, WebsiteDataStore& store)
-    : WebProcessProxy { pool, store, IsPrewarmed::No }
+    : WebProcessProxy { pool, &store, IsPrewarmed::No }
     , m_registrableDomain(registrableDomain)
     , m_serviceWorkerPageID(generatePageID())
 {
index e91273d..362e984 100644 (file)
@@ -571,7 +571,7 @@ bool WebPageProxy::hasRunningProcess() const
 
 void WebPageProxy::notifyProcessPoolToPrewarm()
 {
-    m_process->processPool().didReachGoodTimeToPrewarm(m_websiteDataStore);
+    m_process->processPool().didReachGoodTimeToPrewarm();
 }
 
 void WebPageProxy::setPreferences(WebPreferences& preferences)
index 5214a57..98bd496 100644 (file)
@@ -72,6 +72,7 @@
 #include "WebPreferencesKeys.h"
 #include "WebProcessCache.h"
 #include "WebProcessCreationParameters.h"
+#include "WebProcessDataStoreParameters.h"
 #include "WebProcessMessages.h"
 #include "WebProcessPoolMessages.h"
 #include "WebProcessProxy.h"
@@ -694,7 +695,7 @@ void WebProcessPool::establishWorkerContextConnectionToNetworkProcess(NetworkPro
     m_serviceWorkerProcesses.add(WTFMove(registrableDomain), serviceWorkerProcessProxy.ptr());
 
     updateProcessAssertions();
-    initializeNewWebProcess(serviceWorkerProcessProxy, *websiteDataStore);
+    initializeNewWebProcess(serviceWorkerProcessProxy, websiteDataStore);
 
     auto* serviceWorkerProcessProxyPtr = serviceWorkerProcessProxy.ptr();
     m_processes.append(WTFMove(serviceWorkerProcessProxy));
@@ -789,7 +790,7 @@ void WebProcessPool::resolvePathsForSandboxExtensions()
     platformResolvePathsForSandboxExtensions();
 }
 
-WebProcessProxy& WebProcessPool::createNewWebProcess(WebsiteDataStore& websiteDataStore, WebProcessProxy::IsPrewarmed isPrewarmed)
+WebProcessProxy& WebProcessPool::createNewWebProcess(WebsiteDataStore* websiteDataStore, WebProcessProxy::IsPrewarmed isPrewarmed)
 {
     auto processProxy = WebProcessProxy::create(*this, websiteDataStore, isPrewarmed);
     auto& process = processProxy.get();
@@ -807,12 +808,12 @@ RefPtr<WebProcessProxy> WebProcessPool::tryTakePrewarmedProcess(WebsiteDataStore
     if (!m_prewarmedProcess)
         return nullptr;
 
-    if (&m_prewarmedProcess->websiteDataStore() != &websiteDataStore)
-        return nullptr;
-
     ASSERT(m_prewarmedProcess->isPrewarmed());
     m_prewarmedProcess->markIsNoLongerInPrewarmedPool();
 
+    m_prewarmedProcess->setWebsiteDataStore(websiteDataStore);
+    sendWebProcessDataStoreParameters(*m_prewarmedProcess, websiteDataStore);
+
     return std::exchange(m_prewarmedProcess, nullptr);
 }
 
@@ -839,36 +840,17 @@ static void registerDisplayConfigurationCallback()
 }
 #endif
 
-void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDataStore& websiteDataStore, WebProcessProxy::IsPrewarmed isPrewarmed)
+void WebProcessPool::sendWebProcessDataStoreParameters(WebProcessProxy& process, WebsiteDataStore& websiteDataStore)
 {
-    auto initializationActivityToken = process.throttler().backgroundActivityToken();
-    auto scopeExit = makeScopeExit([&process, initializationActivityToken] {
-        // Round-trip to the Web Content process before releasing the
-        // initialization activity token, so that we're sure that all
-        // messages sent from this function have been handled.
-        process.isResponsive([initializationActivityToken] (bool) { });
-    });
-
-    ensureNetworkProcess();
-
-    WebProcessCreationParameters parameters;
+    WebProcessDataStoreParameters parameters;
 
     websiteDataStore.resolveDirectoriesIfNecessary();
 
-    parameters.injectedBundlePath = m_resolvedPaths.injectedBundlePath;
-    if (!parameters.injectedBundlePath.isEmpty())
-        SandboxExtension::createHandleWithoutResolvingPath(parameters.injectedBundlePath, SandboxExtension::Type::ReadOnly, parameters.injectedBundlePathExtensionHandle);
-
-    parameters.additionalSandboxExtensionHandles.allocate(m_resolvedPaths.additionalWebProcessSandboxExtensionPaths.size());
-    for (size_t i = 0, size = m_resolvedPaths.additionalWebProcessSandboxExtensionPaths.size(); i < size; ++i)
-        SandboxExtension::createHandleWithoutResolvingPath(m_resolvedPaths.additionalWebProcessSandboxExtensionPaths[i], SandboxExtension::Type::ReadOnly, parameters.additionalSandboxExtensionHandles[i]);
-
     parameters.applicationCacheDirectory = websiteDataStore.resolvedApplicationCacheDirectory();
     if (parameters.applicationCacheDirectory.isEmpty())
         parameters.applicationCacheDirectory = m_resolvedPaths.applicationCacheDirectory;
     if (!parameters.applicationCacheDirectory.isEmpty())
         SandboxExtension::createHandleWithoutResolvingPath(parameters.applicationCacheDirectory, SandboxExtension::Type::ReadWrite, parameters.applicationCacheDirectoryExtensionHandle);
-
     parameters.applicationCacheFlatFileSubdirectoryName = m_configuration->applicationCacheFlatFileSubdirectoryName();
 
     parameters.webSQLDatabaseDirectory = websiteDataStore.resolvedDatabaseDirectory();
@@ -889,16 +871,43 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa
     if (!parameters.mediaKeyStorageDirectory.isEmpty())
         SandboxExtension::createHandleWithoutResolvingPath(parameters.mediaKeyStorageDirectory, SandboxExtension::Type::ReadWrite, parameters.mediaKeyStorageDirectoryExtensionHandle);
 
-#if PLATFORM(IOS_FAMILY)
-    setJavaScriptConfigurationFileEnabledFromDefaults();
-#endif
-
     if (javaScriptConfigurationFileEnabled()) {
         parameters.javaScriptConfigurationDirectory = websiteDataStore.resolvedJavaScriptConfigurationDirectory();
         if (!parameters.javaScriptConfigurationDirectory.isEmpty())
             SandboxExtension::createHandleWithoutResolvingPath(parameters.javaScriptConfigurationDirectory, SandboxExtension::Type::ReadWrite, parameters.javaScriptConfigurationDirectoryExtensionHandle);
     }
 
+    parameters.resourceLoadStatisticsEnabled = websiteDataStore.resourceLoadStatisticsEnabled();
+
+    process.send(Messages::WebProcess::SetWebsiteDataStoreParameters(parameters), 0);
+}
+
+void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDataStore* websiteDataStore, WebProcessProxy::IsPrewarmed isPrewarmed)
+{
+    auto initializationActivityToken = process.throttler().backgroundActivityToken();
+    auto scopeExit = makeScopeExit([&process, initializationActivityToken] {
+        // Round-trip to the Web Content process before releasing the
+        // initialization activity token, so that we're sure that all
+        // messages sent from this function have been handled.
+        process.isResponsive([initializationActivityToken] (bool) { });
+    });
+
+    ensureNetworkProcess();
+
+    WebProcessCreationParameters parameters;
+
+    parameters.injectedBundlePath = m_resolvedPaths.injectedBundlePath;
+    if (!parameters.injectedBundlePath.isEmpty())
+        SandboxExtension::createHandleWithoutResolvingPath(parameters.injectedBundlePath, SandboxExtension::Type::ReadOnly, parameters.injectedBundlePathExtensionHandle);
+
+    parameters.additionalSandboxExtensionHandles.allocate(m_resolvedPaths.additionalWebProcessSandboxExtensionPaths.size());
+    for (size_t i = 0, size = m_resolvedPaths.additionalWebProcessSandboxExtensionPaths.size(); i < size; ++i)
+        SandboxExtension::createHandleWithoutResolvingPath(m_resolvedPaths.additionalWebProcessSandboxExtensionPaths[i], SandboxExtension::Type::ReadOnly, parameters.additionalSandboxExtensionHandles[i]);
+
+#if PLATFORM(IOS_FAMILY)
+    setJavaScriptConfigurationFileEnabledFromDefaults();
+#endif
+
     parameters.cacheModel = cacheModel();
     parameters.languages = configuration().overrideLanguages().isEmpty() ? userPreferredLanguages() : configuration().overrideLanguages();
 
@@ -958,7 +967,6 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa
         parameters.waylandCompositorDisplayName = WaylandCompositor::singleton().displayName();
 #endif
 
-    parameters.resourceLoadStatisticsEnabled = websiteDataStore.resourceLoadStatisticsEnabled();
 #if ENABLE(MEDIA_STREAM)
     parameters.shouldCaptureAudioInUIProcess = m_configuration->shouldCaptureAudioInUIProcess();
     parameters.shouldCaptureVideoInUIProcess = m_configuration->shouldCaptureVideoInUIProcess();
@@ -989,6 +997,9 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa
     process.send(Messages::WebProcess::SetQOS(webProcessLatencyQOS(), webProcessThroughputQOS()), 0);
 #endif
 
+    if (websiteDataStore)
+        sendWebProcessDataStoreParameters(process, *websiteDataStore);
+
     if (m_automationSession)
         process.send(Messages::WebProcess::EnsureAutomationSessionProxy(m_automationSession->sessionIdentifier()), 0);
 
@@ -1014,35 +1025,13 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa
 #endif
 }
 
-void WebProcessPool::prewarmProcess(WebsiteDataStore* websiteDataStore, MayCreateDefaultDataStore mayCreateDefaultDataStore)
+void WebProcessPool::prewarmProcess()
 {
-    if (m_prewarmedProcess && websiteDataStore && &m_prewarmedProcess->websiteDataStore() != websiteDataStore) {
-        RELEASE_LOG(PerformanceLogging, "Shutting down prewarmed process %i because we needed a prewarmed process with a different data store", m_prewarmedProcess->processIdentifier());
-        m_prewarmedProcess->shutDown();
-        ASSERT(!m_prewarmedProcess);
-    }
-
     if (m_prewarmedProcess)
         return;
 
-    if (!websiteDataStore) {
-        websiteDataStore = m_websiteDataStore ? &m_websiteDataStore->websiteDataStore() : nullptr;
-        if (!websiteDataStore) {
-            if (!m_processes.isEmpty())
-                websiteDataStore = &m_processes.last()->websiteDataStore();
-            else if (mayCreateDefaultDataStore == MayCreateDefaultDataStore::Yes || API::WebsiteDataStore::defaultDataStoreExists())
-                websiteDataStore = &API::WebsiteDataStore::defaultDataStore()->websiteDataStore();
-            else {
-                RELEASE_LOG(PerformanceLogging, "Unable to prewarming a WebProcess because we could not find a usable data store");
-                return;
-            }
-        }
-    }
-
-    ASSERT(websiteDataStore);
-
     RELEASE_LOG(PerformanceLogging, "Prewarming a WebProcess for performance");
-    createNewWebProcess(*websiteDataStore, WebProcessProxy::IsPrewarmed::Yes);
+    createNewWebProcess(nullptr, WebProcessProxy::IsPrewarmed::Yes);
 }
 
 void WebProcessPool::enableProcessTermination()
@@ -1169,7 +1158,7 @@ WebProcessProxy& WebProcessPool::processForRegistrableDomain(WebsiteDataStore& w
     }
 
     if (!usesSingleWebProcess())
-        return createNewWebProcess(websiteDataStore);
+        return createNewWebProcess(&websiteDataStore);
 
 #if PLATFORM(COCOA)
     bool mustMatchDataStore = API::WebsiteDataStore::defaultDataStoreExists() && &websiteDataStore != &API::WebsiteDataStore::defaultDataStore()->websiteDataStore();
@@ -1178,15 +1167,17 @@ WebProcessProxy& WebProcessPool::processForRegistrableDomain(WebsiteDataStore& w
 #endif
 
     for (auto& process : m_processes) {
-        if (mustMatchDataStore && &process->websiteDataStore() != &websiteDataStore)
+        if (process == m_prewarmedProcess || process == m_dummyProcessProxy)
             continue;
 #if ENABLE(SERVICE_WORKER)
         if (is<ServiceWorkerProcessProxy>(*process))
             continue;
 #endif
+        if (mustMatchDataStore && &process->websiteDataStore() != &websiteDataStore)
+            continue;
         return *process;
     }
-    return createNewWebProcess(websiteDataStore);
+    return createNewWebProcess(&websiteDataStore);
 }
 
 Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API::PageConfiguration>&& pageConfiguration)
@@ -1221,7 +1212,7 @@ Ref<WebPageProxy> WebProcessPool::createWebPage(PageClient& pageClient, Ref<API:
     } else if (!m_isDelayedWebProcessLaunchDisabled) {
         // In the common case, we delay process launch until something is actually loaded in the page.
         if (!m_dummyProcessProxy) {
-            auto dummyProcessProxy = WebProcessProxy::create(*this, WebsiteDataStore::createNonPersistent().get(), WebProcessProxy::IsPrewarmed::No, WebProcessProxy::ShouldLaunchProcess::No);
+            auto dummyProcessProxy = WebProcessProxy::create(*this, nullptr, WebProcessProxy::IsPrewarmed::No, WebProcessProxy::ShouldLaunchProcess::No);
             m_dummyProcessProxy = dummyProcessProxy.ptr();
             m_processes.append(WTFMove(dummyProcessProxy));
         }
@@ -1391,7 +1382,7 @@ void WebProcessPool::postMessageToInjectedBundle(const String& messageName, API:
     }
 }
 
-void WebProcessPool::didReachGoodTimeToPrewarm(WebsiteDataStore& dataStore)
+void WebProcessPool::didReachGoodTimeToPrewarm()
 {
     if (!configuration().isAutomaticProcessWarmingEnabled() || !configuration().processSwapsOnNavigation() || usesSingleWebProcess())
         return;
@@ -1402,7 +1393,7 @@ void WebProcessPool::didReachGoodTimeToPrewarm(WebsiteDataStore& dataStore)
         return;
     }
 
-    prewarmProcess(&dataStore, MayCreateDefaultDataStore::No);
+    prewarmProcess();
 }
 
 void WebProcessPool::populateVisitedLinks()
index 217f324..2157b6b 100644 (file)
@@ -106,6 +106,7 @@ class WebProcessCache;
 struct NetworkProcessCreationParameters;
 struct StatisticsData;
 struct WebProcessCreationParameters;
+struct WebProcessDataStoreParameters;
     
 typedef GenericCallback<API::Dictionary*> DictionaryCallback;
 
@@ -311,8 +312,7 @@ public:
 
     WebProcessProxy& processForRegistrableDomain(WebsiteDataStore&, WebPageProxy*, const WebCore::RegistrableDomain&); // Will return an existing one if limit is met or due to caching.
 
-    enum class MayCreateDefaultDataStore { No, Yes };
-    void prewarmProcess(WebsiteDataStore*, MayCreateDefaultDataStore);
+    void prewarmProcess();
 
     bool shouldTerminate(WebProcessProxy*);
 
@@ -477,7 +477,7 @@ public:
 
     void clearSuspendedPages(AllowProcessCaching);
 
-    void didReachGoodTimeToPrewarm(WebsiteDataStore&);
+    void didReachGoodTimeToPrewarm();
 
     void didCollectPrewarmInformation(const WebCore::RegistrableDomain&, const WebCore::PrewarmInformation&);
 
@@ -517,8 +517,9 @@ private:
 
     RefPtr<WebProcessProxy> tryTakePrewarmedProcess(WebsiteDataStore&);
 
-    WebProcessProxy& createNewWebProcess(WebsiteDataStore&, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No);
-    void initializeNewWebProcess(WebProcessProxy&, WebsiteDataStore&, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No);
+    WebProcessProxy& createNewWebProcess(WebsiteDataStore*, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No);
+    void initializeNewWebProcess(WebProcessProxy&, WebsiteDataStore*, WebProcessProxy::IsPrewarmed = WebProcessProxy::IsPrewarmed::No);
+    void sendWebProcessDataStoreParameters(WebProcessProxy&, WebsiteDataStore&);
 
     void requestWebContentStatistics(StatisticsRequest&);
     void requestNetworkingStatistics(StatisticsRequest&);
@@ -837,7 +838,7 @@ void WebProcessPool::sendToOneProcess(T&& message)
     }
 
     if (!messageSent) {
-        prewarmProcess(nullptr, MayCreateDefaultDataStore::No);
+        prewarmProcess();
         RefPtr<WebProcessProxy> process = m_processes.last();
         if (process->canSendMessage())
             process->send(std::forward<T>(message), 0);
index d4d9f68..f9e7fcc 100644 (file)
@@ -122,7 +122,7 @@ static WebProcessProxy::WebPageProxyMap::MapType& globalPageMap()
     return pageMap;
 }
 
-Ref<WebProcessProxy> WebProcessProxy::create(WebProcessPool& processPool, WebsiteDataStore& websiteDataStore, IsPrewarmed isPrewarmed, ShouldLaunchProcess shouldLaunchProcess)
+Ref<WebProcessProxy> WebProcessProxy::create(WebProcessPool& processPool, WebsiteDataStore* websiteDataStore, IsPrewarmed isPrewarmed, ShouldLaunchProcess shouldLaunchProcess)
 {
     auto proxy = adoptRef(*new WebProcessProxy(processPool, websiteDataStore, isPrewarmed));
     if (shouldLaunchProcess == ShouldLaunchProcess::Yes)
@@ -130,7 +130,7 @@ Ref<WebProcessProxy> WebProcessProxy::create(WebProcessPool& processPool, Websit
     return proxy;
 }
 
-WebProcessProxy::WebProcessProxy(WebProcessPool& processPool, WebsiteDataStore& websiteDataStore, IsPrewarmed isPrewarmed)
+WebProcessProxy::WebProcessProxy(WebProcessPool& processPool, WebsiteDataStore* websiteDataStore, IsPrewarmed isPrewarmed)
     : AuxiliaryProcessProxy(processPool.alwaysRunsAtBackgroundPriority())
     , m_responsivenessTimer(*this)
     , m_backgroundResponsivenessTimer(*this)
@@ -219,6 +219,12 @@ void WebProcessProxy::setIsInProcessCache(bool value)
     validateFreezerStatus();
 }
 
+void WebProcessProxy::setWebsiteDataStore(WebsiteDataStore& dataStore)
+{
+    ASSERT(!m_websiteDataStore);
+    m_websiteDataStore = &dataStore;
+}
+
 void WebProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)
 {
     launchOptions.processType = ProcessLauncher::ProcessType::Web;
@@ -375,7 +381,7 @@ void WebProcessProxy::addExistingWebPage(WebPageProxy& webPage, BeginsUsingDataS
     ASSERT(!m_pageMap.contains(webPage.pageID()));
     ASSERT(!globalPageMap().contains(webPage.pageID()));
     ASSERT(!m_isInProcessCache);
-    ASSERT(m_websiteDataStore.ptr() == &webPage.websiteDataStore() || processPool().dummyProcessProxy() == this);
+    ASSERT(!m_websiteDataStore || m_websiteDataStore == &webPage.websiteDataStore());
 
     if (beginsUsingDataStore == BeginsUsingDataStore::Yes)
         m_processPool->pageBeginUsingWebsiteDataStore(webPage.pageID(), webPage.websiteDataStore());
index 477eba5..01ba243 100644 (file)
@@ -105,7 +105,7 @@ public:
 
     enum class ShouldLaunchProcess : bool { No, Yes };
 
-    static Ref<WebProcessProxy> create(WebProcessPool&, WebsiteDataStore&, IsPrewarmed, ShouldLaunchProcess = ShouldLaunchProcess::Yes);
+    static Ref<WebProcessProxy> create(WebProcessPool&, WebsiteDataStore*, IsPrewarmed, ShouldLaunchProcess = ShouldLaunchProcess::Yes);
     ~WebProcessProxy();
 
     WebConnection* webConnection() const { return m_webConnection.get(); }
@@ -120,8 +120,8 @@ public:
     void setIsInProcessCache(bool);
     bool isInProcessCache() const { return m_isInProcessCache; }
 
-    // FIXME: WebsiteDataStores should be made per-WebPageProxy throughout WebKit2
-    WebsiteDataStore& websiteDataStore() const { return m_websiteDataStore.get(); }
+    WebsiteDataStore& websiteDataStore() const { ASSERT(m_websiteDataStore); return *m_websiteDataStore; }
+    void setWebsiteDataStore(WebsiteDataStore&);
 
     static WebProcessProxy* processForIdentifier(WebCore::ProcessIdentifier);
     static WebPageProxy* webPage(uint64_t pageID);
@@ -342,7 +342,7 @@ public:
 
 protected:
     static uint64_t generatePageID();
-    WebProcessProxy(WebProcessPool&, WebsiteDataStore&, IsPrewarmed);
+    WebProcessProxy(WebProcessPool&, WebsiteDataStore*, IsPrewarmed);
 
     // AuxiliaryProcessProxy
     void getLaunchOptions(ProcessLauncher::LaunchOptions&) override;
@@ -493,8 +493,7 @@ private:
 
     VisibleWebPageCounter m_visiblePageCounter;
 
-    // FIXME: WebsiteDataStores should be made per-WebPageProxy throughout WebKit2. Get rid of this member.
-    Ref<WebsiteDataStore> m_websiteDataStore;
+    RefPtr<WebsiteDataStore> m_websiteDataStore;
 
     bool m_isUnderMemoryPressure { false };
 
index 282384a..1f2c5b0 100644 (file)
                463FD4801EB9459600A2982C /* WKProcessTerminationReason.h in Headers */ = {isa = PBXBuildFile; fileRef = 463FD47F1EB9458400A2982C /* WKProcessTerminationReason.h */; settings = {ATTRIBUTES = (Private, ); }; };
                463FD4821EB94EC000A2982C /* ProcessTerminationReason.h in Headers */ = {isa = PBXBuildFile; fileRef = 463FD4811EB94EAD00A2982C /* ProcessTerminationReason.h */; };
                466BC03C1FA266DA002FA9C1 /* WebSWContextManagerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 466BC0391FA266C9002FA9C1 /* WebSWContextManagerConnection.h */; };
+               467E43E82243FF7D00B13924 /* WebProcessDataStoreParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 467E43E72243FF6D00B13924 /* WebProcessDataStoreParameters.h */; };
                46A2B6091E5676A600C3DEDA /* BackgroundProcessResponsivenessTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A2B6071E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.h */; };
                46DF063C1F3905F8001980BB /* NetworkCORSPreflightChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DF063A1F3905E5001980BB /* NetworkCORSPreflightChecker.h */; };
                4A3CC18B19B0640F00D14AEF /* UserMediaPermissionRequestManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A410F3A19AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.h */; };
                466BC0381FA266C9002FA9C1 /* WebSWContextManagerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWContextManagerConnection.cpp; sourceTree = "<group>"; };
                466BC0391FA266C9002FA9C1 /* WebSWContextManagerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWContextManagerConnection.h; sourceTree = "<group>"; };
                466BC03A1FA266C9002FA9C1 /* WebSWContextManagerConnection.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebSWContextManagerConnection.messages.in; sourceTree = "<group>"; };
+               467E43E72243FF6D00B13924 /* WebProcessDataStoreParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessDataStoreParameters.h; sourceTree = "<group>"; };
                4683569A21E81CC7006E27A3 /* ProvisionalPageProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProvisionalPageProxy.h; sourceTree = "<group>"; };
                4683569B21E81CC7006E27A3 /* ProvisionalPageProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProvisionalPageProxy.cpp; sourceTree = "<group>"; };
                46A2B6061E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BackgroundProcessResponsivenessTimer.cpp; sourceTree = "<group>"; };
                                BCD598AA112B7FDF00EC8C23 /* WebPreferencesStore.h */,
                                BC306823125A6B9400E71278 /* WebProcessCreationParameters.cpp */,
                                BC306822125A6B9400E71278 /* WebProcessCreationParameters.h */,
+                               467E43E72243FF6D00B13924 /* WebProcessDataStoreParameters.h */,
                                37948401150C350600E52CE9 /* WebRenderLayer.cpp */,
                                37948402150C350600E52CE9 /* WebRenderLayer.h */,
                                3760881C150413E900FC82C7 /* WebRenderObject.cpp */,
                                1A043A09124D11A900FFBFB5 /* WebProcessConnection.h in Headers */,
                                1A043F6A12514D8B00FFBFB5 /* WebProcessConnectionMessages.h in Headers */,
                                BC306824125A6B9400E71278 /* WebProcessCreationParameters.h in Headers */,
+                               467E43E82243FF7D00B13924 /* WebProcessDataStoreParameters.h in Headers */,
                                1AFA4B901A65A9E2006C4AB4 /* WebProcessLifetimeObserver.h in Headers */,
                                1AFA4B8C1A65A1D0006C4AB4 /* WebProcessLifetimeTracker.h in Headers */,
                                BC3066BF125A442100E71278 /* WebProcessMessages.h in Headers */,
index bd39824..86364b0 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "WebMediaKeyStorageManager.h"
 
-#include "WebProcessCreationParameters.h"
+#include "WebProcessDataStoreParameters.h"
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/SecurityOriginData.h>
 #include <wtf/FileSystem.h>
@@ -35,7 +35,7 @@
 namespace WebKit {
 using namespace WebCore;
 
-void WebMediaKeyStorageManager::initialize(const WebProcessCreationParameters &parameters)
+void WebMediaKeyStorageManager::setWebsiteDataStore(const WebProcessDataStoreParameters& parameters)
 {
     ASSERT(!parameters.mediaKeyStorageDirectory.isEmpty());
     m_mediaKeyStorageDirectory = parameters.mediaKeyStorageDirectory;
index 0baa5ad..0ca5ea6 100644 (file)
@@ -55,7 +55,7 @@ public:
     void deleteAllMediaKeyEntries();
 
 private:
-    void initialize(const WebProcessCreationParameters&) override;
+    void setWebsiteDataStore(const WebProcessDataStoreParameters&) override;
 
     String m_mediaKeyStorageDirectory;
 };
index 9f36eb8..c05bf09 100644 (file)
@@ -61,6 +61,7 @@
 #include "WebPlatformStrategies.h"
 #include "WebPluginInfoProvider.h"
 #include "WebProcessCreationParameters.h"
+#include "WebProcessDataStoreParameters.h"
 #include "WebProcessMessages.h"
 #include "WebProcessPoolMessages.h"
 #include "WebProcessProxyMessages.h"
@@ -285,7 +286,7 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
     MemoryPressureHandler::ReliefLogger::setLoggingEnabled(parameters.shouldEnableMemoryPressureReliefLogging);
 #endif
 
-    platformInitializeWebProcess(WTFMove(parameters));
+    platformInitializeWebProcess(parameters);
 
     // Match the QoS of the UIProcess and the scrolling thread but use a slightly lower priority.
     WTF::Thread::setCurrentThreadIsUserInteractive(-1);
@@ -341,20 +342,6 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
     for (auto& supplement : m_supplements.values())
         supplement->initialize(parameters);
 
-    auto& databaseManager = DatabaseManager::singleton();
-    databaseManager.initialize(parameters.webSQLDatabaseDirectory);
-
-    // FIXME: This should be constructed per data store, not per process.
-    m_applicationCacheStorage = ApplicationCacheStorage::create(parameters.applicationCacheDirectory, parameters.applicationCacheFlatFileSubdirectoryName);
-#if PLATFORM(IOS_FAMILY)
-    m_applicationCacheStorage->setDefaultOriginQuota(25ULL * 1024 * 1024);
-#endif
-
-#if ENABLE(VIDEO)
-    if (!parameters.mediaCacheDirectory.isEmpty())
-        WebCore::HTMLMediaElement::setMediaCacheDirectory(parameters.mediaCacheDirectory);
-#endif
-
     setCacheModel(parameters.cacheModel);
 
     if (!parameters.languages.isEmpty())
@@ -402,8 +389,6 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
 
     setDefaultRequestTimeoutInterval(parameters.defaultRequestTimeoutInterval);
 
-    setResourceLoadStatisticsEnabled(parameters.resourceLoadStatisticsEnabled);
-
     setAlwaysUsesComplexTextCodePath(parameters.shouldAlwaysUseComplexTextCodePath);
 
     setShouldUseFontSmoothing(parameters.shouldUseFontSmoothing);
@@ -472,6 +457,30 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
     RELEASE_LOG(Process, "%p - WebProcess::initializeWebProcess: Presenting process = %d", this, WebCore::presentingApplicationPID());
 }
 
+void WebProcess::setWebsiteDataStoreParameters(WebProcessDataStoreParameters&& parameters)
+{
+    auto& databaseManager = DatabaseManager::singleton();
+    databaseManager.initialize(parameters.webSQLDatabaseDirectory);
+
+    // FIXME: This should be constructed per data store, not per process.
+    m_applicationCacheStorage = ApplicationCacheStorage::create(parameters.applicationCacheDirectory, parameters.applicationCacheFlatFileSubdirectoryName);
+#if PLATFORM(IOS_FAMILY)
+    m_applicationCacheStorage->setDefaultOriginQuota(25ULL * 1024 * 1024);
+#endif
+
+#if ENABLE(VIDEO)
+    if (!parameters.mediaCacheDirectory.isEmpty())
+        WebCore::HTMLMediaElement::setMediaCacheDirectory(parameters.mediaCacheDirectory);
+#endif
+
+    setResourceLoadStatisticsEnabled(parameters.resourceLoadStatisticsEnabled);
+
+    for (auto& supplement : m_supplements.values())
+        supplement->setWebsiteDataStore(parameters);
+
+    platformSetWebsiteDataStoreParameters(WTFMove(parameters));
+}
+
 bool WebProcess::hasPageRequiringPageCacheWhileSuspended() const
 {
     for (auto& page : m_pageMap.values()) {
index 29520e4..3d947b1 100644 (file)
@@ -36,6 +36,7 @@
 #include "TextCheckerState.h"
 #include "ViewUpdateDispatcher.h"
 #include "WebInspectorInterruptDispatcher.h"
+#include "WebProcessCreationParameters.h"
 #include <WebCore/ActivityState.h>
 #include <WebCore/RegistrableDomain.h>
 #if PLATFORM(MAC)
@@ -104,12 +105,13 @@ class WebFrame;
 class WebLoaderStrategy;
 class WebPage;
 class WebPageGroupProxy;
+struct WebProcessCreationParameters;
+struct WebProcessDataStoreParameters;
 class WebProcessSupplement;
 enum class WebsiteDataType;
 struct WebPageCreationParameters;
 struct WebPageGroupData;
 struct WebPreferencesStore;
-struct WebProcessCreationParameters;
 struct WebsiteData;
 struct WebsiteDataStoreParameters;
 
@@ -262,7 +264,9 @@ private:
     ~WebProcess();
 
     void initializeWebProcess(WebProcessCreationParameters&&);
-    void platformInitializeWebProcess(WebProcessCreationParameters&&);
+    void platformInitializeWebProcess(WebProcessCreationParameters&);
+    void setWebsiteDataStoreParameters(WebProcessDataStoreParameters&&);
+    void platformSetWebsiteDataStoreParameters(WebProcessDataStoreParameters&&);
 
     void prewarmGlobally();
     void prewarmWithDomainInformation(const WebCore::PrewarmInformation&);
index 124285d..627f19f 100644 (file)
@@ -22,6 +22,7 @@
 
 messages -> WebProcess LegacyReceiver {
     InitializeWebProcess(struct WebKit::WebProcessCreationParameters processCreationParameters)
+    SetWebsiteDataStoreParameters(struct WebKit::WebProcessDataStoreParameters parameters)
 
     # Create a new page.
     CreateWebPage(uint64_t newPageID, struct WebKit::WebPageCreationParameters pageCreationParameters)
index 9c9c441..ae42a87 100644 (file)
 namespace WebKit {
 
 struct WebProcessCreationParameters;
+struct WebProcessDataStoreParameters;
 
 class WebProcessSupplement : public AuxiliaryProcessSupplement {
 public:
-    virtual void initialize(const WebProcessCreationParameters&)
-    {
-    }
+    virtual void initialize(const WebProcessCreationParameters&) { }
+    virtual void setWebsiteDataStore(const WebProcessDataStoreParameters&) { }
 };
 
 } // namespace WebKit
index e60fdad..3cd3c8b 100644 (file)
@@ -43,6 +43,7 @@
 #import "WebInspector.h"
 #import "WebPage.h"
 #import "WebProcessCreationParameters.h"
+#import "WebProcessDataStoreParameters.h"
 #import "WebProcessProxyMessages.h"
 #import "WebsiteDataStoreParameters.h"
 #import <JavaScriptCore/ConfigFile.h>
@@ -131,7 +132,7 @@ static id NSApplicationAccessibilityFocusedUIElement(NSApplication*, SEL)
 }
 #endif
 
-void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& parameters)
+void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
 {
 #if !LOG_DISABLED || !RELEASE_LOG_DISABLED
     WebCore::initializeLogChannelsIfNecessary(parameters.webCoreLoggingChannels);
@@ -145,11 +146,6 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par
 
 #if ENABLE(SANDBOX_EXTENSIONS)
     SandboxExtension::consumePermanently(parameters.uiProcessBundleResourcePathExtensionHandle);
-    SandboxExtension::consumePermanently(parameters.webSQLDatabaseDirectoryExtensionHandle);
-    SandboxExtension::consumePermanently(parameters.applicationCacheDirectoryExtensionHandle);
-    SandboxExtension::consumePermanently(parameters.mediaCacheDirectoryExtensionHandle);
-    SandboxExtension::consumePermanently(parameters.mediaKeyStorageDirectoryExtensionHandle);
-    SandboxExtension::consumePermanently(parameters.javaScriptConfigurationDirectoryExtensionHandle);
 #if ENABLE(MEDIA_STREAM)
     SandboxExtension::consumePermanently(parameters.audioCaptureExtensionHandle);
 #endif
@@ -160,11 +156,6 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par
 #endif
 #endif
 
-    if (!parameters.javaScriptConfigurationDirectory.isEmpty()) {
-        String javaScriptConfigFile = parameters.javaScriptConfigurationDirectory + "/JSC.config";
-        JSC::processConfigFile(javaScriptConfigFile.latin1().data(), "com.apple.WebKit.WebContent", parameters.uiProcessBundleIdentifier.latin1().data());
-    }
-
     // Disable NSURLCache.
     auto urlCache = adoptNS([[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]);
     [NSURLCache setSharedURLCache:urlCache.get()];
@@ -216,6 +207,22 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par
 #endif
 }
 
+void WebProcess::platformSetWebsiteDataStoreParameters(WebProcessDataStoreParameters&& parameters)
+{
+#if ENABLE(SANDBOX_EXTENSIONS)
+    SandboxExtension::consumePermanently(parameters.webSQLDatabaseDirectoryExtensionHandle);
+    SandboxExtension::consumePermanently(parameters.applicationCacheDirectoryExtensionHandle);
+    SandboxExtension::consumePermanently(parameters.mediaCacheDirectoryExtensionHandle);
+    SandboxExtension::consumePermanently(parameters.mediaKeyStorageDirectoryExtensionHandle);
+    SandboxExtension::consumePermanently(parameters.javaScriptConfigurationDirectoryExtensionHandle);
+#endif
+
+    if (!parameters.javaScriptConfigurationDirectory.isEmpty()) {
+        String javaScriptConfigFile = parameters.javaScriptConfigurationDirectory + "/JSC.config";
+        JSC::processConfigFile(javaScriptConfigFile.latin1().data(), "com.apple.WebKit.WebContent", m_uiProcessBundleIdentifier.latin1().data());
+    }
+}
+
 void WebProcess::initializeProcessName(const AuxiliaryProcessInitializationParameters&)
 {
 #if PLATFORM(MAC)
index 82a8ec1..ea0f102 100644 (file)
@@ -49,7 +49,7 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel)
     WebCore::MemoryCache::singleton().setDisabled(cacheModel == CacheModel::DocumentViewer);
 }
 
-void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& parameters)
+void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
 {
 #if PLATFORM(WPE)
     if (!parameters.isServiceWorkerProcess) {
@@ -69,6 +69,10 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par
 #endif
 }
 
+void WebProcess::platformSetWebsiteDataStoreParameters(WebProcessDataStoreParameters&&)
+{
+}
+
 void WebProcess::platformTerminate()
 {
 }
index 9e0721e..da1927f 100644 (file)
@@ -34,7 +34,12 @@ WTF_EXPORT RefPtr<WebCore::SharedBuffer> loadResourceIntoBuffer(const char* name
 }
 
 namespace WebKit {
-void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&&)
+
+void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&)
+{
+}
+
+void WebProcess::platformSetWebsiteDataStoreParameters(WebProcessDataStoreParameters&&)
 {
 }
 
index a209a3d..68d40a6 100644 (file)
@@ -1,3 +1,16 @@
+2019-03-22  Chris Dumez  <cdumez@apple.com>
+
+        Prewarmed processes should be usable with any website data store
+        https://bugs.webkit.org/show_bug.cgi?id=196104
+
+        Reviewed by Alex Christensen.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessPreWarming.mm:
+        (runInitialWarmedProcessUsedTest):
+        (TEST):
+
 2019-03-22  David Kilzer  <ddkilzer@apple.com>
 
         Back out local changes to Alex's Subversion working directory
index d08fcd8..c2e09fc 100644 (file)
@@ -49,7 +49,8 @@ TEST(WKProcessPool, WarmInitialProcess)
     EXPECT_TRUE([pool _hasPrewarmedWebProcess]);
 }
 
-TEST(WKProcessPool, InitialWarmedProcessUsed)
+enum class ShouldUseEphemeralStore { No, Yes };
+static void runInitialWarmedProcessUsedTest(ShouldUseEphemeralStore shouldUseEphemeralStore)
 {
     auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
     processPoolConfiguration.get().prewarmsProcessesAutomatically = NO;
@@ -62,6 +63,8 @@ TEST(WKProcessPool, InitialWarmedProcessUsed)
 
     auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
     configuration.get().processPool = pool.get();
+    if (shouldUseEphemeralStore == ShouldUseEphemeralStore::Yes)
+        configuration.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
 
     auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 800, 600) configuration:configuration.get()]);
 
@@ -76,6 +79,16 @@ TEST(WKProcessPool, InitialWarmedProcessUsed)
     EXPECT_EQ(1U, [pool _webPageContentProcessCount]);
 }
 
+TEST(WKProcessPool, InitialWarmedProcessUsed)
+{
+    runInitialWarmedProcessUsedTest(ShouldUseEphemeralStore::No);
+}
+
+TEST(WKProcessPool, InitialWarmedProcessUsedForEphemeralSession)
+{
+    runInitialWarmedProcessUsedTest(ShouldUseEphemeralStore::Yes);
+}
+
 TEST(WKProcessPool, AutomaticProcessWarming)
 {
     auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);