Title: [275288] trunk/Source
Revision
275288
Author
cdu...@apple.com
Date
2021-03-31 10:15:43 -0700 (Wed, 31 Mar 2021)

Log Message

ServiceWorkerContextData should not be saved both on ServiceWorkerThread & ServiceWorkerGlobalScope
https://bugs.webkit.org/show_bug.cgi?id=224001

Reviewed by Geoffrey Garen.

Source/WebCore:

ServiceWorkerContextData should not be saved both on ServiceWorkerThread & ServiceWorkerGlobalScope.
ServiceWorkerContextData contains script sources and may use a large amount of memory.

To address the issue, we now clear ServiceWorkerThread's context data once the ServiceWorkerGlobalScope
has been constructed.

* inspector/agents/worker/ServiceWorkerAgent.cpp:
(WebCore::ServiceWorkerAgent::getInitializationInfo):
* workers/service/ServiceWorkerGlobalScope.cpp:
(WebCore::ServiceWorkerGlobalScope::create):
(WebCore::ServiceWorkerGlobalScope::ServiceWorkerGlobalScope):
* workers/service/ServiceWorkerGlobalScope.h:
* workers/service/context/SWContextManager.cpp:
(WebCore::SWContextManager::registerServiceWorkerThreadForInstall):
* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::ServiceWorkerThread):
(WebCore::ServiceWorkerThread::createWorkerGlobalScope):
(WebCore::ServiceWorkerThread::heartBeatTimerFired):
(WebCore::ServiceWorkerThread::finishedFiringInstallEvent):
* workers/service/context/ServiceWorkerThread.h:
(WebCore::ServiceWorkerThread::identifier const):
(WebCore::ServiceWorkerThread::jobDataIdentifier const):
(WebCore::ServiceWorkerThread::contextData const): Deleted.
* workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
* workers/service/context/ServiceWorkerThreadProxy.h:

Source/WebKit:

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (275287 => 275288)


--- trunk/Source/WebCore/ChangeLog	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebCore/ChangeLog	2021-03-31 17:15:43 UTC (rev 275288)
@@ -1,3 +1,37 @@
+2021-03-31  Chris Dumez  <cdu...@apple.com>
+
+        ServiceWorkerContextData should not be saved both on ServiceWorkerThread & ServiceWorkerGlobalScope
+        https://bugs.webkit.org/show_bug.cgi?id=224001
+
+        Reviewed by Geoffrey Garen.
+
+        ServiceWorkerContextData should not be saved both on ServiceWorkerThread & ServiceWorkerGlobalScope.
+        ServiceWorkerContextData contains script sources and may use a large amount of memory.
+
+        To address the issue, we now clear ServiceWorkerThread's context data once the ServiceWorkerGlobalScope
+        has been constructed.
+
+        * inspector/agents/worker/ServiceWorkerAgent.cpp:
+        (WebCore::ServiceWorkerAgent::getInitializationInfo):
+        * workers/service/ServiceWorkerGlobalScope.cpp:
+        (WebCore::ServiceWorkerGlobalScope::create):
+        (WebCore::ServiceWorkerGlobalScope::ServiceWorkerGlobalScope):
+        * workers/service/ServiceWorkerGlobalScope.h:
+        * workers/service/context/SWContextManager.cpp:
+        (WebCore::SWContextManager::registerServiceWorkerThreadForInstall):
+        * workers/service/context/ServiceWorkerThread.cpp:
+        (WebCore::ServiceWorkerThread::ServiceWorkerThread):
+        (WebCore::ServiceWorkerThread::createWorkerGlobalScope):
+        (WebCore::ServiceWorkerThread::heartBeatTimerFired):
+        (WebCore::ServiceWorkerThread::finishedFiringInstallEvent):
+        * workers/service/context/ServiceWorkerThread.h:
+        (WebCore::ServiceWorkerThread::identifier const):
+        (WebCore::ServiceWorkerThread::jobDataIdentifier const):
+        (WebCore::ServiceWorkerThread::contextData const): Deleted.
+        * workers/service/context/ServiceWorkerThreadProxy.cpp:
+        (WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
+        * workers/service/context/ServiceWorkerThreadProxy.h:
+
 2021-03-31  Antoine Quint  <grao...@webkit.org>
 
         font-stretch should support 0% and disallow animating to a value below 0%

Modified: trunk/Source/WebCore/inspector/agents/worker/ServiceWorkerAgent.cpp (275287 => 275288)


--- trunk/Source/WebCore/inspector/agents/worker/ServiceWorkerAgent.cpp	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebCore/inspector/agents/worker/ServiceWorkerAgent.cpp	2021-03-31 17:15:43 UTC (rev 275288)
@@ -59,8 +59,8 @@
     return Protocol::ServiceWorker::Configuration::create()
         .setTargetId(m_serviceWorkerGlobalScope.identifier())
         .setSecurityOrigin(m_serviceWorkerGlobalScope.securityOrigin()->toRawString())
-        .setUrl(m_serviceWorkerGlobalScope.thread().contextData().scriptURL.string())
-        .setContent(scriptBufferToString(m_serviceWorkerGlobalScope.thread().contextData().script))
+        .setUrl(m_serviceWorkerGlobalScope.contextData().scriptURL.string())
+        .setContent(scriptBufferToString(m_serviceWorkerGlobalScope.contextData().script))
         .release();
 }
 

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp (275287 => 275288)


--- trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp	2021-03-31 17:15:43 UTC (rev 275288)
@@ -44,16 +44,16 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(ServiceWorkerGlobalScope);
 
-Ref<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::create(const ServiceWorkerContextData& data, const WorkerParameters& params, Ref<SecurityOrigin>&& origin, ServiceWorkerThread& thread, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)
+Ref<ServiceWorkerGlobalScope> ServiceWorkerGlobalScope::create(ServiceWorkerContextData&& data, const WorkerParameters& params, Ref<SecurityOrigin>&& origin, ServiceWorkerThread& thread, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)
 {
-    auto scope = adoptRef(*new ServiceWorkerGlobalScope { data, params, WTFMove(origin), thread, WTFMove(topOrigin), connectionProxy, socketProvider });
+    auto scope = adoptRef(*new ServiceWorkerGlobalScope { WTFMove(data), params, WTFMove(origin), thread, WTFMove(topOrigin), connectionProxy, socketProvider });
     scope->applyContentSecurityPolicyResponseHeaders(params.contentSecurityPolicyResponseHeaders);
     return scope;
 }
 
-ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(const ServiceWorkerContextData& data, const WorkerParameters& params, Ref<SecurityOrigin>&& origin, ServiceWorkerThread& thread, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)
+ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(ServiceWorkerContextData&& data, const WorkerParameters& params, Ref<SecurityOrigin>&& origin, ServiceWorkerThread& thread, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider)
     : WorkerGlobalScope(WorkerThreadType::ServiceWorker, params, WTFMove(origin), thread, WTFMove(topOrigin), connectionProxy, socketProvider)
