Title: [266214] trunk/Source
Revision
266214
Author
[email protected]
Date
2020-08-26 18:52:31 -0700 (Wed, 26 Aug 2020)

Log Message

Resource Load Statistics data summary does not report data which is held up in the web content process.
https://bugs.webkit.org/show_bug.cgi?id=215822
<rdar://problem/66682044>

Reviewed by Chris Dumez.

Source/WebCore:

Send empty lambda when calling updateCentralStatisticsStore() because
in these cases we don't care about timing.

* loader/ResourceLoadObserver.h:
(WebCore::ResourceLoadObserver::updateCentralStatisticsStore):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::close):
* testing/Internals.cpp:
(WebCore::Internals::notifyResourceLoadObserver):

Source/WebKit:

No new tests, this fixes a timing bug that is flaky to reproduce, so I
was unable to write a test case. Non-regressed behavior is confirmed
with existing API testing.

* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
Most of the time, the completion handler will be an empty function,
but we should handle it in the network process so we fix the
case where we wait to send the full data summary until the update has
finished.

(WebKit::WebResourceLoadStatisticsStore::aggregatedThirdPartyData):
Delete extra space.

* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::sendResourceLoadStatisticsDataImmediately):
* UIProcess/WebProcessPool.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::getResourceLoadStatisticsDataSummary):
Don't ask the network process for data until any lingering data
in the web content process has been sent first.

* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleResourceLoadStatisticsNotifyObserver):
* WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp:
(WebKit::WebResourceLoadObserver::WebResourceLoadObserver):
(WebKit::WebResourceLoadObserver::~WebResourceLoadObserver):
(WebKit::WebResourceLoadObserver::updateCentralStatisticsStore):
* WebProcess/WebCoreSupport/WebResourceLoadObserver.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::flushResourceLoadStatistics):
(WebKit::WebProcess::sendResourceLoadStatisticsDataImmediately):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (266213 => 266214)


