Title: [233083] trunk/Source/WebKit
Revision
233083
Author
[email protected]
Date
2018-06-22 09:54:55 -0700 (Fri, 22 Jun 2018)

Log Message

[iOS Debug] Multiple resourceLoadStatistics redirect tests are flaky timeouts
https://bugs.webkit.org/show_bug.cgi?id=183216
<rdar://problem/37992317>

Reviewed by Chris Dumez.

Improve consistency of test results by make sure that completion handlers written to run
on the main thread are only called on the main thread. Add additional assertions to help
catch any cases where this invariant is not being honored.

* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::hasStorageAccess): Use Completion handler and assert
we are on the right thread.
(WebKit::WebResourceLoadStatisticsStore::requestStorageAccess): Ditto.
(WebKit::WebResourceLoadStatisticsStore::grantStorageAccess): Ditto.
(WebKit::WebResourceLoadStatisticsStore::logUserInteraction): Ditto.
(WebKit::WebResourceLoadStatisticsStore::logNonRecentUserInteraction): Ditto.
(WebKit::WebResourceLoadStatisticsStore::clearUserInteraction): Ditto.
(WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction): Ditto.
(WebKit::WebResourceLoadStatisticsStore::setLastSeen): Ditto.
(WebKit::WebResourceLoadStatisticsStore::setPrevalentResource): Ditto.
(WebKit::WebResourceLoadStatisticsStore::isPrevalentResource): Ditto.
(WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource): Ditto.
(WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder): Ditto.
(WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo): Ditto.
(WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource): Ditto.
(WebKit::WebResourceLoadStatisticsStore::setGrandfathered): Ditto.
(WebKit::WebResourceLoadStatisticsStore::isGrandfathered): Ditto.
(WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin): Ditto.
(WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin): Ditto.
(WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo): Ditto.
(WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom): Ditto.
(WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo): Ditto.
(WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom): Ditto.
(WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdate):
(WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains):
(WebKit::WebResourceLoadStatisticsStore::scheduleClearPartitioningStateForDomains):
(WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningStateReset):
(WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent): Update to perform callbacks
on the main thread (as intended). This function was doing them on a work queue.
(WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning): Ditto.
(WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains): Ditto.
(WebKit::WebResourceLoadStatisticsStore::clearPartitioningStateForDomains): Ditto.
* UIProcess/WebResourceLoadStatisticsStore.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (233082 => 233083)


--- trunk/Source/WebKit/ChangeLog	2018-06-22 16:54:23 UTC (rev 233082)
+++ trunk/Source/WebKit/ChangeLog	2018-06-22 16:54:55 UTC (rev 233083)
@@ -1,3 +1,50 @@
+2018-06-22  Brent Fulgham  <[email protected]>
+
+        [iOS Debug] Multiple resourceLoadStatistics redirect tests are flaky timeouts
+        https://bugs.webkit.org/show_bug.cgi?id=183216
+        <rdar://problem/37992317>
+
+        Reviewed by Chris Dumez.
+
+        Improve consistency of test results by make sure that completion handlers written to run
+        on the main thread are only called on the main thread. Add additional assertions to help
+        catch any cases where this invariant is not being honored.
+
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess): Use Completion handler and assert
+        we are on the right thread.
+        (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::logUserInteraction): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::logNonRecentUserInteraction): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::setLastSeen): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::setGrandfathered): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::isGrandfathered): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdate): 
+        (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains):
+        (WebKit::WebResourceLoadStatisticsStore::scheduleClearPartitioningStateForDomains):
+        (WebKit::WebResourceLoadStatisticsStore::scheduleCookiePartitioningStateReset):
+        (WebKit::WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent): Update to perform callbacks
+        on the main thread (as intended). This function was doing them on a work queue.
+        (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioning): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains): Ditto.
+        (WebKit::WebResourceLoadStatisticsStore::clearPartitioningStateForDomains): Ditto.
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+
 2018-06-22  Michael Catanzaro  <[email protected]>
 
         REGRESSION(r230950): [GTK] WebKit::CoordinatedBackingStoreTile::setBackBuffer(): WebKitWebProcess killed by SIGSEGV (ASSERTION FAILED: it != m_tiles.end())

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (233082 => 233083)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2018-06-22 16:54:23 UTC (rev 233082)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2018-06-22 16:54:55 UTC (rev 233083)
@@ -371,37 +371,37 @@
     processStatisticsAndDataRecords();
 }
 
