Title: [252848] trunk/Source/WebCore
Revision
252848
Author
[email protected]
Date
2019-11-25 01:13:41 -0800 (Mon, 25 Nov 2019)

Log Message

Use SWClientConnection instead of hopping to main thread in ServiceWorkerContainer
https://bugs.webkit.org/show_bug.cgi?id=204499

Reviewed by Chris Dumez.

Make use of SWClientConnection instead of callOnMainThread.
This removes the callOnMainThread call if we are already on the main thread.
No observable change of behavior.
Remove failedFetchingScript since it is just a call to finishFetchingScriptInServer.

* workers/service/SWClientConnection.cpp:
(WebCore::SWClientConnection::startScriptFetchForServer):
* workers/service/SWClientConnection.h:
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::notifyRegistrationIsSettled):
(WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
(WebCore::ServiceWorkerContainer::notifyFailedFetchingScript):
* workers/service/ServiceWorkerFetchResult.h:
(WebCore::serviceWorkerFetchError):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (252847 => 252848)


--- trunk/Source/WebCore/ChangeLog	2019-11-25 08:50:13 UTC (rev 252847)
+++ trunk/Source/WebCore/ChangeLog	2019-11-25 09:13:41 UTC (rev 252848)
@@ -1,5 +1,27 @@
 2019-11-25  Youenn Fablet  <[email protected]>
 
+        Use SWClientConnection instead of hopping to main thread in ServiceWorkerContainer
+        https://bugs.webkit.org/show_bug.cgi?id=204499
+
+        Reviewed by Chris Dumez.
+
+        Make use of SWClientConnection instead of callOnMainThread.
+        This removes the callOnMainThread call if we are already on the main thread.
+        No observable change of behavior.
+        Remove failedFetchingScript since it is just a call to finishFetchingScriptInServer.
+
+        * workers/service/SWClientConnection.cpp:
+        (WebCore::SWClientConnection::startScriptFetchForServer):
+        * workers/service/SWClientConnection.h:
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::notifyRegistrationIsSettled):
+        (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
+        (WebCore::ServiceWorkerContainer::notifyFailedFetchingScript):
+        * workers/service/ServiceWorkerFetchResult.h:
+        (WebCore::serviceWorkerFetchError):
+
+2019-11-25  Youenn Fablet  <[email protected]>
+
         REGRESSION (Safari 13): WebSocket payload is truncated when x-webkit-deflate-frame is used
         https://bugs.webkit.org/show_bug.cgi?id=202401
         <rdar://problem/55922632>

Modified: trunk/Source/WebCore/workers/service/SWClientConnection.cpp (252847 => 252848)


--- trunk/Source/WebCore/workers/service/SWClientConnection.cpp	2019-11-25 08:50:13 UTC (rev 252847)
+++ trunk/Source/WebCore/workers/service/SWClientConnection.cpp	2019-11-25 09:13:41 UTC (rev 252848)
@@ -53,13 +53,6 @@
     scheduleJobInServer(jobData);
 }
 
-void SWClientConnection::failedFetchingScript(ServiceWorkerJobIdentifier jobIdentifier, const ServiceWorkerRegistrationKey& registrationKey, const ResourceError& error)
-{
-    ASSERT(isMainThread());
-
-    finishFetchingScriptInServer({ { serverConnectionIdentifier(), jobIdentifier }, registrationKey, { }, { }, { },  error });
-}
-
 bool SWClientConnection::postTaskForJob(ServiceWorkerJobIdentifier jobIdentifier, IsJobComplete isJobComplete, Function<void(ServiceWorkerJob&)>&& task)
 {
     ASSERT(isMainThread());
@@ -110,7 +103,7 @@
         job.startScriptFetch(cachePolicy);
     });
     if (!isPosted)
-        failedFetchingScript(jobIdentifier, registrationKey, ResourceError { errorDomainWebKitInternal, 0, { }, makeString("Failed to fetch script for service worker with scope ", registrationKey.scope().string()) });
+        finishFetchingScriptInServer(serviceWorkerFetchError({ serverConnectionIdentifier(), jobIdentifier }, ServiceWorkerRegistrationKey { registrationKey}, ResourceError { errorDomainWebKitInternal, 0, { }, makeString("Failed to fetch script for service worker with scope ", registrationKey.scope().string()) }));
 }
 
 