--- trunk/Source/WebCore/ChangeLog	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebCore/ChangeLog	2020-08-27 01:52:31 UTC (rev 266214)
@@ -1,3 +1,21 @@
+2020-08-26  Kate Cheney  <[email protected]>
+
+        Resource Load Statistics data summary does not report data which is held up in the web content process.
+        https://bugs.webkit.org/show_bug.cgi?id=215822
+        <rdar://problem/66682044>
+
+        Reviewed by Chris Dumez.
+
+        Send empty lambda when calling updateCentralStatisticsStore() because
+        in these cases we don't care about timing.
+
+        * loader/ResourceLoadObserver.h:
+        (WebCore::ResourceLoadObserver::updateCentralStatisticsStore):
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::close):
+        * testing/Internals.cpp:
+        (WebCore::Internals::notifyResourceLoadObserver):
+
 2020-08-25  Ryosuke Niwa  <[email protected]>
 
         Make it possible to create a WeakPtr to Node and use it store assigned nodes in SlotAssignment

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (266213 => 266214)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.h	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h	2020-08-27 01:52:31 UTC (rev 266214)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "ResourceLoadStatistics.h"
+#include <wtf/CompletionHandler.h>
 #include <wtf/Forward.h>
 
 namespace WebCore {
@@ -58,7 +59,7 @@
     virtual void logSubresourceLoadingForTesting(const RegistrableDomain& /* firstPartyDomain */, const RegistrableDomain& /* thirdPartyDomain */, bool /* shouldScheduleNotification */) { }
 
     virtual String statisticsForURL(const URL&) { return { }; }
-    virtual void updateCentralStatisticsStore() { }
+    virtual void updateCentralStatisticsStore(CompletionHandler<void()>&& completionHandler) { completionHandler(); }
     virtual void clearState() { }
     
     virtual bool hasStatistics() const { return false; }

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (266213 => 266214)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2020-08-27 01:52:31 UTC (rev 266214)
@@ -1048,7 +1048,7 @@
     if (!frame->loader().shouldClose())
         return;
 
-    ResourceLoadObserver::shared().updateCentralStatisticsStore();
+    ResourceLoadObserver::shared().updateCentralStatisticsStore([] { });
 
     page->setIsClosing();
     page->chrome().closeWindowSoon();

Modified: trunk/Source/WebCore/testing/Internals.cpp (266213 => 266214)


--- trunk/Source/WebCore/testing/Internals.cpp	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebCore/testing/Internals.cpp	2020-08-27 01:52:31 UTC (rev 266214)
@@ -5635,7 +5635,7 @@
 
 void Internals::notifyResourceLoadObserver()
 {
-    ResourceLoadObserver::shared().updateCentralStatisticsStore();
+    ResourceLoadObserver::shared().updateCentralStatisticsStore([] { });
 }
 
 unsigned Internals::primaryScreenDisplayID()

Modified: trunk/Source/WebKit/ChangeLog (266213 => 266214)


--- trunk/Source/WebKit/ChangeLog	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/ChangeLog	2020-08-27 01:52:31 UTC (rev 266214)
@@ -1,3 +1,51 @@
+2020-08-26  Kate Cheney  <[email protected]>
+
+        Resource Load Statistics data summary does not report data which is held up in the web content process.
+        https://bugs.webkit.org/show_bug.cgi?id=215822
+        <rdar://problem/66682044>
+
+        Reviewed by Chris Dumez.
+
+        No new tests, this fixes a timing bug that is flaky to reproduce, so I
+        was unable to write a test case. Non-regressed behavior is confirmed
+        with existing API testing.
+
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated):
+        Most of the time, the completion handler will be an empty function,
+        but we should handle it in the network process so we fix the
+        case where we wait to send the full data summary until the update has
+        finished.
+
+        (WebKit::WebResourceLoadStatisticsStore::aggregatedThirdPartyData):
+        Delete extra space.
+
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated):
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::sendResourceLoadStatisticsDataImmediately):
+        * UIProcess/WebProcessPool.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::getResourceLoadStatisticsDataSummary):
+        Don't ask the network process for data until any lingering data
+        in the web content process has been sent first.
+
+        * WebProcess/InjectedBundle/API/c/WKBundle.cpp:
+        (WKBundleResourceLoadStatisticsNotifyObserver):
+        * WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp:
+        (WebKit::WebResourceLoadObserver::WebResourceLoadObserver):
+        (WebKit::WebResourceLoadObserver::~WebResourceLoadObserver):
+        (WebKit::WebResourceLoadObserver::updateCentralStatisticsStore):
+        * WebProcess/WebCoreSupport/WebResourceLoadObserver.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::flushResourceLoadStatistics):
+        (WebKit::WebProcess::sendResourceLoadStatisticsDataImmediately):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+
 2020-08-26  Andres Gonzalez  <[email protected]>
 
         Buttons with aria-haspopup attribute are not exposed to accessibility clients as form controls.

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (266213 => 266214)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2020-08-27 01:52:31 UTC (rev 266214)
@@ -353,7 +353,7 @@
     });
 }
 