-void WebResourceLoadStatisticsStore::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void (bool)>&& callback)
+void WebResourceLoadStatisticsStore::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void (bool)>&& completionHandler)
 {
     ASSERT(subFrameHost != topFrameHost);
     ASSERT(RunLoop::isMain());
 
-    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost), frameID, pageID, callback = WTFMove(callback)] () mutable {
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost), frameID, pageID, completionHandler = WTFMove(completionHandler)] () mutable {
         
         auto& subFrameStatistic = ensureResourceStatisticsForPrimaryDomain(subFramePrimaryDomain);
         if (shouldBlockCookies(subFrameStatistic)) {
-            RunLoop::main().dispatch([callback = WTFMove(callback)] {
-                callback(false);
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {
+                completionHandler(false);
             });
             return;
         }
 
         if (!shouldPartitionCookies(subFrameStatistic)) {
-            RunLoop::main().dispatch([callback = WTFMove(callback)] {
-                callback(true);
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {
+                completionHandler(true);
             });
             return;
         }
 
-        m_hasStorageAccessForFrameHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, [callback = WTFMove(callback)] (bool value) mutable {
-            RunLoop::main().dispatch([callback = WTFMove(callback), value] () mutable {
-                callback(value);
+        m_hasStorageAccessForFrameHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, [completionHandler = WTFMove(completionHandler)] (bool value) mutable {
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), value] () mutable {
+                completionHandler(value);
             });
         });
     });
 }
 
-void WebResourceLoadStatisticsStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& callback)
+void WebResourceLoadStatisticsStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)
 {
     ASSERT(subFrameHost != topFrameHost);
     ASSERT(RunLoop::isMain());
@@ -409,23 +409,23 @@
     auto subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost);
     auto topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost);
     if (subFramePrimaryDomain == topFramePrimaryDomain) {
-        callback(StorageAccessStatus::HasAccess);
+        completionHandler(StorageAccessStatus::HasAccess);
         return;
     }
 
-    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFramePrimaryDomain = crossThreadCopy(subFramePrimaryDomain), topFramePrimaryDomain = crossThreadCopy(topFramePrimaryDomain), frameID, pageID, promptEnabled, callback = WTFMove(callback)] () mutable {
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFramePrimaryDomain = crossThreadCopy(subFramePrimaryDomain), topFramePrimaryDomain = crossThreadCopy(topFramePrimaryDomain), frameID, pageID, promptEnabled, completionHandler = WTFMove(completionHandler)] () mutable {
 
         auto& subFrameStatistic = ensureResourceStatisticsForPrimaryDomain(subFramePrimaryDomain);
         if (shouldBlockCookies(subFrameStatistic)) {
-            RunLoop::main().dispatch([callback = WTFMove(callback)] {
-                callback(StorageAccessStatus::CannotRequestAccess);
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {
+                completionHandler(StorageAccessStatus::CannotRequestAccess);
             });
             return;
         }
         
         if (!shouldPartitionCookies(subFrameStatistic)) {
-            RunLoop::main().dispatch([callback = WTFMove(callback)] {
-                callback(StorageAccessStatus::HasAccess);
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {
+                completionHandler(StorageAccessStatus::HasAccess);
             });
             return;
         }
@@ -432,8 +432,8 @@
 
         auto userWasPromptedEarlier = promptEnabled && hasUserGrantedStorageAccessThroughPrompt(subFrameStatistic, topFramePrimaryDomain);
         if (promptEnabled && !userWasPromptedEarlier) {
-            RunLoop::main().dispatch([callback = WTFMove(callback)] {
-                callback(StorageAccessStatus::RequiresUserPrompt);
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {
+                completionHandler(StorageAccessStatus::RequiresUserPrompt);
             });
             return;
         }
@@ -440,9 +440,9 @@
 
         subFrameStatistic.timesAccessedAsFirstPartyDueToStorageAccessAPI++;
 
-        grantStorageAccessInternal(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID, pageID, userWasPromptedEarlier, [callback = WTFMove(callback)] (bool wasGrantedAccess) mutable {
-            RunLoop::main().dispatch([callback = WTFMove(callback), wasGrantedAccess] () mutable {
-                callback(wasGrantedAccess ? StorageAccessStatus::HasAccess : StorageAccessStatus::CannotRequestAccess);
+        grantStorageAccessInternal(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID, pageID, userWasPromptedEarlier, [completionHandler = WTFMove(completionHandler)] (bool wasGrantedAccess) mutable {
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), wasGrantedAccess] () mutable {
+                completionHandler(wasGrantedAccess ? StorageAccessStatus::HasAccess : StorageAccessStatus::CannotRequestAccess);
             });
         });
     });
@@ -473,10 +473,10 @@
     grantStorageAccessInternal(WTFMove(primaryDomainInNeedOfStorageAccess), WTFMove(openerPrimaryDomain), std::nullopt, openerPageID, false, [](bool) { });
 }
 
-void WebResourceLoadStatisticsStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& callback)
+void WebResourceLoadStatisticsStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
-    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFrameHost = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPromptedNow, callback = WTFMove(callback)] () mutable {
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFrameHost = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPromptedNow, completionHandler = WTFMove(completionHandler)] () mutable {
         auto subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost);
         auto topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost);
         if (userWasPromptedNow) {
@@ -484,9 +484,9 @@
             ASSERT(subFrameStatistic.hadUserInteraction);
             subFrameStatistic.storageAccessUnderTopFrameOrigins.add(topFramePrimaryDomain);
         }
