Title: [249056] trunk/Source
Revision
249056
Author
[email protected]
Date
2019-08-23 11:14:43 -0700 (Fri, 23 Aug 2019)

Log Message

Support ITP on a per-session basis (198923)
https://bugs.webkit.org/show_bug.cgi?id=198923

Patch by Kate Cheney <[email protected]> on 2019-08-23
Reviewed by Chris Dumez.

Source/WebCore:

This patch updated the data structure used to collect resource load
statistics in order to support ITP data collection on a per session
basis. Each sessionID is stored as a key-value pair with its own map
of ResourceLoadStatistics.

It also updated the statisticsForURL function call to perform lookups
of URL data based on sessionID.

* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::setStatisticsUpdatedCallback):
(WebCore::ResourceLoadObserver::shouldLog const):
(WebCore::ResourceLoadObserver::logSubresourceLoading):
(WebCore::ResourceLoadObserver::logWebSocketLoading):
(WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
(WebCore::ResourceLoadObserver::logFontLoad):
(WebCore::ResourceLoadObserver::logCanvasRead):
(WebCore::ResourceLoadObserver::logCanvasWriteOrMeasure):
(WebCore::ResourceLoadObserver::logNavigatorAPIAccessed):
(WebCore::ResourceLoadObserver::logScreenAPIAccessed):
(WebCore::ResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain):
(WebCore::ResourceLoadObserver::statisticsForURL):
(WebCore::ResourceLoadObserver::takeStatistics):
(WebCore::ResourceLoadObserver::clearState):
* loader/ResourceLoadObserver.h:
* testing/Internals.cpp:
(WebCore::Internals::resourceLoadStatisticsForURL):

Source/WebKit:

The original implementation of resourceLoadStatisticsUpdated
did not allow for ITP on a per session basis due to the sessionID
not being passed to the resourceLoadStatisticsUpdated function.
This patch allows access of the correct networkSession by passing
all resourceLoadStatistics in a new data structure of key-value
pairs, where the sessionID is the key.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* WebProcess/WebProcess.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (249055 => 249056)


--- trunk/Source/WebCore/ChangeLog	2019-08-23 17:53:19 UTC (rev 249055)
+++ trunk/Source/WebCore/ChangeLog	2019-08-23 18:14:43 UTC (rev 249056)
@@ -1,3 +1,37 @@
+2019-08-23  Kate Cheney  <[email protected]>
+
+        Support ITP on a per-session basis (198923)
+        https://bugs.webkit.org/show_bug.cgi?id=198923
+
+        Reviewed by Chris Dumez.
+
+        This patch updated the data structure used to collect resource load
+        statistics in order to support ITP data collection on a per session
+        basis. Each sessionID is stored as a key-value pair with its own map
+        of ResourceLoadStatistics.
+
+        It also updated the statisticsForURL function call to perform lookups
+        of URL data based on sessionID.
+
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::ResourceLoadObserver::setStatisticsUpdatedCallback):
+        (WebCore::ResourceLoadObserver::shouldLog const):
+        (WebCore::ResourceLoadObserver::logSubresourceLoading):
+        (WebCore::ResourceLoadObserver::logWebSocketLoading):
+        (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+        (WebCore::ResourceLoadObserver::logFontLoad):
+        (WebCore::ResourceLoadObserver::logCanvasRead):
+        (WebCore::ResourceLoadObserver::logCanvasWriteOrMeasure):
+        (WebCore::ResourceLoadObserver::logNavigatorAPIAccessed):
+        (WebCore::ResourceLoadObserver::logScreenAPIAccessed):
+        (WebCore::ResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain):
+        (WebCore::ResourceLoadObserver::statisticsForURL):
+        (WebCore::ResourceLoadObserver::takeStatistics):
+        (WebCore::ResourceLoadObserver::clearState):
+        * loader/ResourceLoadObserver.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::resourceLoadStatisticsForURL):
+
 2019-08-23  Simon Fraser  <[email protected]>
 
         Remove unnecessary call to enclosingClippingScopes()

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (249055 => 249056)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2019-08-23 17:53:19 UTC (rev 249055)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2019-08-23 18:14:43 UTC (rev 249056)
@@ -54,13 +54,13 @@
     return resourceLoadObserver;
 }
 