Modified: trunk/Source/WebCore/workers/service/SWClientConnection.h (252847 => 252848)


--- trunk/Source/WebCore/workers/service/SWClientConnection.h	2019-11-25 08:50:13 UTC (rev 252847)
+++ trunk/Source/WebCore/workers/service/SWClientConnection.h	2019-11-25 09:13:41 UTC (rev 252848)
@@ -70,7 +70,6 @@
     virtual void removeServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier) = 0;
 
     WEBCORE_EXPORT virtual void scheduleJob(DocumentOrWorkerIdentifier, const ServiceWorkerJobData&);
-    void failedFetchingScript(ServiceWorkerJobIdentifier, const ServiceWorkerRegistrationKey&, const ResourceError&);
 
     virtual void didResolveRegistrationPromise(const ServiceWorkerRegistrationKey&) = 0;
 

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (252847 => 252848)


--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp	2019-11-25 08:50:13 UTC (rev 252847)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp	2019-11-25 09:13:41 UTC (rev 252848)
@@ -416,9 +416,7 @@
 
 void ServiceWorkerContainer::notifyRegistrationIsSettled(const ServiceWorkerRegistrationKey& registrationKey)
 {
-    callOnMainThread([registrationKey = registrationKey.isolatedCopy()] {
-        mainThreadConnection().didResolveRegistrationPromise(registrationKey);
-    });
+    ensureSWClientConnection().didResolveRegistrationPromise(registrationKey);
 }
 
 void ServiceWorkerContainer::jobResolvedWithUnregistrationResult(ServiceWorkerJob& job, bool unregistrationResult)
@@ -473,9 +471,7 @@
 
     CONTAINER_RELEASE_LOG_IF_ALLOWED("jobFinishedLoadingScript: Successfuly finished fetching script for job %" PRIu64, job.identifier().toUInt64());
 
-    callOnMainThread([jobDataIdentifier = job.data().identifier(), registrationKey = job.data().registrationKey().isolatedCopy(), script = script.isolatedCopy(), contentSecurityPolicy = contentSecurityPolicy.isolatedCopy(), referrerPolicy = referrerPolicy.isolatedCopy()] {
-        mainThreadConnection().finishFetchingScriptInServer({ jobDataIdentifier, registrationKey, script, contentSecurityPolicy, referrerPolicy, { } });
-    });
+    ensureSWClientConnection().finishFetchingScriptInServer({ job.data().identifier(), job.data().registrationKey(), script, contentSecurityPolicy, referrerPolicy, { } });
 }
 
 void ServiceWorkerContainer::jobFailedLoadingScript(ServiceWorkerJob& job, const ResourceError& error, Exception&& exception)
@@ -499,9 +495,7 @@
 
 void ServiceWorkerContainer::notifyFailedFetchingScript(ServiceWorkerJob& job, const ResourceError& error)
 {
-    callOnMainThread([jobIdentifier = job.identifier(), registrationKey = job.data().registrationKey().isolatedCopy(), error = error.isolatedCopy()] {
-        mainThreadConnection().failedFetchingScript(jobIdentifier, registrationKey, error);
-    });
+    ensureSWClientConnection().finishFetchingScriptInServer(serviceWorkerFetchError(job.data().identifier(), ServiceWorkerRegistrationKey { job.data().registrationKey() }, ResourceError { error }));
 }
 
 void ServiceWorkerContainer::destroyJob(ServiceWorkerJob& job)

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h (252847 => 252848)


--- trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h	2019-11-25 08:50:13 UTC (rev 252847)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h	2019-11-25 09:13:41 UTC (rev 252848)
@@ -48,6 +48,11 @@
     template<class Decoder> static bool decode(Decoder&, ServiceWorkerFetchResult&);
 };
 
+inline ServiceWorkerFetchResult serviceWorkerFetchError(ServiceWorkerJobDataIdentifier jobDataIdentifier, ServiceWorkerRegistrationKey&& registrationKey, ResourceError&& error)
+{
+    return { jobDataIdentifier, WTFMove(registrationKey), { }, { }, { }, WTFMove(error) };
+}
+
 template<class Encoder>
 void ServiceWorkerFetchResult::encode(Encoder& encoder) const
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to