Make WebResourceLoadStatisticsStore::processStatisticsAndDataRecords() call WebProces...
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Feb 2018 19:27:26 +0000 (19:27 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Feb 2018 19:27:26 +0000 (19:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182719
<rdar://problem/37517370>

Reviewed by Brent Fulgham.

Source/WebKit:

This will allow the page notification, statistics pruning, and persistence write
to be done at the right time and hopefully stabilize the layout tests including:
http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html

* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
    Now takes a callback parameter.
(WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
* UIProcess/WebResourceLoadStatisticsStore.h:
    Now calls WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed()
    in a callback provided to WebResourceLoadStatisticsStore::removeDataRecords().

LayoutTests:

* platform/mac-wk2/TestExpectations:
    Marked http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html
    as [ Pass ].
* platform/wk2/TestExpectations:
    Marked http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html
    as [ Pass ]. This should have been done already in r227223:
    https://bugs.webkit.org/show_bug.cgi?id=181822

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

LayoutTests/ChangeLog
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/wk2/TestExpectations
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h

index 27da619..e5ce585 100644 (file)
@@ -1,3 +1,19 @@
+2018-02-20  John Wilander  <wilander@apple.com>
+
+        Make WebResourceLoadStatisticsStore::processStatisticsAndDataRecords() call WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed() in a proper callback
+        https://bugs.webkit.org/show_bug.cgi?id=182719
+        <rdar://problem/37517370>
+
+        Reviewed by Brent Fulgham.
+
+        * platform/mac-wk2/TestExpectations:
+            Marked http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html
+            as [ Pass ].
+        * platform/wk2/TestExpectations:
+            Marked http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html
+            as [ Pass ]. This should have been done already in r227223:
+            https://bugs.webkit.org/show_bug.cgi?id=181822
+
 2018-02-20  Nan Wang  <n_wang@apple.com>
 
         AX: AOM: Dispatch accessibleclick event
index f0739b8..efba94b 100644 (file)
@@ -803,7 +803,7 @@ webkit.org/b/176122 media/video-controls-drop-and-restore-timeline.html [ Pass F
 [ HighSierra+ ] http/tests/resourceLoadStatistics/partitioned-cookies-with-and-without-user-interaction.html [ Pass ]
 [ HighSierra+ ] http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-with-partitioning-timeout.html [ Pass ]
 [ HighSierra+ ] http/tests/resourceLoadStatistics/third-party-cookie-with-and-without-user-interaction.html [ Pass ]
-[ HighSierra+ ] http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html [ Pass Failure ]
+[ HighSierra+ ] http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html [ Pass ]
 [ HighSierra+ ] http/tests/resourceLoadStatistics/non-prevalent-resources-can-access-cookies-in-a-third-party-context.html [ Pass ]
 [ HighSierra+ ] http/tests/resourceLoadStatistics/add-partitioning-to-redirect.html [ Pass ]
 [ HighSierra+ ] http/tests/resourceLoadStatistics/add-blocking-to-redirect.html [ Pass ]
index 022d5c3..7b3a10b 100644 (file)
@@ -692,7 +692,7 @@ http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-uni
 http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html [ Pass ]
 http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html [ Pass ]
 http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html [ Pass ]
-webkit.org/b/181223 http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html [ Skip ]
+http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html [ Pass ]
 http/tests/resourceLoadStatistics/grandfathering.html [ Pass ]
 webkit.org/b/180703 http/tests/resourceLoadStatistics/telemetry-generation.html [ Pass Failure ]
 http/tests/resourceLoadStatistics/prune-statistics.html [ Pass ]
index 01b2fe1..baac9d8 100644 (file)
@@ -1,3 +1,23 @@
+2018-02-20  John Wilander  <wilander@apple.com>
+
+        Make WebResourceLoadStatisticsStore::processStatisticsAndDataRecords() call WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed() in a proper callback
+        https://bugs.webkit.org/show_bug.cgi?id=182719
+        <rdar://problem/37517370>
+
+        Reviewed by Brent Fulgham.
+
+        This will allow the page notification, statistics pruning, and persistence write
+        to be done at the right time and hopefully stabilize the layout tests including:
+        http/tests/resourceLoadStatistics/partitioned-and-unpartitioned-cookie-deletion.html
+
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
+            Now takes a callback parameter.
+        (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+            Now calls WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed()
+            in a callback provided to WebResourceLoadStatisticsStore::removeDataRecords().
+
 2018-02-20  Zan Dobersek  <zdobersek@igalia.com>
 
         [Cairo] Drop target GraphicsContext usage in Cairo operations
index 349eee9..49d8f24 100644 (file)
@@ -185,12 +185,14 @@ WebResourceLoadStatisticsStore::~WebResourceLoadStatisticsStore()
     m_persistentStorage.finishAllPendingWorkSynchronously();
 }
     
-void WebResourceLoadStatisticsStore::removeDataRecords()
+void WebResourceLoadStatisticsStore::removeDataRecords(CompletionHandler<void()>&& callback)
 {
     ASSERT(!RunLoop::isMain());
     
-    if (!shouldRemoveDataRecords())
+    if (!shouldRemoveDataRecords()) {
+        callback();
         return;
+    }
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
     m_activePluginTokens.clear();
@@ -199,19 +201,22 @@ void WebResourceLoadStatisticsStore::removeDataRecords()
 #endif
 
     auto prevalentResourceDomains = topPrivatelyControlledDomainsToRemoveWebsiteDataFor();
-    if (prevalentResourceDomains.isEmpty())
+    if (prevalentResourceDomains.isEmpty()) {
+        callback();
         return;
-    
+    }
+
     setDataRecordsBeingRemoved(true);
 
-    RunLoop::main().dispatch([prevalentResourceDomains = crossThreadCopy(prevalentResourceDomains), this, protectedThis = makeRef(*this)] () mutable {
-        WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, [this, protectedThis = WTFMove(protectedThis)](const HashSet<String>& domainsWithDeletedWebsiteData) mutable {
-            m_statisticsQueue->dispatch([this, protectedThis = WTFMove(protectedThis), topDomains = crossThreadCopy(domainsWithDeletedWebsiteData)] () mutable {
+    RunLoop::main().dispatch([prevalentResourceDomains = crossThreadCopy(prevalentResourceDomains), callback = WTFMove(callback), this, protectedThis = makeRef(*this)] () mutable {
+        WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, [callback = WTFMove(callback), this, protectedThis = WTFMove(protectedThis)](const HashSet<String>& domainsWithDeletedWebsiteData) mutable {
+            m_statisticsQueue->dispatch([topDomains = crossThreadCopy(domainsWithDeletedWebsiteData), callback = WTFMove(callback), this, protectedThis = WTFMove(protectedThis)] () mutable {
                 for (auto& prevalentResourceDomain : topDomains) {
                     auto& statistic = ensureResourceStatisticsForPrimaryDomain(prevalentResourceDomain);
                     ++statistic.dataRecordsRemoved;
                 }
                 setDataRecordsBeingRemoved(false);
+                callback();
             });
         });
     });
@@ -264,17 +269,26 @@ void WebResourceLoadStatisticsStore::processStatisticsAndDataRecords()
                 setPrevalentResource(resourceStatistic);
         }
     }
-    removeDataRecords();
+    
+    if (m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned) {
+        removeDataRecords([this, protectedThis = makeRef(*this)] {
+            ASSERT(!RunLoop::isMain());
 
-    pruneStatisticsIfNeeded();
+            pruneStatisticsIfNeeded();
+            m_persistentStorage.scheduleOrWriteMemoryStore(ResourceLoadStatisticsPersistentStorage::ForceImmediateWrite::No);
 
-    if (m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned) {
-        RunLoop::main().dispatch([] {
-            WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
+            RunLoop::main().dispatch([] {
+                WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
+            });
         });
-    }
+    } else {
+        removeDataRecords([this, protectedThis = makeRef(*this)] {
+            ASSERT(!RunLoop::isMain());
 
-    m_persistentStorage.scheduleOrWriteMemoryStore(ResourceLoadStatisticsPersistentStorage::ForceImmediateWrite::No);
+            pruneStatisticsIfNeeded();
+            m_persistentStorage.scheduleOrWriteMemoryStore(ResourceLoadStatisticsPersistentStorage::ForceImmediateWrite::No);
+        });
+    }
 }
 
 void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&& origins)
index d8c140e..eeb6cac 100644 (file)
@@ -150,7 +150,7 @@ public:
 private:
     WebResourceLoadStatisticsStore(const String&, Function<void(const String&)>&& testingCallback, bool isEphemeral, UpdatePrevalentDomainsToPartitionOrBlockCookiesHandler&&, HasStorageAccessForFrameHandler&&, GrantStorageAccessForFrameHandler&&, RemovePrevalentDomainsHandler&&);
 
-    void removeDataRecords();
+    void removeDataRecords(CompletionHandler<void()>&&);
 
     // IPC::MessageReceiver
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;