-void ResourceLoadObserver::setStatisticsUpdatedCallback(WTF::Function<void(Vector<ResourceLoadStatistics>&&)>&& notificationCallback)
+void ResourceLoadObserver::setStatisticsUpdatedCallback(Function<void(PerSessionResourceLoadData&&)>&& notificationCallback)
 {
     ASSERT(!m_notificationCallback);
     m_notificationCallback = WTFMove(notificationCallback);
 }
 
-void ResourceLoadObserver::setRequestStorageAccessUnderOpenerCallback(WTF::Function<void(PAL::SessionID sessionID, const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, const RegistrableDomain& openerDomain)>&& callback)
+void ResourceLoadObserver::setRequestStorageAccessUnderOpenerCallback(Function<void(PAL::SessionID sessionID, const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, const RegistrableDomain& openerDomain)>&& callback)
 {
     ASSERT(!m_requestStorageAccessUnderOpenerCallback);
     m_requestStorageAccessUnderOpenerCallback = WTFMove(callback);
@@ -95,9 +95,9 @@
     return response.httpStatusCode() >= 300 && response.httpStatusCode() <= 399;
 }
 
-bool ResourceLoadObserver::shouldLog(bool usesEphemeralSession) const
+bool ResourceLoadObserver::shouldLog(PAL::SessionID sessionID) const
 {
-    return DeprecatedGlobalSettings::resourceLoadStatisticsEnabled() && !usesEphemeralSession && m_notificationCallback;
+    return DeprecatedGlobalSettings::resourceLoadStatisticsEnabled() && !sessionID.isEphemeral() && m_notificationCallback;
 }
 
 void ResourceLoadObserver::logSubresourceLoading(const Frame* frame, const ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
@@ -108,7 +108,7 @@
         return;
 
     auto* page = frame->page();
-    if (!page || !shouldLog(page->usesEphemeralSession()))
+    if (!page || !shouldLog(page->sessionID()))
         return;
 
     bool isRedirect = is3xxRedirect(redirectResponse);
@@ -130,7 +130,7 @@
         return;
 
     {
-        auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain);
+        auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), targetDomain);
         auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
         targetStatistics.lastSeen = lastSeen;
         targetStatistics.subresourceUnderTopFrameDomains.add(topFrameDomain);
@@ -139,9 +139,9 @@
     }
 
     if (isRedirect) {
-        auto& redirectingOriginStatistics = ensureResourceStatisticsForRegistrableDomain(redirectedFromDomain);
+        auto& redirectingOriginStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), redirectedFromDomain);
         redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetDomain);
-        auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain);
+        auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), targetDomain);
         targetStatistics.subresourceUniqueRedirectsFrom.add(redirectedFromDomain);
 
         m_logSubresourceRedirectNotificationCallback(page->sessionID(), redirectedFromDomain, targetDomain);
@@ -150,7 +150,7 @@
 
 void ResourceLoadObserver::logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL, PAL::SessionID sessionID)
 {
-    if (!shouldLog(sessionID.isEphemeral()))
+    if (!shouldLog(sessionID))
         return;
 
     auto targetHost = targetURL.host();
@@ -167,7 +167,7 @@
 
     auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
 
-    auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain);
+    auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(sessionID, targetDomain);
     targetStatistics.lastSeen = lastSeen;
     targetStatistics.subresourceUnderTopFrameDomains.add(topFrameDomain);
 
@@ -176,7 +176,7 @@
 
 void ResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Document& document)
 {
-    if (!document.sessionID().isValid() || !shouldLog(document.sessionID().isEphemeral()))
+    if (!document.sessionID().isValid() || !shouldLog(document.sessionID()))
         return;
 
     auto& url = ""
@@ -191,7 +191,7 @@
 
     m_lastReportedUserInteractionMap.set(topFrameDomain, newTime);
 
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(topFrameDomain);
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID(), topFrameDomain);
     statistics.hadUserInteraction = true;
     statistics.lastSeen = newTime;
     statistics.mostRecentUserInteractionTime = newTime;