-        grantStorageAccessInternal(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPromptedNow, [callback = WTFMove(callback)] (bool wasGrantedAccess) mutable {
-            RunLoop::main().dispatch([callback = WTFMove(callback), wasGrantedAccess] () mutable {
-                callback(wasGrantedAccess);
+        grantStorageAccessInternal(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPromptedNow, [completionHandler = WTFMove(completionHandler)] (bool wasGrantedAccess) mutable {
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), wasGrantedAccess] () mutable {
+                completionHandler(wasGrantedAccess);
             });
         });
     });
@@ -672,6 +672,8 @@
 
 void WebResourceLoadStatisticsStore::logUserInteraction(const URL& url)
 {
+    ASSERT(RunLoop::isMain());
+
     if (url.isBlankURL() || url.isEmpty())
         return;
 
@@ -687,6 +689,8 @@
 
 void WebResourceLoadStatisticsStore::logNonRecentUserInteraction(const URL& url)
 {
+    ASSERT(RunLoop::isMain());
+
     if (url.isBlankURL() || url.isEmpty())
         return;
     
@@ -701,6 +705,8 @@
 
 void WebResourceLoadStatisticsStore::clearUserInteraction(const URL& url)
 {
+    ASSERT(RunLoop::isMain());
+
     if (url.isBlankURL() || url.isEmpty())
         return;
 
@@ -711,8 +717,10 @@
     });
 }
 
-void WebResourceLoadStatisticsStore::hasHadUserInteraction(const URL& url, WTF::Function<void (bool)>&& completionHandler)
+void WebResourceLoadStatisticsStore::hasHadUserInteraction(const URL& url, CompletionHandler<void (bool)>&& completionHandler)
 {
+    ASSERT(RunLoop::isMain());
+
     if (url.isBlankURL() || url.isEmpty()) {
         completionHandler(false);
         return;
@@ -729,6 +737,8 @@
 
 void WebResourceLoadStatisticsStore::setLastSeen(const URL& url, Seconds seconds)
 {
+    ASSERT(RunLoop::isMain());
+
     if (url.isBlankURL() || url.isEmpty())
         return;
     
@@ -740,6 +750,8 @@
     
 void WebResourceLoadStatisticsStore::setPrevalentResource(const URL& url)
 {
+    ASSERT(RunLoop::isMain());
+
     if (url.isBlankURL() || url.isEmpty())
         return;
 
@@ -778,8 +790,10 @@
     }
 }
 
-void WebResourceLoadStatisticsStore::isPrevalentResource(const URL& url, WTF::Function<void (bool)>&& completionHandler)
+void WebResourceLoadStatisticsStore::isPrevalentResource(const URL& url, CompletionHandler<void (bool)>&& completionHandler)
 {
+    ASSERT(RunLoop::isMain());
+
     if (url.isBlankURL() || url.isEmpty()) {
         completionHandler(false);
         return;
@@ -794,7 +808,7 @@
     });
 }
 
-void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const URL& url, WTF::Function<void(bool)>&& completionHandler)
+void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const URL& url, CompletionHandler<void(bool)>&& completionHandler)
 {
     ASSERT(isMainThread());
 
@@ -812,8 +826,10 @@
     });
 }
 