-    , m_contextData(crossThreadCopy(data))
+    , m_contextData(WTFMove(data))
     , m_registration(ServiceWorkerRegistration::getOrCreate(*this, navigator().serviceWorker(), WTFMove(m_contextData.registration)))
     , m_clients(ServiceWorkerClients::create())
 {

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h (275287 => 275288)


--- trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h	2021-03-31 17:15:43 UTC (rev 275288)
@@ -44,7 +44,7 @@
 class ServiceWorkerGlobalScope final : public WorkerGlobalScope {
     WTF_MAKE_ISO_ALLOCATED(ServiceWorkerGlobalScope);
 public:
-    static Ref<ServiceWorkerGlobalScope> create(const ServiceWorkerContextData&, const WorkerParameters&, Ref<SecurityOrigin>&&, ServiceWorkerThread&, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
+    static Ref<ServiceWorkerGlobalScope> create(ServiceWorkerContextData&&, const WorkerParameters&, Ref<SecurityOrigin>&&, ServiceWorkerThread&, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
 
     ~ServiceWorkerGlobalScope();
 
@@ -68,12 +68,13 @@
     const ServiceWorkerContextData::ImportedScript* scriptResource(const URL&) const;
     void setScriptResource(const URL&, ServiceWorkerContextData::ImportedScript&&);
 
+    const ServiceWorkerContextData& contextData() const { return m_contextData; }
     const CertificateInfo& certificateInfo() const { return m_contextData.certificateInfo; }
 
     FetchOptions::Destination destination() const final { return FetchOptions::Destination::Serviceworker; }
     
 private:
-    ServiceWorkerGlobalScope(const ServiceWorkerContextData&, const WorkerParameters&, Ref<SecurityOrigin>&&, ServiceWorkerThread&, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
+    ServiceWorkerGlobalScope(ServiceWorkerContextData&&, const WorkerParameters&, Ref<SecurityOrigin>&&, ServiceWorkerThread&, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*);
 
     bool hasPendingEvents() const { return !m_extendedEvents.isEmpty(); }
 

Modified: trunk/Source/WebCore/workers/service/context/SWContextManager.cpp (275287 => 275288)


--- trunk/Source/WebCore/workers/service/context/SWContextManager.cpp	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.cpp	2021-03-31 17:15:43 UTC (rev 275288)
@@ -55,7 +55,7 @@
 void SWContextManager::registerServiceWorkerThreadForInstall(Ref<ServiceWorkerThreadProxy>&& serviceWorkerThreadProxy)
 {
     auto serviceWorkerIdentifier = serviceWorkerThreadProxy->identifier();
-    auto jobDataIdentifier = serviceWorkerThreadProxy->thread().contextData().jobDataIdentifier;
+    auto jobDataIdentifier = serviceWorkerThreadProxy->thread().jobDataIdentifier();
     auto* threadProxy = serviceWorkerThreadProxy.ptr();
     auto result = m_workerMap.add(serviceWorkerIdentifier, WTFMove(serviceWorkerThreadProxy));
     ASSERT_UNUSED(result, result.isNewEntry);

Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (275287 => 275288)


--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp	2021-03-31 17:15:43 UTC (rev 275288)
@@ -73,9 +73,11 @@
 // FIXME: Use a valid WorkerObjectProxy
 // FIXME: Use valid runtime flags
 
-ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, String&& userAgent, const Settings::Values& settingsValues, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider)
+ServiceWorkerThread::ServiceWorkerThread(ServiceWorkerContextData&& data, String&& userAgent, const Settings::Values& settingsValues, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider)
     : WorkerThread({ data.scriptURL, emptyString(), "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.contentSecurityPolicy, false, MonotonicTime::now(), { }, data.workerType, FetchRequestCredentials::Omit, settingsValues }, scriptBufferToString(data.script), loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.registration.key.topOrigin().securityOrigin().get(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled())
-    , m_data(data.isolatedCopy())
+    , m_serviceWorkerIdentifier(data.serviceWorkerIdentifier)
+    , m_jobDataIdentifier(data.jobDataIdentifier)
+    , m_data(crossThreadCopy(data))
     , m_workerObjectProxy(DummyServiceWorkerThreadProxy::shared())
     , m_heartBeatTimeout(SWContextManager::singleton().connection()->shouldUseShortTimeout() ? heartBeatTimeoutForTest : heartBeatTimeout)
     , m_heartBeatTimer { *this, &ServiceWorkerThread::heartBeatTimerFired }
@@ -88,7 +90,8 @@
 
 Ref<WorkerGlobalScope> ServiceWorkerThread::createWorkerGlobalScope(const WorkerParameters& params, Ref<SecurityOrigin>&& origin, Ref<SecurityOrigin>&& topOrigin)
 {
-    return ServiceWorkerGlobalScope::create(m_data, params, WTFMove(origin), *this, WTFMove(topOrigin), idbConnectionProxy(), socketProvider());
+    RELEASE_ASSERT(m_data);
+    return ServiceWorkerGlobalScope::create(*std::exchange(m_data, WTF::nullopt), params, WTFMove(origin), *this, WTFMove(topOrigin), idbConnectionProxy(), socketProvider());
 }
 
 void ServiceWorkerThread::runEventLoop()
@@ -257,10 +260,10 @@
         connection->didFailHeartBeatCheck(identifier());
         break;
     case State::Starting:
-        connection->serviceWorkerFailedToStart(m_data.jobDataIdentifier, identifier(), "Service Worker script execution timed out"_s);
+        connection->serviceWorkerFailedToStart(m_jobDataIdentifier, identifier(), "Service Worker script execution timed out"_s);
         break;
     case State::Installing:
-        connection->didFinishInstall(m_data.jobDataIdentifier, identifier(), false);
+        connection->didFinishInstall(m_jobDataIdentifier, identifier(), false);
         break;
     }
 }
@@ -276,7 +279,7 @@
     m_state = State::Idle;
 
     if (auto* connection = SWContextManager::singleton().connection())
-        connection->didFinishInstall(m_data.jobDataIdentifier, identifier(), !hasRejectedAnyPromise);
+        connection->didFinishInstall(m_jobDataIdentifier, identifier(), !hasRejectedAnyPromise);
 }
 
 void ServiceWorkerThread::willPostTaskToFireActivateEvent()

Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h (275287 => 275288)


--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h	2021-03-31 17:15:43 UTC (rev 275288)
@@ -67,9 +67,8 @@
     void queueTaskToFireInstallEvent();
     void queueTaskToFireActivateEvent();
 
-    const ServiceWorkerContextData& contextData() const { return m_data; }
-
-    ServiceWorkerIdentifier identifier() const { return m_data.serviceWorkerIdentifier; }
+    ServiceWorkerIdentifier identifier() const { return m_serviceWorkerIdentifier; }
+    Optional<ServiceWorkerJobDataIdentifier> jobDataIdentifier() const { return m_jobDataIdentifier; }
     bool doesHandleFetch() const { return m_doesHandleFetch; }
 
     void startFetchEventMonitoring();
@@ -80,7 +79,7 @@
     void runEventLoop() override;
 
 private:
-    WEBCORE_EXPORT ServiceWorkerThread(const ServiceWorkerContextData&, String&& userAgent, const Settings::Values&, WorkerLoaderProxy&, WorkerDebuggerProxy&, IDBClient::IDBConnectionProxy*, SocketProvider*);
+    WEBCORE_EXPORT ServiceWorkerThread(ServiceWorkerContextData&&, String&& userAgent, const Settings::Values&, WorkerLoaderProxy&, WorkerDebuggerProxy&, IDBClient::IDBConnectionProxy*, SocketProvider*);
 
     bool isServiceWorkerThread() const final { return true; }
     void finishedEvaluatingScript() final;
@@ -94,7 +93,9 @@
     void heartBeatTimerFired();
     void installEventTimerFired();
 
-    ServiceWorkerContextData m_data;
+    ServiceWorkerIdentifier m_serviceWorkerIdentifier;
+    Optional<ServiceWorkerJobDataIdentifier> m_jobDataIdentifier;
+    Optional<ServiceWorkerContextData> m_data; // Becomes WTF::nullopt after the ServiceWorkerGlobalScope has been created.
     WorkerObjectProxy& m_workerObjectProxy;
     bool m_doesHandleFetch { false };
 

Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp (275287 => 275288)


--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp	2021-03-31 17:15:43 UTC (rev 275288)
@@ -92,10 +92,13 @@
     return set;
 }
 
-ServiceWorkerThreadProxy::ServiceWorkerThreadProxy(PageConfiguration&& pageConfiguration, const ServiceWorkerContextData& data, String&& userAgent, CacheStorageProvider& cacheStorageProvider, StorageBlockingPolicy storageBlockingPolicy)
+ServiceWorkerThreadProxy::ServiceWorkerThreadProxy(PageConfiguration&& pageConfiguration, ServiceWorkerContextData&& data, String&& userAgent, CacheStorageProvider& cacheStorageProvider, StorageBlockingPolicy storageBlockingPolicy)
     : m_page(createPageForServiceWorker(WTFMove(pageConfiguration), data, storageBlockingPolicy))
     , m_document(*m_page->mainFrame().document())
-    , m_serviceWorkerThread(ServiceWorkerThread::create(data, WTFMove(userAgent), m_document->settingsValues(), *this, *this, idbConnectionProxy(m_document), m_document->socketProvider()))
+#if ENABLE(REMOTE_INSPECTOR)
+    , m_remoteDebuggable(makeUnique<ServiceWorkerDebuggable>(*this, data))
+#endif
+    , m_serviceWorkerThread(ServiceWorkerThread::create(WTFMove(data), WTFMove(userAgent), m_document->settingsValues(), *this, *this, idbConnectionProxy(m_document), m_document->socketProvider()))
     , m_cacheStorageProvider(cacheStorageProvider)
     , m_inspectorProxy(*this)
 {
@@ -109,7 +112,6 @@
     allServiceWorkerThreadProxies().add(this);
 
 #if ENABLE(REMOTE_INSPECTOR)
-    m_remoteDebuggable = makeUnique<ServiceWorkerDebuggable>(*this, data);
     m_remoteDebuggable->setRemoteDebuggingAllowed(true);
     m_remoteDebuggable->init();
 #endif

Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h (275287 => 275288)


--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h	2021-03-31 17:15:43 UTC (rev 275288)
@@ -82,7 +82,7 @@
     WEBCORE_EXPORT void setLastNavigationWasAppBound(bool);
 
 private:
-    WEBCORE_EXPORT ServiceWorkerThreadProxy(PageConfiguration&&, const ServiceWorkerContextData&, String&& userAgent, CacheStorageProvider&, StorageBlockingPolicy);
+    WEBCORE_EXPORT ServiceWorkerThreadProxy(PageConfiguration&&, ServiceWorkerContextData&&, String&& userAgent, CacheStorageProvider&, StorageBlockingPolicy);
 
     WEBCORE_EXPORT static void networkStateChanged(bool isOnLine);
 
@@ -98,6 +98,9 @@
 
     UniqueRef<Page> m_page;
     Ref<Document> m_document;
+#if ENABLE(REMOTE_INSPECTOR)
+    std::unique_ptr<ServiceWorkerDebuggable> m_remoteDebuggable;
+#endif
     Ref<ServiceWorkerThread> m_serviceWorkerThread;
     CacheStorageProvider& m_cacheStorageProvider;
     RefPtr<CacheStorageConnection> m_cacheStorageConnection;
@@ -104,9 +107,6 @@
     bool m_isTerminatingOrTerminated { false };
 
     ServiceWorkerInspectorProxy m_inspectorProxy;
-#if ENABLE(REMOTE_INSPECTOR)
-    std::unique_ptr<ServiceWorkerDebuggable> m_remoteDebuggable;
-#endif
     HashMap<std::pair<SWServerConnectionIdentifier, FetchIdentifier>, Ref<ServiceWorkerFetch::Client>> m_ongoingFetchTasks;
 };
 

Modified: trunk/Source/WebKit/ChangeLog (275287 => 275288)


--- trunk/Source/WebKit/ChangeLog	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebKit/ChangeLog	2021-03-31 17:15:43 UTC (rev 275288)
@@ -1,3 +1,14 @@
+2021-03-31  Chris Dumez  <cdu...@apple.com>
+
+        ServiceWorkerContextData should not be saved both on ServiceWorkerThread & ServiceWorkerGlobalScope
+        https://bugs.webkit.org/show_bug.cgi?id=224001
+
+        Reviewed by Geoffrey Garen.
+
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::WebSWContextManagerConnection::installServiceWorker):
+        * WebProcess/Storage/WebSWContextManagerConnection.h:
+
 2021-03-30  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [iOS] Fall back to context menu presentation after long pressing image overlay text

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (275287 => 275288)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp	2021-03-31 17:15:43 UTC (rev 275288)
@@ -135,7 +135,7 @@
     setShouldUseShortTimeout(store.getBoolValueForKey(WebPreferencesKey::shouldUseServiceWorkerShortTimeoutKey()));
 }
 
-void WebSWContextManagerConnection::installServiceWorker(const ServiceWorkerContextData& data, String&& userAgent)
+void WebSWContextManagerConnection::installServiceWorker(ServiceWorkerContextData&& data, String&& userAgent)
 {
     auto pageConfiguration = pageConfigurationWithEmptyClients(WebProcess::singleton().sessionID());
 
@@ -152,10 +152,11 @@
 
     pageConfiguration.loaderClientForMainFrame = makeUniqueRef<ServiceWorkerFrameLoaderClient>(m_webPageProxyID, m_pageID, FrameIdentifier::generate(), effectiveUserAgent);
 
-    auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(pageConfiguration), data, WTFMove(effectiveUserAgent), WebProcess::singleton().cacheStorageProvider(), m_storageBlockingPolicy);
+    auto serviceWorkerIdentifier = data.serviceWorkerIdentifier;
+    auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(pageConfiguration), WTFMove(data), WTFMove(effectiveUserAgent), WebProcess::singleton().cacheStorageProvider(), m_storageBlockingPolicy);
     SWContextManager::singleton().registerServiceWorkerThreadForInstall(WTFMove(serviceWorkerThreadProxy));
 
