[MSVC] Fix compilation errors with lambdas in ResourceLoadStatistics
authordon.olmstead@sony.com <don.olmstead@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2019 01:05:08 +0000 (01:05 +0000)
committerdon.olmstead@sony.com <don.olmstead@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2019 01:05:08 +0000 (01:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194913

Reviewed by Brent Fulgham.

MSVC has problems with the scoping of `this` within a nested lambda. To work around the
behavior the enclosing lambda's wrapping of `this` is used within the nested lambda.

* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::requestStorageAccessGranted):

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

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp

index 0969161..87571dc 100644 (file)
@@ -1,3 +1,18 @@
+2019-02-21  Don Olmstead  <don.olmstead@sony.com>
+
+        [MSVC] Fix compilation errors with lambdas in ResourceLoadStatistics
+        https://bugs.webkit.org/show_bug.cgi?id=194913
+
+        Reviewed by Brent Fulgham.
+
+        MSVC has problems with the scoping of `this` within a nested lambda. To work around the
+        behavior the enclosing lambda's wrapping of `this` is used within the nested lambda.
+
+        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
+        (WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords):
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessGranted):
+
 2019-02-21  Chris Dumez  <cdumez@apple.com>
 
         Fix API test crashes after r241855.
index 7ee2ad1..4183c0c 100644 (file)
@@ -354,7 +354,7 @@ void ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords()
         }
     }
 
-    removeDataRecords([this, weakThis = makeWeakPtr(*this)] {
+    removeDataRecords([this, weakThis = makeWeakPtr(*this)]() mutable {
         ASSERT(!RunLoop::isMain());
         if (!weakThis)
             return;
@@ -366,7 +366,7 @@ void ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords()
         if (!m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned)
             return;
 
-        RunLoop::main().dispatch([this, weakThis = makeWeakPtr(*this)] {
+        RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis)]() {
             ASSERT(RunLoop::isMain());
             if (!weakThis)
                 return;
index e0dac21..30fe91f 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "APIDictionary.h"
 #include "Logging.h"
+#include "NetworkProcess.h"
 #include "NetworkSession.h"
 #include "ResourceLoadStatisticsMemoryStore.h"
 #include "ResourceLoadStatisticsPersistentStorage.h"
@@ -305,7 +306,7 @@ void WebResourceLoadStatisticsStore::requestStorageAccessGranted(const String& s
             ASSERT_UNUSED(promptEnabled, promptEnabled);
             auto subFramePrimaryDomain = ResourceLoadStatistics::primaryDomain(subFrameHost);
             auto topFramePrimaryDomain = ResourceLoadStatistics::primaryDomain(topFrameHost);
-            CompletionHandler<void(bool)> requestConfirmationCompletionHandler = [this, protectedThis = makeRef(*this), subFrameHost = WTFMove(subFrameHost), topFrameHost = WTFMove(topFrameHost), frameID, pageID, completionHandler = WTFMove(completionHandler)] (bool userDidGrantAccess) mutable {
+            CompletionHandler<void(bool)> requestConfirmationCompletionHandler = [this, protectedThis = protectedThis.copyRef(), subFrameHost = WTFMove(subFrameHost), topFrameHost = WTFMove(topFrameHost), frameID, pageID, completionHandler = WTFMove(completionHandler)] (bool userDidGrantAccess) mutable {
                 if (userDidGrantAccess)
                     grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userDidGrantAccess, WTFMove(completionHandler));
                 else