-void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, WTF::Function<void (bool)>&& completionHandler)
+void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void (bool)>&& completionHandler)
 {
+    ASSERT(RunLoop::isMain());
+
     m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), subFramePrimaryDomain = isolatedPrimaryDomain(subFrame), topFramePrimaryDomain = isolatedPrimaryDomain(topFrame), completionHandler = WTFMove(completionHandler)] () mutable {
         auto mapEntry = m_resourceStatisticsMap.find(subFramePrimaryDomain);
         bool isRegisteredAsSubFrameUnder = mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.subframeUnderTopFrameOrigins.contains(topFramePrimaryDomain);
@@ -823,8 +839,10 @@
     });
 }
 
-void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, WTF::Function<void (bool)>&& completionHandler)
+void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void (bool)>&& completionHandler)
 {
+    ASSERT(RunLoop::isMain());
+
     m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), hostRedirectedFromPrimaryDomain = isolatedPrimaryDomain(hostRedirectedFrom), hostRedirectedToPrimaryDomain = isolatedPrimaryDomain(hostRedirectedTo), completionHandler = WTFMove(completionHandler)] () mutable {
         auto mapEntry = m_resourceStatisticsMap.find(hostRedirectedFromPrimaryDomain);
         bool isRegisteredAsRedirectingTo = mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.subresourceUniqueRedirectsTo.contains(hostRedirectedToPrimaryDomain);
@@ -836,6 +854,8 @@
 
 void WebResourceLoadStatisticsStore::clearPrevalentResource(const URL& url)
 {
+    ASSERT(RunLoop::isMain());
+
     if (url.isBlankURL() || url.isEmpty())
         return;
 
@@ -848,6 +868,8 @@
 
 void WebResourceLoadStatisticsStore::setGrandfathered(const URL& url, bool value)
 {
+    ASSERT(RunLoop::isMain());
+
     if (url.isBlankURL() || url.isEmpty())
         return;
 
@@ -857,8 +879,10 @@
     });
 }
 
-void WebResourceLoadStatisticsStore::isGrandfathered(const URL& url, WTF::Function<void (bool)>&& completionHandler)
+void WebResourceLoadStatisticsStore::isGrandfathered(const URL& url, CompletionHandler<void (bool)>&& completionHandler)
 {
+    ASSERT(RunLoop::isMain());
+
     if (url.isBlankURL() || url.isEmpty()) {
         completionHandler(false);
         return;
@@ -875,6 +899,8 @@
 
 void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame)
 {
+    ASSERT(RunLoop::isMain());
+
     if (subframe.isBlankURL() || subframe.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
         return;
 
@@ -888,6 +914,8 @@
 
 void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame)
 {
+    ASSERT(RunLoop::isMain());
+
     if (subresource.isBlankURL() || subresource.isEmpty() || topFrame.isBlankURL() || topFrame.isEmpty())
         return;
 
@@ -901,6 +929,8 @@
 
 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo)
 {
+    ASSERT(RunLoop::isMain());
+
     if (subresource.isBlankURL() || subresource.isEmpty() || hostNameRedirectedTo.isBlankURL() || hostNameRedirectedTo.isEmpty())
         return;
 
@@ -914,6 +944,8 @@
 
 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom)
 {
+    ASSERT(RunLoop::isMain());
+
     if (subresource.isBlankURL() || subresource.isEmpty() || hostNameRedirectedFrom.isBlankURL() || hostNameRedirectedFrom.isEmpty())
         return;
     
@@ -927,6 +959,8 @@
 
 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo)
 {
+    ASSERT(RunLoop::isMain());
+
     if (topFrameHostName.isBlankURL() || topFrameHostName.isEmpty() || hostNameRedirectedTo.isBlankURL() || hostNameRedirectedTo.isEmpty())
         return;
     
@@ -940,6 +974,8 @@
 
 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom)
 {
+    ASSERT(RunLoop::isMain());
+
     if (topFrameHostName.isBlankURL() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.isBlankURL() || hostNameRedirectedFrom.isEmpty())
         return;
     
@@ -951,31 +987,43 @@
     });
 }
 
-void WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdate(CompletionHandler<void()>&& callback)
+void WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdate(CompletionHandler<void()>&& completionHandler)
 {
     // Helper function used by testing system. Should only be called from the main thread.
     ASSERT(RunLoop::isMain());
 
-    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), callback = WTFMove(callback)] () mutable {
-        updateCookiePartitioning(WTFMove(callback));
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)] () mutable {
+        updateCookiePartitioning([completionHandler = WTFMove(completionHandler)]() mutable {
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)]() {
+                completionHandler();
+            });
+        });
     });
 }
 