@@ -251,10 +251,10 @@
 void ResourceLoadObserver::logFontLoad(const Document& document, const String& familyName, bool loadStatus)
 {
 #if ENABLE(WEB_API_STATISTICS)
-    if (!shouldLog(document.sessionID().isEphemeral()))
+    if (!shouldLog(document.sessionID()))
         return;
     RegistrableDomain registrableDomain { document.url() };
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain);
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
     bool shouldCallNotificationCallback = false;
     if (!loadStatus) {
         if (statistics.fontsFailedToLoad.add(familyName).isNewEntry)
@@ -278,10 +278,10 @@
 void ResourceLoadObserver::logCanvasRead(const Document& document)
 {
 #if ENABLE(WEB_API_STATISTICS)
-    if (!shouldLog(document.sessionID().isEphemeral()))
+    if (!shouldLog(document.sessionID()))
         return;
     RegistrableDomain registrableDomain { document.url() };
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain);
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID(), registrableDomain);
     RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
     statistics.canvasActivityRecord.wasDataRead = true;
     if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
@@ -294,10 +294,10 @@
 void ResourceLoadObserver::logCanvasWriteOrMeasure(const Document& document, const String& textWritten)
 {
 #if ENABLE(WEB_API_STATISTICS)
-    if (!shouldLog(document.sessionID().isEphemeral()))
+    if (!shouldLog(document.sessionID()))
         return;
     RegistrableDomain registrableDomain { document.url() };
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain);
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
     bool shouldCallNotificationCallback = false;
     RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
     if (statistics.canvasActivityRecord.recordWrittenOrMeasuredText(textWritten))