-void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(Vector<ResourceLoadStatistics>&& statistics)
+void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(Vector<ResourceLoadStatistics>&& statistics, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
@@ -360,13 +360,15 @@
     // It is safe to move the origins to the background queue without isolated copy here because this is an r-value
     // coming from IPC. ResourceLoadStatistics only contains strings which are safe to move to other threads as long
     // as nobody on this thread holds a reference to those strings.
-    postTask([this, protectedThis = makeRef(*this), statistics = WTFMove(statistics)]() mutable {
-        if (!m_statisticsStore)
+    postTask([this, protectedThis = makeRef(*this), statistics = WTFMove(statistics), completionHandler = WTFMove(completionHandler)]() mutable {
+        if (!m_statisticsStore) {
+            postTaskReply(WTFMove(completionHandler));
             return;
+        }
 
         ASSERT(suspendedState != State::Suspended);
         m_statisticsStore->mergeStatistics(WTFMove(statistics));
-
+        postTaskReply(WTFMove(completionHandler));
         // We can cancel any pending request to process statistics since we're doing it synchronously below.
         m_statisticsStore->cancelPendingStatisticsProcessingRequest();
 
@@ -1444,7 +1446,7 @@
 {
     ASSERT(RunLoop::isMain());
 
-    postTask([this, completionHandler = WTFMove(completionHandler)]() mutable  {
+    postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
         if (!m_statisticsStore) {
             postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable {
                 completionHandler({ });

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (266213 => 266214)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2020-08-27 01:52:31 UTC (rev 266214)
@@ -292,7 +292,7 @@
     void sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample) const;
     void notifyPageStatisticsTelemetryFinished(unsigned numberOfPrevalentResources, unsigned numberOfPrevalentResourcesWithUserInteraction, unsigned numberOfPrevalentResourcesWithoutUserInteraction, unsigned topPrevalentResourceWithUserInteractionDaysSinceUserInteraction, unsigned medianDaysSinceUserInteractionPrevalentResourceWithUserInteraction, unsigned top3NumberOfPrevalentResourcesWithUI, unsigned top3MedianSubFrameWithoutUI, unsigned top3MedianSubResourceWithoutUI, unsigned top3MedianUniqueRedirectsWithoutUI, unsigned top3MedianDataRecordsRemovedWithoutUI) const;
 
-    void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&&);
+    void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&&, CompletionHandler<void()>&&);
     void requestStorageAccessUnderOpener(DomainInNeedOfStorageAccess&&, WebCore::PageIdentifier openerID, OpenerDomain&&);
     void aggregatedThirdPartyData(CompletionHandler<void(Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&&)>&&);
     static void suspend(CompletionHandler<void()>&&);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (266213 => 266214)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2020-08-27 01:52:31 UTC (rev 266214)
@@ -870,14 +870,19 @@
     }
 }
 
-void NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated(Vector<ResourceLoadStatistics>&& statistics)
+void NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated(Vector<ResourceLoadStatistics>&& statistics, CompletionHandler<void()>&& completionHandler)
 {
     if (auto* networkSession = this->networkSession()) {
-        if (networkSession->sessionID().isEphemeral())
+        if (networkSession->sessionID().isEphemeral()) {
+            completionHandler();
             return;
-        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
-            resourceLoadStatistics->resourceLoadStatisticsUpdated(WTFMove(statistics));
+        }
+        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) {
+            resourceLoadStatistics->resourceLoadStatisticsUpdated(WTFMove(statistics), WTFMove(completionHandler));
+            return;
+        }
     }
+    completionHandler();
 }
 
 void NetworkConnectionToWebProcess::hasStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, FrameIdentifier frameID, PageIdentifier pageID, CompletionHandler<void(bool)>&& completionHandler)

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (266213 => 266214)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2020-08-27 01:52:31 UTC (rev 266214)
@@ -266,7 +266,7 @@
     void clearPageSpecificDataForResourceLoadStatistics(WebCore::PageIdentifier);
 
     void logUserInteraction(const RegistrableDomain&);
-    void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&&);
+    void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&&, CompletionHandler<void()>&&);
     void hasStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, WebCore::FrameIdentifier, WebCore::PageIdentifier, CompletionHandler<void(bool)>&&);
     void requestStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, WebCore::FrameIdentifier, WebCore::PageIdentifier, WebPageProxyIdentifier, WebCore::StorageAccessScope, CompletionHandler<void(WebCore::RequestStorageAccessResult)>&&);
     void requestStorageAccessUnderOpener(WebCore::RegistrableDomain&& domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::RegistrableDomain&& openerDomain);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (266213 => 266214)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in	2020-08-27 01:52:31 UTC (rev 266214)
@@ -65,7 +65,7 @@
     RemoveStorageAccessForFrame(WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID);
     ClearPageSpecificDataForResourceLoadStatistics(WebCore::PageIdentifier pageID);
     LogUserInteraction(WebCore::RegistrableDomain domain)