-void WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& callback)
+void WebResourceLoadStatisticsStore::scheduleCookiePartitioningUpdateForDomains(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
 {
     // Helper function used by testing system. Should only be called from the main thread.
     ASSERT(RunLoop::isMain());
-    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), domainsToPartition = crossThreadCopy(domainsToPartition), domainsToBlock = crossThreadCopy(domainsToBlock), domainsToNeitherPartitionNorBlock = crossThreadCopy(domainsToNeitherPartitionNorBlock), shouldClearFirst, callback = WTFMove(callback)] () mutable {
-        updateCookiePartitioningForDomains(domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, shouldClearFirst, WTFMove(callback));
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), domainsToPartition = crossThreadCopy(domainsToPartition), domainsToBlock = crossThreadCopy(domainsToBlock), domainsToNeitherPartitionNorBlock = crossThreadCopy(domainsToNeitherPartitionNorBlock), shouldClearFirst, completionHandler = WTFMove(completionHandler)] () mutable {
+        updateCookiePartitioningForDomains(domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, shouldClearFirst, [completionHandler = WTFMove(completionHandler)]() mutable {
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)]() {
+                completionHandler();
+            });
+        });
     });
 }
 
-void WebResourceLoadStatisticsStore::scheduleClearPartitioningStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&& callback)
+void WebResourceLoadStatisticsStore::scheduleClearPartitioningStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&& completionHandler)
 {
     // Helper function used by testing system. Should only be called from the main thread.
     ASSERT(RunLoop::isMain());
-    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), domains = crossThreadCopy(domains), callback = WTFMove(callback)] () mutable {
-        clearPartitioningStateForDomains(domains, WTFMove(callback));
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), domains = crossThreadCopy(domains), completionHandler = WTFMove(completionHandler)] () mutable {
+        clearPartitioningStateForDomains(domains, [completionHandler = WTFMove(completionHandler)]() mutable {
+            RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)]() {
+                completionHandler();
+            });
+        });
     });
 }
 
@@ -982,6 +1030,7 @@
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
 void WebResourceLoadStatisticsStore::scheduleCookiePartitioningStateReset()
 {
+    ASSERT(RunLoop::isMain());
     m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this)] {
         resetCookiePartitioningState();
     });
@@ -996,19 +1045,17 @@
     });
 }
 
-void WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent(ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& callback)
+void WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent(ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
-    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), shouldGrandfather, callback = WTFMove(callback)] () mutable {
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), shouldGrandfather, completionHandler = WTFMove(completionHandler)] () mutable {
         clearInMemory();
         m_persistentStorage.clear();
         
         if (shouldGrandfather == ShouldGrandfather::Yes)
-            grandfatherExistingWebsiteData([protectedThis = WTFMove(protectedThis), callback = WTFMove(callback)]() {
-                callback();
-            });
+            grandfatherExistingWebsiteData(WTFMove(completionHandler));
         else {
-            callback();
+            completionHandler();
         }
     });
 }
@@ -1190,7 +1237,7 @@
     return statistic.storageAccessUnderTopFrameOrigins.contains(firstPartyPrimaryDomain);
 }
 
-void WebResourceLoadStatisticsStore::updateCookiePartitioning(CompletionHandler<void()>&& callback)
+void WebResourceLoadStatisticsStore::updateCookiePartitioning(CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(!RunLoop::isMain());
 
@@ -1216,7 +1263,7 @@
     }
 
     if (domainsToPartition.isEmpty() && domainsToBlock.isEmpty() && domainsToNeitherPartitionNorBlock.isEmpty()) {
-        callback();
+        completionHandler();
         return;
     }
 
@@ -1254,9 +1301,11 @@
     }
 #endif
 