-    RELEASE_LOG(ServiceWorker, "Created service worker %" PRIu64 " in process PID %i", data.serviceWorkerIdentifier.toUInt64(), getCurrentProcessID());
+    RELEASE_LOG(ServiceWorker, "Created service worker %" PRIu64 " in process PID %i", serviceWorkerIdentifier.toUInt64(), getCurrentProcessID());
 }
 
 void WebSWContextManagerConnection::setUserAgent(String&& userAgent)

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h (275287 => 275288)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h	2021-03-31 17:10:46 UTC (rev 275287)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h	2021-03-31 17:15:43 UTC (rev 275288)
@@ -82,7 +82,7 @@
     // IPC messages.
     void serviceWorkerStarted(Optional<WebCore::ServiceWorkerJobDataIdentifier>, WebCore::ServiceWorkerIdentifier, bool doesHandleFetch) final;
     void serviceWorkerFailedToStart(Optional<WebCore::ServiceWorkerJobDataIdentifier>, WebCore::ServiceWorkerIdentifier, const String& exceptionMessage) final;
-    void installServiceWorker(const WebCore::ServiceWorkerContextData&, String&& userAgent);
+    void installServiceWorker(WebCore::ServiceWorkerContextData&&, String&& userAgent);
     void startFetch(WebCore::SWServerConnectionIdentifier, WebCore::ServiceWorkerIdentifier, WebCore::FetchIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&, IPC::FormDataReference&&, String&& referrer);
     void cancelFetch(WebCore::SWServerConnectionIdentifier, WebCore::ServiceWorkerIdentifier, WebCore::FetchIdentifier);
     void continueDidReceiveFetchResponse(WebCore::SWServerConnectionIdentifier, WebCore::ServiceWorkerIdentifier, WebCore::FetchIdentifier);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to