[MSVC] Fix compilation errors with lambdas in Service Workers
authordon.olmstead@sony.com <don.olmstead@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2019 18:23:19 +0000 (18:23 +0000)
committerdon.olmstead@sony.com <don.olmstead@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Feb 2019 18:23:19 +0000 (18:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194841

Reviewed by Alex Christensen.

Source/WebCore:

No new tests. No change in behavior.

MSVC has problems with the scoping of `this` within a nested lambda. In these cases `this` is
referring to the enclosing lambda according to MSVC. This patch works around this behavior
through by using the `protectedThis` pattern in WebKit code.

* workers/service/server/RegistrationDatabase.cpp:
(WebCore::RegistrationDatabase::openSQLiteDatabase):

Source/WebKit:

* WebProcess/Storage/ServiceWorkerClientFetch.cpp:
(WebKit::ServiceWorkerClientFetch::didReceiveRedirectResponse):

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

Source/WebCore/ChangeLog
Source/WebCore/workers/service/server/RegistrationDatabase.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp

index 24a9da3..93eade4 100644 (file)
@@ -1,3 +1,19 @@
+2019-02-20  Don Olmstead  <don.olmstead@sony.com>
+
+        [MSVC] Fix compilation errors with lambdas in Service Workers
+        https://bugs.webkit.org/show_bug.cgi?id=194841
+
+        Reviewed by Alex Christensen.
+
+        No new tests. No change in behavior.
+
+        MSVC has problems with the scoping of `this` within a nested lambda. In these cases `this` is
+        referring to the enclosing lambda according to MSVC. This patch works around this behavior
+        through by using the `protectedThis` pattern in WebKit code.
+
+        * workers/service/server/RegistrationDatabase.cpp:
+        (WebCore::RegistrationDatabase::openSQLiteDatabase):
+
 2019-02-20  Adrian Perez de Castro  <aperez@igalia.com>
 
         [WPE][GTK] Enable support for CONTENT_EXTENSIONS
index 55c8fce..41e8055 100644 (file)
@@ -133,7 +133,7 @@ void RegistrationDatabase::openSQLiteDatabase(const String& fullFilename)
     LOG(ServiceWorker, "ServiceWorker RegistrationDatabase opening file %s", fullFilename.utf8().data());
 
     String errorMessage;
-    auto scopeExit = makeScopeExit([&, errorMessage = &errorMessage] {
+    auto scopeExit = makeScopeExit([this, protectedThis = makeRef(*this), errorMessage = &errorMessage] {
         ASSERT_UNUSED(errorMessage, !errorMessage->isNull());
 
 #if RELEASE_LOG_DISABLED
@@ -143,7 +143,7 @@ void RegistrationDatabase::openSQLiteDatabase(const String& fullFilename)
 #endif
 
         m_database = nullptr;
-        callOnMainThread([protectedThis = makeRef(*this)] {
+        callOnMainThread([protectedThis = protectedThis.copyRef()] {
             protectedThis->databaseFailedToOpen();
         });
     });
index f01d82e..f9a3352 100644 (file)
@@ -1,3 +1,13 @@
+2019-02-20  Don Olmstead  <don.olmstead@sony.com>
+
+        [MSVC] Fix compilation errors with lambdas in Service Workers
+        https://bugs.webkit.org/show_bug.cgi?id=194841
+
+        Reviewed by Alex Christensen.
+
+        * WebProcess/Storage/ServiceWorkerClientFetch.cpp:
+        (WebKit::ServiceWorkerClientFetch::didReceiveRedirectResponse):
+
 2019-02-20  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Epiphany searching for plugins even if plugins are disabled
index f07473c..c9a3f34 100644 (file)
@@ -115,7 +115,7 @@ void ServiceWorkerClientFetch::didReceiveRedirectResponse(ResourceResponse&& res
         }
         response.setSource(ResourceResponse::Source::ServiceWorker);
 
-        m_loader->willSendRequest(m_loader->request().redirectedRequest(response, m_shouldClearReferrerOnHTTPSToHTTPRedirect), response, [protectedThis = makeRef(*this), this](ResourceRequest&& request) {
+        m_loader->willSendRequest(m_loader->request().redirectedRequest(response, m_shouldClearReferrerOnHTTPSToHTTPRedirect), response, [this, protectedThis = protectedThis.copyRef()](ResourceRequest&& request) {
             if (!m_loader || request.isNull()) {
                 if (auto callback = WTFMove(m_callback))
                     callback(Result::Succeeded);