-    ResourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics> statistics)
+    ResourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics> statistics) -> () Async
     HasStorageAccess(WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID) -> (bool hasStorageAccess) Async
     RequestStorageAccess(WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier webPageID, WebKit::WebPageProxyIdentifier webPageProxyID, enum:bool WebCore::StorageAccessScope scope) -> (struct WebCore::RequestStorageAccessResult result) Async
     RequestStorageAccessUnderOpener(WebCore::RegistrableDomain domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::RegistrableDomain openerDomain)

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (266213 => 266214)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2020-08-27 01:52:31 UTC (rev 266214)
@@ -2408,6 +2408,14 @@
     for (auto& process : processes())
         process->sendWithAsyncReply(Messages::WebProcess::SeedResourceLoadStatisticsForTesting(firstPartyDomain, thirdPartyDomain, shouldScheduleNotification), [callbackAggregator] { });
 }
+
+void WebProcessPool::sendResourceLoadStatisticsDataImmediately(CompletionHandler<void()>&& completionHandler)
+{
+    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
+
+    for (auto& process : processes())
+        process->sendWithAsyncReply(Messages::WebProcess::SendResourceLoadStatisticsDataImmediately(), [callbackAggregator] { });
+}
 #endif
 
 WebProcessWithAudibleMediaToken WebProcessPool::webProcessWithAudibleMediaToken() const

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (266213 => 266214)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2020-08-27 01:52:31 UTC (rev 266214)
@@ -514,6 +514,7 @@
     void didCommitCrossSiteLoadWithDataTransfer(PAL::SessionID, const WebCore::RegistrableDomain& fromDomain, const WebCore::RegistrableDomain& toDomain, OptionSet<WebCore::CrossSiteNavigationDataTransfer::Flag>, WebPageProxyIdentifier, WebCore::PageIdentifier);
     void setDomainsWithUserInteraction(HashSet<WebCore::RegistrableDomain>&&);
     void seedResourceLoadStatisticsForTesting(const WebCore::RegistrableDomain& firstPartyDomain, const WebCore::RegistrableDomain& thirdPartyDomain, bool shouldScheduleNotification, CompletionHandler<void()>&&);
+    void sendResourceLoadStatisticsDataImmediately(CompletionHandler<void()>&&);
 #endif
 
 #if PLATFORM(GTK) || PLATFORM(WPE)

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (266213 => 266214)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2020-08-27 01:52:31 UTC (rev 266214)
@@ -1562,8 +1562,10 @@
     RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(WTFMove(completionHandler)));
 
     for (auto& processPool : ensureProcessPools()) {
-        processPool->ensureNetworkProcess(this).getResourceLoadStatisticsDataSummary(m_sessionID, [callbackAggregator, processPool](Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&& data) {
-            callbackAggregator->addResult(WTFMove(data));
+        processPool->sendResourceLoadStatisticsDataImmediately([this, protectedThis = makeRef(*this), processPool, callbackAggregator] {
+            processPool->ensureNetworkProcess(this).getResourceLoadStatisticsDataSummary(m_sessionID, [callbackAggregator, processPool](Vector<WebResourceLoadStatisticsStore::ThirdPartyData>&& data) {
+                callbackAggregator->addResult(WTFMove(data));
+            });
         });
     }
 }

Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp (266213 => 266214)


--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundle.cpp	2020-08-27 01:52:31 UTC (rev 266214)
@@ -304,7 +304,7 @@
     if (!WebCore::ResourceLoadObserver::shared().hasStatistics())
         return false;
 
-    WebCore::ResourceLoadObserver::shared().updateCentralStatisticsStore();
+    WebCore::ResourceLoadObserver::shared().updateCentralStatisticsStore([] { });
     return true;
 }
 

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp (266213 => 266214)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp	2020-08-27 01:52:31 UTC (rev 266214)
@@ -63,7 +63,7 @@
 
 WebResourceLoadObserver::WebResourceLoadObserver(ResourceLoadStatistics::IsEphemeral isEphemeral)
     : m_isEphemeral(isEphemeral)
