ServiceWorkerThreadProxy::postTaskForModeToWorkerGlobalScope should be a no-op if...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 08:26:17 +0000 (08:26 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 08:26:17 +0000 (08:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181245

Patch by Youenn Fablet <youenn@apple.com> on 2018-01-04
Reviewed by Alex Christensen.

Stop appending tasks to a terminating worker and returning false in that case.
This mirrors what is done for regular workers.

* workers/service/context/SWContextManager.cpp:
(WebCore::SWContextManager::terminateWorker):
* workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::ServiceWorkerThreadProxy::postTaskForModeToWorkerGlobalScope):
* workers/service/context/ServiceWorkerThreadProxy.h:

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

Source/WebCore/ChangeLog
Source/WebCore/workers/service/context/SWContextManager.cpp
Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp
Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h

index 45096df..e3c0ed0 100644 (file)
@@ -1,5 +1,21 @@
 2018-01-04  Youenn Fablet  <youenn@apple.com>
 
+        ServiceWorkerThreadProxy::postTaskForModeToWorkerGlobalScope should be a no-op if worker is being terminated
+        https://bugs.webkit.org/show_bug.cgi?id=181245
+
+        Reviewed by Alex Christensen.
+
+        Stop appending tasks to a terminating worker and returning false in that case.
+        This mirrors what is done for regular workers.
+
+        * workers/service/context/SWContextManager.cpp:
+        (WebCore::SWContextManager::terminateWorker):
+        * workers/service/context/ServiceWorkerThreadProxy.cpp:
+        (WebCore::ServiceWorkerThreadProxy::postTaskForModeToWorkerGlobalScope):
+        * workers/service/context/ServiceWorkerThreadProxy.h:
+
+2018-01-04  Youenn Fablet  <youenn@apple.com>
+
         Cancel pending script loads when service worker is being terminated
         https://bugs.webkit.org/show_bug.cgi?id=181250
 
index 9dac058..624fea7 100644 (file)
@@ -101,7 +101,7 @@ void SWContextManager::terminateWorker(ServiceWorkerIdentifier identifier, Funct
     if (!serviceWorker)
         return;
 
-    serviceWorker->setTerminatingOrTerminated(true);
+    serviceWorker->setAsTerminatingOrTerminated();
 
     serviceWorker->thread().stop([identifier, serviceWorker = WTFMove(serviceWorker), completionHandler = WTFMove(completionHandler)]() mutable {
         if (auto* connection = SWContextManager::singleton().connection())
index 9e590e8..3feb93c 100644 (file)
@@ -94,7 +94,9 @@ ServiceWorkerThreadProxy::ServiceWorkerThreadProxy(PageConfiguration&& pageConfi
 
 bool ServiceWorkerThreadProxy::postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&& task, const String& mode)
 {
-    // FIXME: Handle termination case.
+    if (m_isTerminatingOrTerminated)
+        return false;
+
     m_serviceWorkerThread->runLoop().postTaskForMode(WTFMove(task), mode);
     return true;
 }
index 8791c8d..db1ccdf 100644 (file)
@@ -60,7 +60,7 @@ public:
     ServiceWorkerInspectorProxy& inspectorProxy() { return m_inspectorProxy; }
 
     bool isTerminatingOrTerminated() const { return m_isTerminatingOrTerminated; }
-    void setTerminatingOrTerminated(bool terminating) { m_isTerminatingOrTerminated = terminating; }
+    void setAsTerminatingOrTerminated() { m_isTerminatingOrTerminated = true; }
 
     WEBCORE_EXPORT std::unique_ptr<FetchLoader> createBlobLoader(FetchLoaderClient&, const URL&);