Update ServiceWorkerContainer::getRegistration lambdas
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Dec 2018 21:35:50 +0000 (21:35 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Dec 2018 21:35:50 +0000 (21:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192376

Reviewed by Chris Dumez.

There is no need to pass 'this' in lambdas as the last lambda
takes a ScriptExecutionContext&.
No change of behavior.

* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::getRegistration):
(WebCore::ServiceWorkerContainer::getRegistrations):

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

Source/WebCore/ChangeLog
Source/WebCore/workers/service/ServiceWorkerContainer.cpp

index 8097b3e..a02c7b0 100644 (file)
@@ -1,3 +1,18 @@
+2018-12-05  Youenn Fablet  <youenn@apple.com>
+
+        Update ServiceWorkerContainer::getRegistration lambdas
+        https://bugs.webkit.org/show_bug.cgi?id=192376
+
+        Reviewed by Chris Dumez.
+
+        There is no need to pass 'this' in lambdas as the last lambda
+        takes a ScriptExecutionContext&.
+        No change of behavior.
+
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::getRegistration):
+        (WebCore::ServiceWorkerContainer::getRegistrations):
+
 2018-12-05  Chris Dumez  <cdumez@apple.com>
 
         Crash under WebCore::cachedDocumentWrapper()
index 969bd20..0ef9bf3 100644 (file)
@@ -269,10 +269,16 @@ void ServiceWorkerContainer::getRegistration(const String& clientURL, Ref<Deferr
     m_pendingPromises.add(pendingPromiseIdentifier, WTFMove(pendingPromise));
 
     auto contextIdentifier = this->contextIdentifier();
-    callOnMainThread([connection = makeRef(ensureSWClientConnection()), this, topOrigin = context->topOrigin().data().isolatedCopy(), parsedURL = parsedURL.isolatedCopy(), contextIdentifier, pendingPromiseIdentifier]() mutable {
-        connection->matchRegistration(WTFMove(topOrigin), parsedURL, [this, contextIdentifier, pendingPromiseIdentifier] (auto&& result) mutable {
-            ScriptExecutionContext::postTaskTo(contextIdentifier, [this, pendingPromiseIdentifier, result = crossThreadCopy(result)](ScriptExecutionContext&) mutable {
-                this->didFinishGetRegistrationRequest(pendingPromiseIdentifier, WTFMove(result));
+    callOnMainThread([connection = makeRef(ensureSWClientConnection()), topOrigin = context->topOrigin().data().isolatedCopy(), parsedURL = parsedURL.isolatedCopy(), contextIdentifier, pendingPromiseIdentifier]() mutable {
+        connection->matchRegistration(WTFMove(topOrigin), parsedURL, [contextIdentifier, pendingPromiseIdentifier] (auto&& result) mutable {
+            ScriptExecutionContext::postTaskTo(contextIdentifier, [pendingPromiseIdentifier, result = crossThreadCopy(result)](auto& context) mutable {
+                auto* serviceWorkerContainer = context.serviceWorkerContainer();
+                if (!serviceWorkerContainer)
+                    return;
+                if (serviceWorkerContainer->m_isStopped || !context.sessionID().isValid())
+                    return;
+
+                serviceWorkerContainer->didFinishGetRegistrationRequest(pendingPromiseIdentifier, WTFMove(result));
             });
         });
     });
@@ -332,10 +338,16 @@ void ServiceWorkerContainer::getRegistrations(Ref<DeferredPromise>&& promise)
 
     auto contextIdentifier = this->contextIdentifier();
     auto contextURL = context->url();
-    callOnMainThread([connection = makeRef(ensureSWClientConnection()), this, topOrigin = context->topOrigin().data().isolatedCopy(), contextURL = contextURL.isolatedCopy(), contextIdentifier, pendingPromiseIdentifier]() mutable {
-        connection->getRegistrations(WTFMove(topOrigin), contextURL, [this, contextIdentifier, pendingPromiseIdentifier] (auto&& registrationDatas) mutable {
-            ScriptExecutionContext::postTaskTo(contextIdentifier, [this, pendingPromiseIdentifier, registrationDatas = crossThreadCopy(registrationDatas)](ScriptExecutionContext&) mutable {
-                this->didFinishGetRegistrationsRequest(pendingPromiseIdentifier, WTFMove(registrationDatas));
+    callOnMainThread([connection = makeRef(ensureSWClientConnection()), topOrigin = context->topOrigin().data().isolatedCopy(), contextURL = contextURL.isolatedCopy(), contextIdentifier, pendingPromiseIdentifier]() mutable {
+        connection->getRegistrations(WTFMove(topOrigin), contextURL, [contextIdentifier, pendingPromiseIdentifier] (auto&& registrationDatas) mutable {
+            ScriptExecutionContext::postTaskTo(contextIdentifier, [pendingPromiseIdentifier, registrationDatas = crossThreadCopy(registrationDatas)](auto& context) mutable {
+                auto* serviceWorkerContainer = context.serviceWorkerContainer();
+                if (!serviceWorkerContainer)
+                    return;
+                if (serviceWorkerContainer->m_isStopped || !context.sessionID().isValid())
+                    return;
+
+                serviceWorkerContainer->didFinishGetRegistrationsRequest(pendingPromiseIdentifier, WTFMove(registrationDatas));
             });
         });
     });