-    , m_notificationTimer(*this, &WebResourceLoadObserver::updateCentralStatisticsStore)
+    , m_notificationTimer([this] { updateCentralStatisticsStore([] { }); })
 {
 }
 
@@ -70,7 +70,7 @@
 WebResourceLoadObserver::~WebResourceLoadObserver()
 {
     if (hasStatistics())
-        updateCentralStatisticsStore();
+        updateCentralStatisticsStore([] { });
 }
 
 void WebResourceLoadObserver::requestStorageAccessUnderOpener(const RegistrableDomain& domainInNeedOfStorageAccess, WebPage& openerPage, Document& openerDocument)
@@ -109,12 +109,13 @@
         m_notificationTimer.startOneShot(minimumNotificationInterval);
 }
 
-void WebResourceLoadObserver::updateCentralStatisticsStore()
+void WebResourceLoadObserver::updateCentralStatisticsStore(CompletionHandler<void()>&& completionHandler)
 {
     m_notificationTimer.stop();
-    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::ResourceLoadStatisticsUpdated(takeStatistics()), 0);
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::ResourceLoadStatisticsUpdated(takeStatistics()), WTFMove(completionHandler));
 }
 
+
 String WebResourceLoadObserver::statisticsForURL(const URL& url)
 {
     auto iter = m_resourceStatisticsMap.find(RegistrableDomain { url });

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.h (266213 => 266214)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.h	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.h	2020-08-27 01:52:31 UTC (rev 266214)
@@ -57,7 +57,7 @@
 #endif
 
     String statisticsForURL(const URL&) final;
-    void updateCentralStatisticsStore() final;
+    void updateCentralStatisticsStore(CompletionHandler<void()>&&) final;
     void clearState() final;
     
     bool hasStatistics() const final { return !m_resourceStatisticsMap.isEmpty(); }

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (266213 => 266214)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-08-27 01:52:31 UTC (rev 266214)
@@ -1595,7 +1595,7 @@
 {
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     if (auto* observer = ResourceLoadObserver::sharedIfExists())
-        observer->updateCentralStatisticsStore();
+        observer->updateCentralStatisticsStore([] { });
 #endif
 }
 
@@ -1907,6 +1907,11 @@
 {
     ResourceLoadObserver::shared().setDomainsWithUserInteraction(WTFMove(domains));
 }
+
+void WebProcess::sendResourceLoadStatisticsDataImmediately(CompletionHandler<void()>&& completionHandler)
+{
+    ResourceLoadObserver::shared().updateCentralStatisticsStore(WTFMove(completionHandler));
+}
 #endif
 
 #if ENABLE(GPU_PROCESS)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (266213 => 266214)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2020-08-27 01:52:31 UTC (rev 266214)
@@ -475,6 +475,7 @@
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     void setThirdPartyCookieBlockingMode(WebCore::ThirdPartyCookieBlockingMode, CompletionHandler<void()>&&);
     void setDomainsWithUserInteraction(HashSet<WebCore::RegistrableDomain>&&);
+    void sendResourceLoadStatisticsDataImmediately(CompletionHandler<void()>&&);
 #endif
 
     void platformInitializeProcess(const AuxiliaryProcessInitializationParameters&);

Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (266213 => 266214)


--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2020-08-27 01:47:20 UTC (rev 266213)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in	2020-08-27 01:52:31 UTC (rev 266214)
@@ -159,6 +159,7 @@
     SeedResourceLoadStatisticsForTesting(WebCore::RegistrableDomain firstPartyDomain, WebCore::RegistrableDomain thirdPartyDomain, bool shouldScheduleNotification) -> () Async
     SetThirdPartyCookieBlockingMode(enum:uint8_t WebCore::ThirdPartyCookieBlockingMode blockingMode) -> () Async
     SetDomainsWithUserInteraction(HashSet<WebCore::RegistrableDomain> domains)
+    SendResourceLoadStatisticsDataImmediately() -> () Async
 #endif
 
 #if PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to