-    RunLoop::main().dispatch([this, protectedThis = makeRef(*this), domainsToPartition = crossThreadCopy(domainsToPartition), domainsToBlock = crossThreadCopy(domainsToBlock), domainsToNeitherPartitionNorBlock = crossThreadCopy(domainsToNeitherPartitionNorBlock), callback = WTFMove(callback)] () {
+    RunLoop::main().dispatch([this, protectedThis = makeRef(*this), domainsToPartition = crossThreadCopy(domainsToPartition), domainsToBlock = crossThreadCopy(domainsToBlock), domainsToNeitherPartitionNorBlock = crossThreadCopy(domainsToNeitherPartitionNorBlock), completionHandler = WTFMove(completionHandler)] () mutable {
         m_updatePrevalentDomainsToPartitionOrBlockCookiesHandler(domainsToPartition, domainsToBlock, domainsToNeitherPartitionNorBlock, ShouldClearFirst::No);
-        callback();
+        m_statisticsQueue->dispatch([completionHandler = WTFMove(completionHandler)] () {
+            completionHandler();
+        });
 #if !RELEASE_LOG_DISABLED
         RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Done updating cookie partitioning and blocking.");
 #endif
@@ -1263,11 +1312,11 @@
     });
 }
 
-void WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& callback)
+void WebResourceLoadStatisticsStore::updateCookiePartitioningForDomains(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst shouldClearFirst, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(!RunLoop::isMain());
     if (domainsToPartition.isEmpty() && domainsToBlock.isEmpty() && domainsToNeitherPartitionNorBlock.isEmpty() && shouldClearFirst == ShouldClearFirst::No) {
-        callback();
+        completionHandler();
         return;
     }
     
@@ -1291,14 +1340,14 @@
     for (auto& domain : domainsToBlock)
         ensureResourceStatisticsForPrimaryDomain(domain).isMarkedForCookieBlocking = true;
 
-    callback();
+    completionHandler();
 }
 
-void WebResourceLoadStatisticsStore::clearPartitioningStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&& callback)
+void WebResourceLoadStatisticsStore::clearPartitioningStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(!RunLoop::isMain());
     if (domains.isEmpty()) {
-        callback();
+        completionHandler();
         return;
     }
 
@@ -1312,7 +1361,7 @@
         statistic.isMarkedForCookieBlocking = false;
     }
 
-    callback();
+    completionHandler();
 }
 
 void WebResourceLoadStatisticsStore::resetCookiePartitioningState()

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (233082 => 233083)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2018-06-22 16:54:23 UTC (rev 233082)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2018-06-22 16:54:55 UTC (rev 233083)
@@ -105,17 +105,17 @@
     void logUserInteraction(const WebCore::URL&);
     void logNonRecentUserInteraction(const WebCore::URL&);
     void clearUserInteraction(const WebCore::URL&);
-    void hasHadUserInteraction(const WebCore::URL&, WTF::Function<void (bool)>&&);
+    void hasHadUserInteraction(const WebCore::URL&, CompletionHandler<void (bool)>&&);
     void setLastSeen(const WebCore::URL&, Seconds);
     void setPrevalentResource(const WebCore::URL&);
     void setVeryPrevalentResource(const WebCore::URL&);
-    void isPrevalentResource(const WebCore::URL&, WTF::Function<void (bool)>&&);
-    void isVeryPrevalentResource(const WebCore::URL&, WTF::Function<void(bool)>&&);
-    void isRegisteredAsSubFrameUnder(const WebCore::URL& subFrame, const WebCore::URL& topFrame, WTF::Function<void (bool)>&&);
-    void isRegisteredAsRedirectingTo(const WebCore::URL& hostRedirectedFrom, const WebCore::URL& hostRedirectedTo, WTF::Function<void (bool)>&&);
+    void isPrevalentResource(const WebCore::URL&, CompletionHandler<void (bool)>&&);
+    void isVeryPrevalentResource(const WebCore::URL&, CompletionHandler<void(bool)>&&);
+    void isRegisteredAsSubFrameUnder(const WebCore::URL& subFrame, const WebCore::URL& topFrame, CompletionHandler<void (bool)>&&);
+    void isRegisteredAsRedirectingTo(const WebCore::URL& hostRedirectedFrom, const WebCore::URL& hostRedirectedTo, CompletionHandler<void (bool)>&&);
     void clearPrevalentResource(const WebCore::URL&);
     void setGrandfathered(const WebCore::URL&, bool);
-    void isGrandfathered(const WebCore::URL&, WTF::Function<void (bool)>&&);
+    void isGrandfathered(const WebCore::URL&, CompletionHandler<void (bool)>&&);
     void setSubframeUnderTopFrameOrigin(const WebCore::URL& subframe, const WebCore::URL& topFrame);
     void setSubresourceUnderTopFrameOrigin(const WebCore::URL& subresource, const WebCore::URL& topFrame);
     void setSubresourceUniqueRedirectTo(const WebCore::URL& subresource, const WebCore::URL& hostNameRedirectedTo);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to