@@ -315,10 +315,10 @@
 void ResourceLoadObserver::logNavigatorAPIAccessed(const Document& document, const ResourceLoadStatistics::NavigatorAPI functionName)
 {
 #if ENABLE(WEB_API_STATISTICS)
-    if (!shouldLog(document.sessionID().isEphemeral()))
+    if (!shouldLog(document.sessionID()))
         return;
     RegistrableDomain registrableDomain { document.url() };
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain);
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
     bool shouldCallNotificationCallback = false;
     if (!statistics.navigatorFunctionsAccessed.contains(functionName)) {
         statistics.navigatorFunctionsAccessed.add(functionName);
@@ -338,10 +338,10 @@
 void ResourceLoadObserver::logScreenAPIAccessed(const Document& document, const ResourceLoadStatistics::ScreenAPI functionName)
 {
 #if ENABLE(WEB_API_STATISTICS)
-    if (!shouldLog(document.sessionID().isEphemeral()))
+    if (!shouldLog(document.sessionID()))
         return;
     RegistrableDomain registrableDomain { document.url() };
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain);
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
     bool shouldCallNotificationCallback = false;
     if (!statistics.screenFunctionsAccessed.contains(functionName)) {
         statistics.screenFunctionsAccessed.add(functionName);
@@ -358,12 +358,16 @@
 #endif
 }
     
-ResourceLoadStatistics& ResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain(const RegistrableDomain& domain)
+ResourceLoadStatistics& ResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain(PAL::SessionID sessionID, const RegistrableDomain& domain)
 {
-    auto addResult = m_resourceStatisticsMap.ensure(domain, [&domain] {
+    auto addResult = m_perSessionResourceStatisticsMap.ensure(sessionID, [] {
+        return makeUnique<HashMap<RegistrableDomain, ResourceLoadStatistics>>();
+    });
+
+    auto addDomainResult = addResult.iterator->value->ensure(domain, [&domain] {
         return ResourceLoadStatistics(domain);
     });
-    return addResult.iterator->value;
+    return addDomainResult.iterator->value;
 }
 
 void ResourceLoadObserver::updateCentralStatisticsStore()
@@ -371,30 +375,40 @@
     m_notificationCallback(takeStatistics());
 }
 
-String ResourceLoadObserver::statisticsForURL(const URL& url)
+String ResourceLoadObserver::statisticsForURL(PAL::SessionID sessionID, const URL& url)
 {
-    auto iter = m_resourceStatisticsMap.find(RegistrableDomain { url });
-    if (iter == m_resourceStatisticsMap.end())
+    auto* resourceStatisticsByDomain = m_perSessionResourceStatisticsMap.get(sessionID);
+    if (!resourceStatisticsByDomain)
         return emptyString();
 
+    auto iter = resourceStatisticsByDomain->find(RegistrableDomain { url });
+    if (iter == resourceStatisticsByDomain->end())
+        return emptyString();
+
     return makeString("Statistics for ", url.host().toString(), ":\n", iter->value.toString());
 }
 
-Vector<ResourceLoadStatistics> ResourceLoadObserver::takeStatistics()
+auto ResourceLoadObserver::takeStatistics() -> PerSessionResourceLoadData
 {
-    Vector<ResourceLoadStatistics> statistics;
-    statistics.reserveInitialCapacity(m_resourceStatisticsMap.size());
-    for (auto& statistic : m_resourceStatisticsMap.values())
-        statistics.uncheckedAppend(WTFMove(statistic));
+    PerSessionResourceLoadData perSessionStatistics;
 
-    m_resourceStatisticsMap.clear();
+    for (auto& iter : m_perSessionResourceStatisticsMap) {
+        Vector<ResourceLoadStatistics> statistics;
+        statistics.reserveInitialCapacity(iter.value->size());
 
-    return statistics;
+        for (auto& statistic : iter.value->values())
+            statistics.uncheckedAppend(WTFMove(statistic));
+
+        perSessionStatistics.append(std::make_pair(iter.key, WTFMove(statistics)));
+    }
+    
+    m_perSessionResourceStatisticsMap.clear();
+    return perSessionStatistics;
 }
 
 void ResourceLoadObserver::clearState()
 {
-    m_resourceStatisticsMap.clear();
+    m_perSessionResourceStatisticsMap.clear();
     m_lastReportedUserInteractionMap.clear();
 }
 

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (249055 => 249056)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.h	2019-08-23 17:53:19 UTC (rev 249055)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h	2019-08-23 18:14:43 UTC (rev 249056)
@@ -59,6 +59,7 @@
 class ResourceLoadObserver {
     friend class WTF::NeverDestroyed<ResourceLoadObserver>;
 public:
+    using PerSessionResourceLoadData = Vector<std::pair<PAL::SessionID, Vector<ResourceLoadStatistics>>>;
     WEBCORE_EXPORT static ResourceLoadObserver& shared();
 
     void logSubresourceLoading(const Frame*, const ResourceRequest& newRequest, const ResourceResponse& redirectResponse);
@@ -71,9 +72,9 @@
     void logNavigatorAPIAccessed(const Document&, const ResourceLoadStatistics::NavigatorAPI);
     void logScreenAPIAccessed(const Document&, const ResourceLoadStatistics::ScreenAPI);
 
-    WEBCORE_EXPORT String statisticsForURL(const URL&);
+    WEBCORE_EXPORT String statisticsForURL(PAL::SessionID, const URL&);
 
-    WEBCORE_EXPORT void setStatisticsUpdatedCallback(WTF::Function<void(Vector<ResourceLoadStatistics>&&)>&&);
+    WEBCORE_EXPORT void setStatisticsUpdatedCallback(Function<void(PerSessionResourceLoadData&&)>&&);
     WEBCORE_EXPORT void setRequestStorageAccessUnderOpenerCallback(Function<void(PAL::SessionID, const RegistrableDomain&, PageIdentifier, const RegistrableDomain&)>&&);
     WEBCORE_EXPORT void setLogUserInteractionNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&)>&&);
     WEBCORE_EXPORT void setLogWebSocketLoadingNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&, WallTime)>&&);
@@ -89,18 +90,18 @@
 #endif
 
 private:
-    bool shouldLog(bool usesEphemeralSession) const;
-    ResourceLoadStatistics& ensureResourceStatisticsForRegistrableDomain(const RegistrableDomain&);
+    bool shouldLog(PAL::SessionID) const;
+    ResourceLoadStatistics& ensureResourceStatisticsForRegistrableDomain(PAL::SessionID, const RegistrableDomain&);
 
-    Vector<ResourceLoadStatistics> takeStatistics();
+    PerSessionResourceLoadData takeStatistics();
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     void requestStorageAccessUnderOpener(PAL::SessionID, const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, Document& openerDocument);
 #endif
 
-    HashMap<RegistrableDomain, ResourceLoadStatistics> m_resourceStatisticsMap;
+    HashMap<PAL::SessionID, std::unique_ptr<HashMap<RegistrableDomain, ResourceLoadStatistics>>> m_perSessionResourceStatisticsMap;
     HashMap<RegistrableDomain, WTF::WallTime> m_lastReportedUserInteractionMap;
-    Function<void(Vector<ResourceLoadStatistics>&&)> m_notificationCallback;
+    Function<void(PerSessionResourceLoadData)> m_notificationCallback;
     Function<void(PAL::SessionID, const RegistrableDomain&, PageIdentifier, const RegistrableDomain&)> m_requestStorageAccessUnderOpenerCallback;
     Function<void(PAL::SessionID, const RegistrableDomain&)> m_logUserInteractionNotificationCallback;
     Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&, WallTime)> m_logWebSocketLoadingNotificationCallback;

Modified: trunk/Source/WebCore/testing/Internals.cpp (249055 => 249056)


--- trunk/Source/WebCore/testing/Internals.cpp	2019-08-23 17:53:19 UTC (rev 249055)
+++ trunk/Source/WebCore/testing/Internals.cpp	2019-08-23 18:14:43 UTC (rev 249056)
@@ -4434,7 +4434,11 @@
 
 String Internals::resourceLoadStatisticsForURL(const DOMURL& url)
 {
-    return ResourceLoadObserver::shared().statisticsForURL(url.href());
+    auto* document = contextDocument();
+    if (!document)
+        return emptyString();
+
+    return ResourceLoadObserver::shared().statisticsForURL(document->sessionID(), url.href());
 }
 
 void Internals::setResourceLoadStatisticsEnabled(bool enable)

Modified: trunk/Source/WebKit/ChangeLog (249055 => 249056)


--- trunk/Source/WebKit/ChangeLog	2019-08-23 17:53:19 UTC (rev 249055)
+++ trunk/Source/WebKit/ChangeLog	2019-08-23 18:14:43 UTC (rev 249056)
@@ -1,3 +1,22 @@
+2019-08-23  Kate Cheney  <[email protected]>
+
+        Support ITP on a per-session basis (198923)
+        https://bugs.webkit.org/show_bug.cgi?id=198923
+
+        Reviewed by Chris Dumez.
+
+        The original implementation of resourceLoadStatisticsUpdated
+        did not allow for ITP on a per session basis due to the sessionID
+        not being passed to the resourceLoadStatisticsUpdated function.
+        This patch allows access of the correct networkSession by passing
+        all resourceLoadStatistics in a new data structure of key-value
+        pairs, where the sessionID is the key.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated):
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * WebProcess/WebProcess.cpp:
+
 2019-08-23  Russell Epstein  <[email protected]>
 
         Unreviewed, rolling out r249031.

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (249055 => 249056)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2019-08-23 17:53:19 UTC (rev 249055)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2019-08-23 18:14:43 UTC (rev 249056)
@@ -62,6 +62,7 @@
 #include "WebsiteDataStoreParameters.h"
 #include <WebCore/DocumentStorageAccess.h>
 #include <WebCore/NetworkStorageSession.h>
+#include <WebCore/ResourceLoadObserver.h>
 #include <WebCore/ResourceLoadStatistics.h>
 #include <WebCore/ResourceRequest.h>
 #include <WebCore/SameSiteInfo.h>
@@ -712,14 +713,14 @@
     }
 }
 
-void NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&& statistics)
+void NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated(ResourceLoadObserver::PerSessionResourceLoadData&& statistics)
 {
-    auto* networkSession = networkProcess().networkSessionByConnection(connection());
-    if (!networkSession)
-        return;
-
-    if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
-        resourceLoadStatistics->resourceLoadStatisticsUpdated(WTFMove(statistics));
+    for (auto& iter : statistics) {
+        if (auto* networkSession = networkProcess().networkSession(iter.first)) {
+            if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
+                resourceLoadStatistics->resourceLoadStatisticsUpdated(WTFMove(iter.second));
+        }
+    }
 }
 
 void NetworkConnectionToWebProcess::hasStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, FrameIdentifier frameID, PageIdentifier pageID, CompletionHandler<void(bool)>&& completionHandler)

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (249055 => 249056)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2019-08-23 17:53:19 UTC (rev 249055)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2019-08-23 18:14:43 UTC (rev 249056)
@@ -39,6 +39,7 @@
 #include <WebCore/PageIdentifier.h>
 #include <WebCore/ProcessIdentifier.h>
 #include <WebCore/RegistrableDomain.h>
+#include <WebCore/ResourceLoadObserver.h>
 #include <wtf/RefCounted.h>
 
 namespace PAL {
@@ -222,7 +223,7 @@
     void logWebSocketLoading(PAL::SessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen);
     void logSubresourceLoading(PAL::SessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen);
     void logSubresourceRedirect(PAL::SessionID, const RegistrableDomain& sourceDomain, const RegistrableDomain& targetDomain);
-    void resourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics>&&);
+    void resourceLoadStatisticsUpdated(WebCore::ResourceLoadObserver::PerSessionResourceLoadData&&);
     void hasStorageAccess(PAL::SessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, WebCore::FrameIdentifier, WebCore::PageIdentifier, CompletionHandler<void(bool)>&&);
     void requestStorageAccess(PAL::SessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, WebCore::FrameIdentifier, WebCore::PageIdentifier, CompletionHandler<void(WebCore::StorageAccessWasGranted, WebCore::StorageAccessPromptWasShown)>&&);
     void requestStorageAccessUnderOpener(PAL::SessionID, WebCore::RegistrableDomain&& domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::RegistrableDomain&& openerDomain);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (249055 => 249056)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in	2019-08-23 17:53:19 UTC (rev 249055)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in	2019-08-23 18:14:43 UTC (rev 249056)
@@ -64,7 +64,7 @@
     LogWebSocketLoading(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain, WebCore::RegistrableDomain topFrameDomain, WallTime lastSeen)
     LogSubresourceLoading(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain, WebCore::RegistrableDomain topFrameDomain, WallTime lastSeen)
     LogSubresourceRedirect(PAL::SessionID sessionID, WebCore::RegistrableDomain sourceDomain, WebCore::RegistrableDomain targetDomain)
-    ResourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics> statistics)
+    ResourceLoadStatisticsUpdated(Vector<std::pair<PAL::SessionID, Vector<WebCore::ResourceLoadStatistics>>> statistics)
     HasStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID) -> (bool hasStorageAccess) Async
     RequestStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::FrameIdentifier frameID, WebCore::PageIdentifier pageID) -> (enum:bool WebCore::StorageAccessWasGranted wasGranted, enum:bool WebCore::StorageAccessPromptWasShown promptWasShown) Async
     RequestStorageAccessUnderOpener(PAL::SessionID sessionID, WebCore::RegistrableDomain domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::RegistrableDomain openerDomain)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (249055 => 249056)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2019-08-23 17:53:19 UTC (rev 249055)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2019-08-23 18:14:43 UTC (rev 249056)
@@ -217,7 +217,7 @@
     m_plugInAutoStartOriginHashes.add(PAL::SessionID::defaultSessionID(), HashMap<unsigned, WallTime>());
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    ResourceLoadObserver::shared().setStatisticsUpdatedCallback([this] (Vector<ResourceLoadStatistics>&& statistics) {
+    ResourceLoadObserver::shared().setStatisticsUpdatedCallback([this] (auto&& statistics) {
         ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::ResourceLoadStatisticsUpdated(WTFMove(statistics)), 0);
     });
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to