Title: [249603] trunk/Source
Revision
249603
Author
[email protected]
Date
2019-09-06 18:53:20 -0700 (Fri, 06 Sep 2019)

Log Message

Move the ResourceLoadObserver logic to WebKit2
https://bugs.webkit.org/show_bug.cgi?id=201517

Reviewed by Brent Fulgham.

Move the ResourceLoadObserver logic to WebKit2 since it is not used by WebKit1. This allows us to simplify
code.

In a follow-up patch, I will simplify the code even further by leveraging the fact that a WebContent process
is always associated with a single WebsiteDataStore / sessionID:
- No need for a HashMap of sessionIDs
- No need to even allocate the ResourceLoadObserver if the WebProcess is associated with an ephemeral session.

Source/WebCore:

* dom/Document.h:
* loader/ResourceLoadObserver.cpp:
(WebCore::sharedObserver):
(WebCore::ResourceLoadObserver::setShared):
(WebCore::ResourceLoadObserver::shared):
* loader/ResourceLoadObserver.h:
(WebCore::ResourceLoadObserver::~ResourceLoadObserver):
(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::statisticsForURL):
(WebCore::ResourceLoadObserver::updateCentralStatisticsStore):
(WebCore::ResourceLoadObserver::clearState):
(WebCore::ResourceLoadObserver::setShouldLogUserInteraction):
* page/DeprecatedGlobalSettings.h:

Source/WebKit:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* Sources.txt:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp: Copied from Source/WebCore/loader/ResourceLoadObserver.cpp.
(WebKit::is3xxRedirect):
(WebKit::WebResourceLoadObserver::WebResourceLoadObserver):
(WebKit::WebResourceLoadObserver::shouldLog const):
(WebKit::WebResourceLoadObserver::requestStorageAccessUnderOpener):
(WebKit::WebResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain):
(WebKit::WebResourceLoadObserver::scheduleNotificationIfNeeded):
(WebKit::WebResourceLoadObserver::updateCentralStatisticsStore):
(WebKit::WebResourceLoadObserver::statisticsForURL):
(WebKit::WebResourceLoadObserver::takeStatistics):
(WebKit::WebResourceLoadObserver::clearState):
(WebKit::WebResourceLoadObserver::nonNullOwnerURL const):
(WebKit::WebResourceLoadObserver::logFontLoad):
(WebKit::WebResourceLoadObserver::logCanvasRead):
(WebKit::WebResourceLoadObserver::logCanvasWriteOrMeasure):
(WebKit::WebResourceLoadObserver::logNavigatorAPIAccessed):
(WebKit::WebResourceLoadObserver::logScreenAPIAccessed):
(WebKit::WebResourceLoadObserver::logSubresourceLoading):
(WebKit::WebResourceLoadObserver::logWebSocketLoading):
(WebKit::WebResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
* WebProcess/WebCoreSupport/WebResourceLoadObserver.h: Added.
* WebProcess/WebProcess.cpp:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (249602 => 249603)


--- trunk/Source/WebCore/ChangeLog	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebCore/ChangeLog	2019-09-07 01:53:20 UTC (rev 249603)
@@ -1,3 +1,39 @@
+2019-09-06  Chris Dumez  <[email protected]>
+
+        Move the ResourceLoadObserver logic to WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=201517
+
+        Reviewed by Brent Fulgham.
+
+        Move the ResourceLoadObserver logic to WebKit2 since it is not used by WebKit1. This allows us to simplify
+        code.
+
+        In a follow-up patch, I will simplify the code even further by leveraging the fact that a WebContent process
+        is always associated with a single WebsiteDataStore / sessionID:
+        - No need for a HashMap of sessionIDs
+        - No need to even allocate the ResourceLoadObserver if the WebProcess is associated with an ephemeral session.
+
+        * dom/Document.h:
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::sharedObserver):
+        (WebCore::ResourceLoadObserver::setShared):
+        (WebCore::ResourceLoadObserver::shared):
+        * loader/ResourceLoadObserver.h:
+        (WebCore::ResourceLoadObserver::~ResourceLoadObserver):
+        (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::statisticsForURL):
+        (WebCore::ResourceLoadObserver::updateCentralStatisticsStore):
+        (WebCore::ResourceLoadObserver::clearState):
+        (WebCore::ResourceLoadObserver::setShouldLogUserInteraction):
+        * page/DeprecatedGlobalSettings.h:
+
 2019-09-06  Justin Fan  <[email protected]>
 
         [WebGPU] Update several interface and enum names to match spec

Modified: trunk/Source/WebCore/dom/Document.h (249602 => 249603)


--- trunk/Source/WebCore/dom/Document.h	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebCore/dom/Document.h	2019-09-07 01:53:20 UTC (rev 249603)
@@ -1491,8 +1491,8 @@
 #endif
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    bool hasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain&);
-    void setHasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain&);
+    WEBCORE_EXPORT bool hasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain&);
+    WEBCORE_EXPORT void setHasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain&);
     WEBCORE_EXPORT void wasLoadedWithDataTransferFromPrevalentResource();
     void downgradeReferrerToRegistrableDomain();
 #endif

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (249602 => 249603)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2019-09-07 01:53:20 UTC (rev 249603)
@@ -26,414 +26,25 @@
 #include "config.h"
 #include "ResourceLoadObserver.h"
 
-#include "DeprecatedGlobalSettings.h"
-#include "Document.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "FrameLoaderClient.h"
-#include "HTMLFrameOwnerElement.h"
-#include "Logging.h"
-#include "Page.h"
-#include "RegistrableDomain.h"
-#include "ResourceLoadStatistics.h"
-#include "ResourceRequest.h"
-#include "ResourceResponse.h"
-#include "RuntimeEnabledFeatures.h"
-#include "ScriptExecutionContext.h"
-#include "SecurityOrigin.h"
-#include "Settings.h"
-#include <wtf/URL.h>
-
 namespace WebCore {
 
-static const Seconds minimumNotificationInterval { 5_s };
-
-ResourceLoadObserver::ResourceLoadObserver()
-    : m_notificationTimer(*this, &ResourceLoadObserver::updateCentralStatisticsStore)
+static ResourceLoadObserver*& sharedObserver()
 {
+    static ResourceLoadObserver* observer = nullptr;
+    return observer;
 }
 
-ResourceLoadObserver& ResourceLoadObserver::shared()
+void ResourceLoadObserver::setShared(ResourceLoadObserver& observer)
 {
-    static NeverDestroyed<ResourceLoadObserver> resourceLoadObserver;
-    return resourceLoadObserver;
+    RELEASE_ASSERT(!sharedObserver());
+    sharedObserver() = &observer;
 }
 
-void ResourceLoadObserver::setStatisticsUpdatedCallback(Function<void(PerSessionResourceLoadData&&)>&& notificationCallback)
+ResourceLoadObserver& ResourceLoadObserver::shared()
 {
-    ASSERT(!m_notificationCallback);
-    m_notificationCallback = WTFMove(notificationCallback);
+    if (!sharedObserver())
+        sharedObserver() = new ResourceLoadObserver;
+    return *sharedObserver();
 }
 
-void ResourceLoadObserver::setRequestStorageAccessUnderOpenerCallback(Function<void(PAL::SessionID sessionID, const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, const RegistrableDomain& openerDomain)>&& callback)
-{
-    ASSERT(!m_requestStorageAccessUnderOpenerCallback);
-    m_requestStorageAccessUnderOpenerCallback = WTFMove(callback);
-}
-
-void ResourceLoadObserver::setLogUserInteractionNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&)>&& callback)
-{
-    ASSERT(!m_logUserInteractionNotificationCallback);
-    m_logUserInteractionNotificationCallback = WTFMove(callback);
-}
-    
-static inline bool is3xxRedirect(const ResourceResponse& response)
-{
-    return response.httpStatusCode() >= 300 && response.httpStatusCode() <= 399;
-}
-
-bool ResourceLoadObserver::shouldLog(PAL::SessionID sessionID) const
-{
-    return DeprecatedGlobalSettings::resourceLoadStatisticsEnabled() && !sessionID.isEphemeral() && m_notificationCallback;
-}
-
-void ResourceLoadObserver::logSubresourceLoading(const Frame* frame, const ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
-{
-    ASSERT(frame->page());
-
-    if (!frame)
-        return;
-
-    auto* page = frame->page();
-    if (!page || !shouldLog(page->sessionID()))
-        return;
-
-    bool isRedirect = is3xxRedirect(redirectResponse);
-    const URL& redirectedFromURL = redirectResponse.url();
-    const URL& targetURL = newRequest.url();
-    const URL& topFrameURL = frame ? frame->mainFrame().document()->url() : URL();
-    
-    auto targetHost = targetURL.host();
-    auto topFrameHost = topFrameURL.host();
-
-    if (targetHost.isEmpty() || topFrameHost.isEmpty() || targetHost == topFrameHost || (isRedirect && targetHost == redirectedFromURL.host()))
-        return;
-
-    RegistrableDomain targetDomain { targetURL };
-    RegistrableDomain topFrameDomain { topFrameURL };
-    RegistrableDomain redirectedFromDomain { redirectedFromURL };
-
-    if (targetDomain == topFrameDomain || (isRedirect && targetDomain == redirectedFromDomain))
-        return;
-
-    {
-        auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), targetDomain);
-        auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
-        targetStatistics.lastSeen = lastSeen;
-        targetStatistics.subresourceUnderTopFrameDomains.add(topFrameDomain);
-
-        scheduleNotificationIfNeeded();
-    }
-
-    if (isRedirect) {
-        auto& redirectingOriginStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), redirectedFromDomain);
-        redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetDomain);
-        auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), targetDomain);
-        targetStatistics.subresourceUniqueRedirectsFrom.add(redirectedFromDomain);
-
-        scheduleNotificationIfNeeded();
-    }
-}
-
-void ResourceLoadObserver::logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL, PAL::SessionID sessionID)
-{
-    if (!shouldLog(sessionID))
-        return;
-
-    auto targetHost = targetURL.host();
-    auto mainFrameHost = mainFrameURL.host();
-    
-    if (targetHost.isEmpty() || mainFrameHost.isEmpty() || targetHost == mainFrameHost)
-        return;
-    
-    RegistrableDomain targetDomain { targetURL };
-    RegistrableDomain topFrameDomain { mainFrameURL };
-
-    if (targetDomain == topFrameDomain)
-        return;
-
-    auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
-
-    auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(sessionID, targetDomain);
-    targetStatistics.lastSeen = lastSeen;
-    targetStatistics.subresourceUnderTopFrameDomains.add(topFrameDomain);
-
-    scheduleNotificationIfNeeded();
-}
-
-void ResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Document& document)
-{
-    if (!document.sessionID().isValid() || !shouldLog(document.sessionID()))
-        return;
-
-    auto& url = ""
-    if (url.protocolIsAbout() || url.isLocalFile() || url.isEmpty())
-        return;
-
-    RegistrableDomain topFrameDomain { url };
-    auto newTime = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
-    auto lastReportedUserInteraction = m_lastReportedUserInteractionMap.get(topFrameDomain);
-    if (newTime == lastReportedUserInteraction)
-        return;
-
-    m_lastReportedUserInteractionMap.set(topFrameDomain, newTime);
-
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID(), topFrameDomain);
-    statistics.hadUserInteraction = true;
-    statistics.lastSeen = newTime;
-    statistics.mostRecentUserInteractionTime = newTime;
-
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-    if (auto* frame = document.frame()) {
-        if (auto* opener = frame->loader().opener()) {
-            if (auto* openerDocument = opener->document()) {
-                if (auto* openerFrame = openerDocument->frame()) {
-                    if (auto openerPageID = openerFrame->loader().client().pageID())
-                        requestStorageAccessUnderOpener(document.sessionID(), topFrameDomain, openerPageID.value(), *openerDocument);
-                }
-            }
-        }
-    }
-
-    // We notify right away in case of a user interaction instead of waiting the usual 5 seconds because we want
-    // to update cookie blocking state as quickly as possible.
-    m_logUserInteractionNotificationCallback(document.sessionID(), topFrameDomain);
-#endif
-
-#if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
-    if (shouldLogUserInteraction()) {
-        auto counter = ++m_loggingCounter;
-#define LOCAL_LOG(str, ...) \
-        RELEASE_LOG(ResourceLoadStatistics, "ResourceLoadObserver::logUserInteraction: counter = %" PRIu64 ": " str, counter, ##__VA_ARGS__)
-
-        auto escapeForJSON = [](String s) {
-            s.replace('\\', "\\\\").replace('"', "\\\"");
-            return s;
-        };
-        auto escapedURL = escapeForJSON(url.string());
-        auto escapedDomain = escapeForJSON(topFrameDomain.string());
-
-        LOCAL_LOG(R"({ "url": "%{public}s",)", escapedURL.utf8().data());
-        LOCAL_LOG(R"(  "domain" : "%{public}s",)", escapedDomain.utf8().data());
-        LOCAL_LOG(R"(  "until" : %f })", newTime.secondsSinceEpoch().seconds());
-
-#undef LOCAL_LOG
-    }
-#endif
-}
-
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-void ResourceLoadObserver::requestStorageAccessUnderOpener(PAL::SessionID sessionID, const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, Document& openerDocument)
-{
-    auto openerUrl = openerDocument.url();
-    RegistrableDomain openerDomain { openerUrl };
-    if (domainInNeedOfStorageAccess != openerDomain
-        && !openerDocument.hasRequestedPageSpecificStorageAccessWithUserInteraction(domainInNeedOfStorageAccess)
-        && !equalIgnoringASCIICase(openerUrl.string(), WTF::blankURL())) {
-        m_requestStorageAccessUnderOpenerCallback(sessionID, domainInNeedOfStorageAccess, openerPageID, openerDomain);
-        // Remember user interaction-based requests since they don't need to be repeated.
-        openerDocument.setHasRequestedPageSpecificStorageAccessWithUserInteraction(domainInNeedOfStorageAccess);
-    }
-}
-#endif
-
-void ResourceLoadObserver::logFontLoad(const Document& document, const String& familyName, bool loadStatus)
-{
-#if ENABLE(WEB_API_STATISTICS)
-    if (!shouldLog(document.sessionID()))
-        return;
-    RegistrableDomain registrableDomain { document.url() };
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
-    bool shouldCallNotificationCallback = false;
-    if (!loadStatus) {
-        if (statistics.fontsFailedToLoad.add(familyName).isNewEntry)
-            shouldCallNotificationCallback = true;
-    } else {
-        if (statistics.fontsSuccessfullyLoaded.add(familyName).isNewEntry)
-            shouldCallNotificationCallback = true;
-    }
-    RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
-    if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
-        shouldCallNotificationCallback = true;
-    if (shouldCallNotificationCallback)
-        scheduleNotificationIfNeeded();
-#else
-    UNUSED_PARAM(document);
-    UNUSED_PARAM(familyName);
-    UNUSED_PARAM(loadStatus);
-#endif
-}
-    
-void ResourceLoadObserver::logCanvasRead(const Document& document)
-{
-#if ENABLE(WEB_API_STATISTICS)
-    if (!shouldLog(document.sessionID()))
-        return;
-    RegistrableDomain registrableDomain { document.url() };
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID(), registrableDomain);
-    RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
-    statistics.canvasActivityRecord.wasDataRead = true;
-    if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
-        scheduleNotificationIfNeeded();
-#else
-    UNUSED_PARAM(document);
-#endif
-}
-
-void ResourceLoadObserver::logCanvasWriteOrMeasure(const Document& document, const String& textWritten)
-{
-#if ENABLE(WEB_API_STATISTICS)
-    if (!shouldLog(document.sessionID()))
-        return;
-    RegistrableDomain registrableDomain { document.url() };
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
-    bool shouldCallNotificationCallback = false;
-    RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
-    if (statistics.canvasActivityRecord.recordWrittenOrMeasuredText(textWritten))
-        shouldCallNotificationCallback = true;
-    if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
-        shouldCallNotificationCallback = true;
-    if (shouldCallNotificationCallback)
-        scheduleNotificationIfNeeded();
-#else
-    UNUSED_PARAM(document);
-    UNUSED_PARAM(textWritten);
-#endif
-}
-    
-void ResourceLoadObserver::logNavigatorAPIAccessed(const Document& document, const ResourceLoadStatistics::NavigatorAPI functionName)
-{
-#if ENABLE(WEB_API_STATISTICS)
-    if (!shouldLog(document.sessionID()))
-        return;
-    RegistrableDomain registrableDomain { document.url() };
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
-    bool shouldCallNotificationCallback = false;
-    if (!statistics.navigatorFunctionsAccessed.contains(functionName)) {
-        statistics.navigatorFunctionsAccessed.add(functionName);
-        shouldCallNotificationCallback = true;
-    }
-    RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
-    if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
-        shouldCallNotificationCallback = true;
-    if (shouldCallNotificationCallback)
-        scheduleNotificationIfNeeded();
-#else
-    UNUSED_PARAM(document);
-    UNUSED_PARAM(functionName);
-#endif
-}
-    
-void ResourceLoadObserver::logScreenAPIAccessed(const Document& document, const ResourceLoadStatistics::ScreenAPI functionName)
-{
-#if ENABLE(WEB_API_STATISTICS)
-    if (!shouldLog(document.sessionID()))
-        return;
-    RegistrableDomain registrableDomain { document.url() };
-    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
-    bool shouldCallNotificationCallback = false;
-    if (!statistics.screenFunctionsAccessed.contains(functionName)) {
-        statistics.screenFunctionsAccessed.add(functionName);
-        shouldCallNotificationCallback = true;
-    }
-    RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
-    if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
-        shouldCallNotificationCallback = true;
-    if (shouldCallNotificationCallback)
-        scheduleNotificationIfNeeded();
-#else
-    UNUSED_PARAM(document);
-    UNUSED_PARAM(functionName);
-#endif
-}
-    
-ResourceLoadStatistics& ResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain(PAL::SessionID sessionID, const RegistrableDomain& domain)
-{
-    auto addResult = m_perSessionResourceStatisticsMap.ensure(sessionID, [] {
-        return makeUnique<HashMap<RegistrableDomain, ResourceLoadStatistics>>();
-    });
-
-    auto addDomainResult = addResult.iterator->value->ensure(domain, [&domain] {
-        return ResourceLoadStatistics(domain);
-    });
-    return addDomainResult.iterator->value;
-}
-
-void ResourceLoadObserver::scheduleNotificationIfNeeded()
-{
-    ASSERT(m_notificationCallback);
-    if (m_perSessionResourceStatisticsMap.isEmpty()) {
-        m_notificationTimer.stop();
-        return;
-    }
-
-    if (!m_notificationTimer.isActive())
-        m_notificationTimer.startOneShot(minimumNotificationInterval);
-}
-
-void ResourceLoadObserver::updateCentralStatisticsStore()
-{
-    ASSERT(m_notificationCallback);
-    m_notificationTimer.stop();
-    m_notificationCallback(takeStatistics());
-}
-
-String ResourceLoadObserver::statisticsForURL(PAL::SessionID sessionID, const URL& url)
-{
-    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());
-}
-
-auto ResourceLoadObserver::takeStatistics() -> PerSessionResourceLoadData
-{
-    PerSessionResourceLoadData perSessionStatistics;
-
-    for (auto& iter : m_perSessionResourceStatisticsMap) {
-        Vector<ResourceLoadStatistics> statistics;
-        statistics.reserveInitialCapacity(iter.value->size());
-
-        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_notificationTimer.stop();
-    m_perSessionResourceStatisticsMap.clear();
-    m_lastReportedUserInteractionMap.clear();
-}
-
-URL ResourceLoadObserver::nonNullOwnerURL(const Document& document) const
-{
-    auto url = ""
-    auto* frame = document.frame();
-    auto host = document.url().host();
-
-    while ((host.isNull() || host.isEmpty()) && frame && !frame->isMainFrame()) {
-        auto* ownerElement = frame->ownerElement();
-
-        ASSERT(ownerElement != nullptr);
-        
-        auto& doc = ownerElement->document();
-        frame = doc.frame();
-        url = ""
-        host = url.host();
-    }
-
-    return url;
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (249602 => 249603)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.h	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h	2019-09-07 01:53:20 UTC (rev 249603)
@@ -25,91 +25,41 @@
 
 #pragma once
 
-#include "CanvasActivityRecord.h"
-#include "PageIdentifier.h"
 #include "ResourceLoadStatistics.h"
-#include "Timer.h"
 #include <pal/SessionID.h>
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/NeverDestroyed.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/Forward.h>
 
-namespace WTF {
-class Lock;
-class WorkQueue;
-class WallTime;
-}
-
 namespace WebCore {
 
 class Document;
 class Frame;
-class Page;
-class RegistrableDomain;
 class ResourceRequest;
 class ResourceResponse;
-class ScriptExecutionContext;
 
-struct ResourceLoadStatistics;
-
 class ResourceLoadObserver {
-    friend class WTF::NeverDestroyed<ResourceLoadObserver>;
+    WTF_MAKE_FAST_ALLOCATED;
 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);
-    void logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL, PAL::SessionID);
-    void logUserInteractionWithReducedTimeResolution(const Document&);
+    WEBCORE_EXPORT static void setShared(ResourceLoadObserver&);
     
-    void logFontLoad(const Document&, const String& familyName, bool loadStatus);
-    void logCanvasRead(const Document&);
-    void logCanvasWriteOrMeasure(const Document&, const String& textWritten);
-    void logNavigatorAPIAccessed(const Document&, const ResourceLoadStatistics::NavigatorAPI);
-    void logScreenAPIAccessed(const Document&, const ResourceLoadStatistics::ScreenAPI);
+    virtual ~ResourceLoadObserver() { }
 
-    WEBCORE_EXPORT String statisticsForURL(PAL::SessionID, const URL&);
+    virtual void logSubresourceLoading(const Frame*, const ResourceRequest& /* newRequest */, const ResourceResponse& /* redirectResponse */) { }
+    virtual void logWebSocketLoading(const URL& /* targetURL */, const URL& /* mainFrameURL */, PAL::SessionID) { }
+    virtual void logUserInteractionWithReducedTimeResolution(const Document&) { }
+    virtual void logFontLoad(const Document&, const String& /* familyName */, bool /* loadStatus */) { }
+    virtual void logCanvasRead(const Document&) { }
+    virtual void logCanvasWriteOrMeasure(const Document&, const String& /* textWritten */) { }
+    virtual void logNavigatorAPIAccessed(const Document&, const ResourceLoadStatistics::NavigatorAPI) { }
+    virtual void logScreenAPIAccessed(const Document&, const ResourceLoadStatistics::ScreenAPI) { }
 
-    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 updateCentralStatisticsStore();
-    WEBCORE_EXPORT void clearState();
-
+    virtual String statisticsForURL(PAL::SessionID, const URL&) { return { }; }
+    virtual void updateCentralStatisticsStore() { }
+    virtual void clearState() { }
+    
 #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
-    bool shouldLogUserInteraction() const { return m_shouldLogUserInteraction; }
-    void setShouldLogUserInteraction(bool shouldLogUserInteraction) { m_shouldLogUserInteraction = shouldLogUserInteraction; }
+    virtual void setShouldLogUserInteraction(bool) { }
 #endif
-
-private:
-    ResourceLoadObserver();
-
-    bool shouldLog(PAL::SessionID) const;
-    ResourceLoadStatistics& ensureResourceStatisticsForRegistrableDomain(PAL::SessionID, const RegistrableDomain&);
-    void scheduleNotificationIfNeeded();
-
-    PerSessionResourceLoadData takeStatistics();
-
-#if ENABLE(RESOURCE_LOAD_STATISTICS)
-    void requestStorageAccessUnderOpener(PAL::SessionID, const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, Document& openerDocument);
-#endif
-
-    HashMap<PAL::SessionID, std::unique_ptr<HashMap<RegistrableDomain, ResourceLoadStatistics>>> m_perSessionResourceStatisticsMap;
-    HashMap<RegistrableDomain, WTF::WallTime> m_lastReportedUserInteractionMap;
-    Function<void(PerSessionResourceLoadData)> m_notificationCallback;
-    Function<void(PAL::SessionID, const RegistrableDomain&, PageIdentifier, const RegistrableDomain&)> m_requestStorageAccessUnderOpenerCallback;
-    Function<void(PAL::SessionID, const RegistrableDomain&)> m_logUserInteractionNotificationCallback;
-
-    Timer m_notificationTimer;
-
-#if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
-    uint64_t m_loggingCounter { 0 };
-    bool m_shouldLogUserInteraction { false };
-#endif
-
-    URL nonNullOwnerURL(const Document&) const;
 };
     
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/DeprecatedGlobalSettings.h (249602 => 249603)


--- trunk/Source/WebCore/page/DeprecatedGlobalSettings.h	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebCore/page/DeprecatedGlobalSettings.h	2019-09-07 01:53:20 UTC (rev 249603)
@@ -134,7 +134,7 @@
     WEBCORE_EXPORT static bool gManageAudioSession;
 
     static bool gLowPowerVideoAudioBufferSizeEnabled;
-    static bool gResourceLoadStatisticsEnabledEnabled;
+    WEBCORE_EXPORT static bool gResourceLoadStatisticsEnabledEnabled;
     static bool gAllowsAnySSLCertificate;
 };
 

Modified: trunk/Source/WebKit/ChangeLog (249602 => 249603)


--- trunk/Source/WebKit/ChangeLog	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebKit/ChangeLog	2019-09-07 01:53:20 UTC (rev 249603)
@@ -1,3 +1,46 @@
+2019-09-06  Chris Dumez  <[email protected]>
+
+        Move the ResourceLoadObserver logic to WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=201517
+
+        Reviewed by Brent Fulgham.
+
+        Move the ResourceLoadObserver logic to WebKit2 since it is not used by WebKit1. This allows us to simplify
+        code.
+
+        In a follow-up patch, I will simplify the code even further by leveraging the fact that a WebContent process
+        is always associated with a single WebsiteDataStore / sessionID:
+        - No need for a HashMap of sessionIDs
+        - No need to even allocate the ResourceLoadObserver if the WebProcess is associated with an ephemeral session.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated):
+        * NetworkProcess/NetworkConnectionToWebProcess.h:
+        * Sources.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp: Copied from Source/WebCore/loader/ResourceLoadObserver.cpp.
+        (WebKit::is3xxRedirect):
+        (WebKit::WebResourceLoadObserver::WebResourceLoadObserver):
+        (WebKit::WebResourceLoadObserver::shouldLog const):
+        (WebKit::WebResourceLoadObserver::requestStorageAccessUnderOpener):
+        (WebKit::WebResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain):
+        (WebKit::WebResourceLoadObserver::scheduleNotificationIfNeeded):
+        (WebKit::WebResourceLoadObserver::updateCentralStatisticsStore):
+        (WebKit::WebResourceLoadObserver::statisticsForURL):
+        (WebKit::WebResourceLoadObserver::takeStatistics):
+        (WebKit::WebResourceLoadObserver::clearState):
+        (WebKit::WebResourceLoadObserver::nonNullOwnerURL const):
+        (WebKit::WebResourceLoadObserver::logFontLoad):
+        (WebKit::WebResourceLoadObserver::logCanvasRead):
+        (WebKit::WebResourceLoadObserver::logCanvasWriteOrMeasure):
+        (WebKit::WebResourceLoadObserver::logNavigatorAPIAccessed):
+        (WebKit::WebResourceLoadObserver::logScreenAPIAccessed):
+        (WebKit::WebResourceLoadObserver::logSubresourceLoading):
+        (WebKit::WebResourceLoadObserver::logWebSocketLoading):
+        (WebKit::WebResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+        * WebProcess/WebCoreSupport/WebResourceLoadObserver.h: Added.
+        * WebProcess/WebProcess.cpp:
+
 2019-09-06  Jiewen Tan  <[email protected]>
 
         [WebAuthn] Make WebAuthn default off and let clients turn it on at will

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (249602 => 249603)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2019-09-07 01:53:20 UTC (rev 249603)
@@ -696,7 +696,7 @@
     }
 }
 
-void NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated(ResourceLoadObserver::PerSessionResourceLoadData&& statistics)
+void NetworkConnectionToWebProcess::resourceLoadStatisticsUpdated(WebResourceLoadObserver::PerSessionResourceLoadData&& statistics)
 {
     for (auto& iter : statistics) {
         if (auto* networkSession = networkProcess().networkSession(iter.first)) {

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (249602 => 249603)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h	2019-09-07 01:53:20 UTC (rev 249603)
@@ -34,6 +34,7 @@
 #include "NetworkRTCProvider.h"
 #include "NetworkResourceLoadMap.h"
 #include "WebPaymentCoordinatorProxy.h"
+#include "WebResourceLoadObserver.h"
 #include <WebCore/FrameIdentifier.h>
 #include <WebCore/MessagePortChannelProvider.h>
 #include <WebCore/MessagePortIdentifier.h>
@@ -41,7 +42,6 @@
 #include <WebCore/PageIdentifier.h>
 #include <WebCore/ProcessIdentifier.h>
 #include <WebCore/RegistrableDomain.h>
-#include <WebCore/ResourceLoadObserver.h>
 #include <wtf/RefCounted.h>
 
 namespace PAL {
@@ -235,7 +235,7 @@
     void clearPageSpecificDataForResourceLoadStatistics(PAL::SessionID, WebCore::PageIdentifier);
 
     void logUserInteraction(PAL::SessionID, const RegistrableDomain&);
-    void resourceLoadStatisticsUpdated(WebCore::ResourceLoadObserver::PerSessionResourceLoadData&&);
+    void resourceLoadStatisticsUpdated(WebResourceLoadObserver::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, WebPageProxyIdentifier, CompletionHandler<void(WebCore::StorageAccessWasGranted, WebCore::StorageAccessPromptWasShown)>&&);
     void requestStorageAccessUnderOpener(PAL::SessionID, WebCore::RegistrableDomain&& domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::RegistrableDomain&& openerDomain);

Modified: trunk/Source/WebKit/Sources.txt (249602 => 249603)


--- trunk/Source/WebKit/Sources.txt	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebKit/Sources.txt	2019-09-07 01:53:20 UTC (rev 249603)
@@ -554,6 +554,7 @@
 WebProcess/WebCoreSupport/WebPlugInClient.cpp
 WebProcess/WebCoreSupport/WebPopupMenu.cpp
 WebProcess/WebCoreSupport/WebProgressTrackerClient.cpp
+WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp
 WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp
 WebProcess/WebCoreSupport/WebUserMediaClient.cpp
 WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (249602 => 249603)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-09-07 01:53:20 UTC (rev 249603)
@@ -910,6 +910,7 @@
 		4657D88A22664A2F005DE823 /* WKOrientationAccessAlert.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4657D88822664A1A005DE823 /* WKOrientationAccessAlert.mm */; };
 		465F4E06230B2E95003CEDB7 /* StorageNamespaceIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 465F4E05230B2E7C003CEDB7 /* StorageNamespaceIdentifier.h */; };
 		466BC03C1FA266DA002FA9C1 /* WebSWContextManagerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 466BC0391FA266C9002FA9C1 /* WebSWContextManagerConnection.h */; };
+		4671FF1F23217EFF001B64C7 /* WebResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 4671FF1D23217EFF001B64C7 /* WebResourceLoadObserver.h */; };
 		467E43E82243FF7D00B13924 /* WebProcessDataStoreParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 467E43E72243FF6D00B13924 /* WebProcessDataStoreParameters.h */; };
 		46A2B6091E5676A600C3DEDA /* BackgroundProcessResponsivenessTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46A2B6071E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.h */; };
 		46B0524722668D8500265B97 /* WebDeviceOrientationAndMotionAccessController.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B0524422668D2300265B97 /* WebDeviceOrientationAndMotionAccessController.h */; };
@@ -3217,6 +3218,8 @@
 		466BC0381FA266C9002FA9C1 /* WebSWContextManagerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWContextManagerConnection.cpp; sourceTree = "<group>"; };
 		466BC0391FA266C9002FA9C1 /* WebSWContextManagerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWContextManagerConnection.h; sourceTree = "<group>"; };
 		466BC03A1FA266C9002FA9C1 /* WebSWContextManagerConnection.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebSWContextManagerConnection.messages.in; sourceTree = "<group>"; };
+		4671FF1D23217EFF001B64C7 /* WebResourceLoadObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebResourceLoadObserver.h; sourceTree = "<group>"; };
+		4671FF1E23217EFF001B64C7 /* WebResourceLoadObserver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebResourceLoadObserver.cpp; sourceTree = "<group>"; };
 		467E43E72243FF6D00B13924 /* WebProcessDataStoreParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebProcessDataStoreParameters.h; sourceTree = "<group>"; };
 		4683569A21E81CC7006E27A3 /* ProvisionalPageProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProvisionalPageProxy.h; sourceTree = "<group>"; };
 		4683569B21E81CC7006E27A3 /* ProvisionalPageProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProvisionalPageProxy.cpp; sourceTree = "<group>"; };
@@ -7625,6 +7628,8 @@
 				D3B9484311FF4B6500032B39 /* WebPopupMenu.h */,
 				1A1E093118861D3800D2DC49 /* WebProgressTrackerClient.cpp */,
 				1A1E093218861D3800D2DC49 /* WebProgressTrackerClient.h */,
+				4671FF1E23217EFF001B64C7 /* WebResourceLoadObserver.cpp */,
+				4671FF1D23217EFF001B64C7 /* WebResourceLoadObserver.h */,
 				D3B9484411FF4B6500032B39 /* WebSearchPopupMenu.cpp */,
 				D3B9484511FF4B6500032B39 /* WebSearchPopupMenu.h */,
 				C149380322341DF7000CD707 /* WebSpeechSynthesisClient.cpp */,
@@ -9993,8 +9998,10 @@
 				461CCCA6231485AA00B659B9 /* WebRemoteObjectRegistry.h in Headers */,
 				37948404150C350600E52CE9 /* WebRenderLayer.h in Headers */,
 				3760881F150413E900FC82C7 /* WebRenderObject.h in Headers */,
+				A5860E71230F67FC00461AAE /* WebResourceInterceptController.h in Headers */,
 				510AFFBA16542048001BA05E /* WebResourceLoader.h in Headers */,
 				51F060E01654317F00F3281B /* WebResourceLoaderMessages.h in Headers */,
+				4671FF1F23217EFF001B64C7 /* WebResourceLoadObserver.h in Headers */,
 				7AFBD36321E50F39005DBACB /* WebResourceLoadStatisticsStore.h in Headers */,
 				413075B01DE85F580039EC69 /* WebRTCMonitor.h in Headers */,
 				41FAF5F51E3C0649001AE678 /* WebRTCResolver.h in Headers */,
@@ -10211,7 +10218,6 @@
 				0F3C725B196F604E00AEDD0C /* WKInspectorHighlightView.h in Headers */,
 				A54293A4195A43DA002782C7 /* WKInspectorNodeSearchGestureRecognizer.h in Headers */,
 				6EE849C81368D9390038D481 /* WKInspectorPrivateMac.h in Headers */,
-				A5860E71230F67FC00461AAE /* WebResourceInterceptController.h in Headers */,
 				994BADF41F7D781400B571E7 /* WKInspectorViewController.h in Headers */,
 				A518B5D21FE1D55B00F9FA28 /* WKInspectorWKWebView.h in Headers */,
 				2DD5E129210ADC7B00DB6012 /* WKKeyboardScrollingAnimator.h in Headers */,

Copied: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp (from rev 249602, trunk/Source/WebCore/loader/ResourceLoadObserver.cpp) (0 => 249603)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp	2019-09-07 01:53:20 UTC (rev 249603)
@@ -0,0 +1,391 @@
+/*
+* Copyright (C) 2019 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "config.h"
+#include "WebResourceLoadObserver.h"
+
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+
+#include "NetworkConnectionToWebProcessMessages.h"
+#include "NetworkProcessConnection.h"
+#include "WebProcess.h"
+#include <WebCore/DeprecatedGlobalSettings.h>
+#include <WebCore/Frame.h>
+#include <WebCore/FrameLoader.h>
+#include <WebCore/HTMLFrameOwnerElement.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+static const Seconds minimumNotificationInterval { 5_s };
+
+static bool is3xxRedirect(const ResourceResponse& response)
+{
+    return response.httpStatusCode() >= 300 && response.httpStatusCode() <= 399;
+}
+
+static bool shouldLogResourceLoadStatistics(PAL::SessionID sessionID)
+{
+    return DeprecatedGlobalSettings::resourceLoadStatisticsEnabled() && !sessionID.isEphemeral();
+}
+
+WebResourceLoadObserver::WebResourceLoadObserver()
+    : m_notificationTimer(*this, &WebResourceLoadObserver::updateCentralStatisticsStore)
+{
+}
+
+void WebResourceLoadObserver::requestStorageAccessUnderOpener(PAL::SessionID sessionID, const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, Document& openerDocument)
+{
+    auto openerUrl = openerDocument.url();
+    RegistrableDomain openerDomain { openerUrl };
+    if (domainInNeedOfStorageAccess != openerDomain
+        && !openerDocument.hasRequestedPageSpecificStorageAccessWithUserInteraction(domainInNeedOfStorageAccess)
+        && !equalIgnoringASCIICase(openerUrl.string(), WTF::blankURL())) {
+        WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RequestStorageAccessUnderOpener(sessionID, domainInNeedOfStorageAccess, openerPageID, openerDomain), 0);
+        
+        // Remember user interaction-based requests since they don't need to be repeated.
+        openerDocument.setHasRequestedPageSpecificStorageAccessWithUserInteraction(domainInNeedOfStorageAccess);
+    }
+}
+    
+ResourceLoadStatistics& WebResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain(PAL::SessionID sessionID, const RegistrableDomain& domain)
+{
+    auto addResult = m_perSessionResourceStatisticsMap.ensure(sessionID, [] {
+        return makeUnique<HashMap<RegistrableDomain, ResourceLoadStatistics>>();
+    });
+
+    auto addDomainResult = addResult.iterator->value->ensure(domain, [&domain] {
+        return ResourceLoadStatistics(domain);
+    });
+    return addDomainResult.iterator->value;
+}
+
+void WebResourceLoadObserver::scheduleNotificationIfNeeded()
+{
+    if (m_perSessionResourceStatisticsMap.isEmpty()) {
+        m_notificationTimer.stop();
+        return;
+    }
+
+    if (!m_notificationTimer.isActive())
+        m_notificationTimer.startOneShot(minimumNotificationInterval);
+}
+
+void WebResourceLoadObserver::updateCentralStatisticsStore()
+{
+    m_notificationTimer.stop();
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::ResourceLoadStatisticsUpdated(takeStatistics()), 0);
+}
+
+String WebResourceLoadObserver::statisticsForURL(PAL::SessionID sessionID, const URL& url)
+{
+    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());
+}
+
+auto WebResourceLoadObserver::takeStatistics() -> PerSessionResourceLoadData
+{
+    PerSessionResourceLoadData perSessionStatistics;
+
+    for (auto& iter : m_perSessionResourceStatisticsMap) {
+        Vector<ResourceLoadStatistics> statistics;
+        statistics.reserveInitialCapacity(iter.value->size());
+
+        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 WebResourceLoadObserver::clearState()
+{
+    m_notificationTimer.stop();
+    m_perSessionResourceStatisticsMap.clear();
+    m_lastReportedUserInteractionMap.clear();
+}
+
+void WebResourceLoadObserver::logFontLoad(const Document& document, const String& familyName, bool loadStatus)
+{
+#if ENABLE(WEB_API_STATISTICS)
+    if (!shouldLogResourceLoadStatistics(document.sessionID()))
+        return;
+
+    RegistrableDomain registrableDomain { document.url() };
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
+    bool shouldCallNotificationCallback = false;
+    if (!loadStatus) {
+        if (statistics.fontsFailedToLoad.add(familyName).isNewEntry)
+            shouldCallNotificationCallback = true;
+    } else {
+        if (statistics.fontsSuccessfullyLoaded.add(familyName).isNewEntry)
+            shouldCallNotificationCallback = true;
+    }
+    RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
+    if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
+        shouldCallNotificationCallback = true;
+    if (shouldCallNotificationCallback)
+        scheduleNotificationIfNeeded();
+#else
+    UNUSED_PARAM(document);
+    UNUSED_PARAM(familyName);
+    UNUSED_PARAM(loadStatus);
+#endif
+}
+    
+void WebResourceLoadObserver::logCanvasRead(const Document& document)
+{
+#if ENABLE(WEB_API_STATISTICS)
+    if (!shouldLogResourceLoadStatistics(document.sessionID()))
+        return;
+
+    RegistrableDomain registrableDomain { document.url() };
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID(), registrableDomain);
+    RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
+    statistics.canvasActivityRecord.wasDataRead = true;
+    if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
+        scheduleNotificationIfNeeded();
+#else
+    UNUSED_PARAM(document);
+#endif
+}
+
+void WebResourceLoadObserver::logCanvasWriteOrMeasure(const Document& document, const String& textWritten)
+{
+#if ENABLE(WEB_API_STATISTICS)
+    if (!shouldLogResourceLoadStatistics(document.sessionID()))
+        return;
+
+    RegistrableDomain registrableDomain { document.url() };
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
+    bool shouldCallNotificationCallback = false;
+    RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
+    if (statistics.canvasActivityRecord.recordWrittenOrMeasuredText(textWritten))
+        shouldCallNotificationCallback = true;
+    if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
+        shouldCallNotificationCallback = true;
+    if (shouldCallNotificationCallback)
+        scheduleNotificationIfNeeded();
+#else
+    UNUSED_PARAM(document);
+    UNUSED_PARAM(textWritten);
+#endif
+}
+    
+void WebResourceLoadObserver::logNavigatorAPIAccessed(const Document& document, const ResourceLoadStatistics::NavigatorAPI functionName)
+{
+#if ENABLE(WEB_API_STATISTICS)
+    if (!shouldLogResourceLoadStatistics(document.sessionID()))
+        return;
+
+    RegistrableDomain registrableDomain { document.url() };
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
+    bool shouldCallNotificationCallback = false;
+    if (!statistics.navigatorFunctionsAccessed.contains(functionName)) {
+        statistics.navigatorFunctionsAccessed.add(functionName);
+        shouldCallNotificationCallback = true;
+    }
+    RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
+    if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
+        shouldCallNotificationCallback = true;
+    if (shouldCallNotificationCallback)
+        scheduleNotificationIfNeeded();
+#else
+    UNUSED_PARAM(document);
+    UNUSED_PARAM(functionName);
+#endif
+}
+    
+void WebResourceLoadObserver::logScreenAPIAccessed(const Document& document, const ResourceLoadStatistics::ScreenAPI functionName)
+{
+#if ENABLE(WEB_API_STATISTICS)
+    if (!shouldLogResourceLoadStatistics(document.sessionID()))
+        return;
+
+    RegistrableDomain registrableDomain { document.url() };
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID, registrableDomain);
+    bool shouldCallNotificationCallback = false;
+    if (!statistics.screenFunctionsAccessed.contains(functionName)) {
+        statistics.screenFunctionsAccessed.add(functionName);
+        shouldCallNotificationCallback = true;
+    }
+    RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() };
+    if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry)
+        shouldCallNotificationCallback = true;
+    if (shouldCallNotificationCallback)
+        scheduleNotificationIfNeeded();
+#else
+    UNUSED_PARAM(document);
+    UNUSED_PARAM(functionName);
+#endif
+}
+
+void WebResourceLoadObserver::logSubresourceLoading(const Frame* frame, const ResourceRequest& newRequest, const ResourceResponse& redirectResponse)
+{
+    ASSERT(frame->page());
+
+    if (!frame)
+        return;
+
+    auto* page = frame->page();
+    if (!page || !shouldLogResourceLoadStatistics(page->sessionID()))
+        return;
+
+    bool isRedirect = is3xxRedirect(redirectResponse);
+    const URL& redirectedFromURL = redirectResponse.url();
+    const URL& targetURL = newRequest.url();
+    const URL& topFrameURL = frame ? frame->mainFrame().document()->url() : URL();
+    
+    auto targetHost = targetURL.host();
+    auto topFrameHost = topFrameURL.host();
+
+    if (targetHost.isEmpty() || topFrameHost.isEmpty() || targetHost == topFrameHost || (isRedirect && targetHost == redirectedFromURL.host()))
+        return;
+
+    RegistrableDomain targetDomain { targetURL };
+    RegistrableDomain topFrameDomain { topFrameURL };
+    RegistrableDomain redirectedFromDomain { redirectedFromURL };
+
+    if (targetDomain == topFrameDomain || (isRedirect && targetDomain == redirectedFromDomain))
+        return;
+
+    {
+        auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), targetDomain);
+        auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
+        targetStatistics.lastSeen = lastSeen;
+        targetStatistics.subresourceUnderTopFrameDomains.add(topFrameDomain);
+
+        scheduleNotificationIfNeeded();
+    }
+
+    if (isRedirect) {
+        auto& redirectingOriginStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), redirectedFromDomain);
+        redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetDomain);
+        auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(page->sessionID(), targetDomain);
+        targetStatistics.subresourceUniqueRedirectsFrom.add(redirectedFromDomain);
+
+        scheduleNotificationIfNeeded();
+    }
+}
+
+void WebResourceLoadObserver::logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL, PAL::SessionID sessionID)
+{
+    if (!shouldLogResourceLoadStatistics(sessionID))
+        return;
+
+    auto targetHost = targetURL.host();
+    auto mainFrameHost = mainFrameURL.host();
+    
+    if (targetHost.isEmpty() || mainFrameHost.isEmpty() || targetHost == mainFrameHost)
+        return;
+    
+    RegistrableDomain targetDomain { targetURL };
+    RegistrableDomain topFrameDomain { mainFrameURL };
+
+    if (targetDomain == topFrameDomain)
+        return;
+
+    auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
+
+    auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(sessionID, targetDomain);
+    targetStatistics.lastSeen = lastSeen;
+    targetStatistics.subresourceUnderTopFrameDomains.add(topFrameDomain);
+
+    scheduleNotificationIfNeeded();
+}
+
+void WebResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Document& document)
+{
+    if (!document.sessionID().isValid() || !shouldLogResourceLoadStatistics(document.sessionID()))
+        return;
+
+    auto& url = ""
+    if (url.protocolIsAbout() || url.isLocalFile() || url.isEmpty())
+        return;
+
+    RegistrableDomain topFrameDomain { url };
+    auto newTime = ResourceLoadStatistics::reduceTimeResolution(WallTime::now());
+    auto lastReportedUserInteraction = m_lastReportedUserInteractionMap.get(topFrameDomain);
+    if (newTime == lastReportedUserInteraction)
+        return;
+
+    m_lastReportedUserInteractionMap.set(topFrameDomain, newTime);
+
+    auto& statistics = ensureResourceStatisticsForRegistrableDomain(document.sessionID(), topFrameDomain);
+    statistics.hadUserInteraction = true;
+    statistics.lastSeen = newTime;
+    statistics.mostRecentUserInteractionTime = newTime;
+
+    if (auto* frame = document.frame()) {
+        if (auto* opener = frame->loader().opener()) {
+            if (auto* openerDocument = opener->document()) {
+                if (auto* openerFrame = openerDocument->frame()) {
+                    if (auto openerPageID = openerFrame->loader().client().pageID())
+                        requestStorageAccessUnderOpener(document.sessionID(), topFrameDomain, openerPageID.value(), *openerDocument);
+                }
+            }
+        }
+    }
+
+    // We notify right away in case of a user interaction instead of waiting the usual 5 seconds because we want
+    // to update cookie blocking state as quickly as possible.
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::LogUserInteraction(document.sessionID(), topFrameDomain), 0);
+
+#if !RELEASE_LOG_DISABLED
+    if (m_shouldLogUserInteraction) {
+        auto counter = ++m_loggingCounter;
+#define LOCAL_LOG(str, ...) \
+        RELEASE_LOG(ResourceLoadStatistics, "ResourceLoadObserver::logUserInteraction: counter = %" PRIu64 ": " str, counter, ##__VA_ARGS__)
+
+        auto escapeForJSON = [](String s) {
+            s.replace('\\', "\\\\").replace('"', "\\\"");
+            return s;
+        };
+        auto escapedURL = escapeForJSON(url.string());
+        auto escapedDomain = escapeForJSON(topFrameDomain.string());
+
+        LOCAL_LOG(R"({ "url": "%{public}s",)", escapedURL.utf8().data());
+        LOCAL_LOG(R"(  "domain" : "%{public}s",)", escapedDomain.utf8().data());
+        LOCAL_LOG(R"(  "until" : %f })", newTime.secondsSinceEpoch().seconds());
+
+#undef LOCAL_LOG
+    }
+#endif
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(RESOURCE_LOAD_STATISTICS)

Added: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.h (0 => 249603)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.h	2019-09-07 01:53:20 UTC (rev 249603)
@@ -0,0 +1,80 @@
+/*
+* Copyright (C) 2019 Apple Inc. All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+*
+* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+* PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#pragma once
+
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+
+#include <WebCore/PageIdentifier.h>
+#include <WebCore/ResourceLoadObserver.h>
+#include <WebCore/Timer.h>
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebResourceLoadObserver final : public WebCore::ResourceLoadObserver {
+public:
+    using PerSessionResourceLoadData = Vector<std::pair<PAL::SessionID, Vector<WebCore::ResourceLoadStatistics>>>;
+
+    WebResourceLoadObserver();
+    
+    void logSubresourceLoading(const WebCore::Frame*, const WebCore::ResourceRequest& newRequest, const WebCore::ResourceResponse& redirectResponse) final;
+    void logWebSocketLoading(const URL& targetURL, const URL& mainFrameURL, PAL::SessionID) final;
+    void logUserInteractionWithReducedTimeResolution(const WebCore::Document&) final;
+    void logFontLoad(const WebCore::Document&, const String& familyName, bool loadStatus) final;
+    void logCanvasRead(const WebCore::Document&) final;
+    void logCanvasWriteOrMeasure(const WebCore::Document&, const String& textWritten) final;
+    void logNavigatorAPIAccessed(const WebCore::Document&, const WebCore::ResourceLoadStatistics::NavigatorAPI) final;
+    void logScreenAPIAccessed(const WebCore::Document&, const WebCore::ResourceLoadStatistics::ScreenAPI) final;
+
+#if !RELEASE_LOG_DISABLED
+    void setShouldLogUserInteraction(bool shouldLogUserInteraction) final { m_shouldLogUserInteraction = shouldLogUserInteraction; }
+#endif
+
+    String statisticsForURL(PAL::SessionID, const URL&) final;
+    void updateCentralStatisticsStore() final;
+    void clearState() final;
+
+private:
+    WebCore::ResourceLoadStatistics& ensureResourceStatisticsForRegistrableDomain(PAL::SessionID, const WebCore::RegistrableDomain&);
+    void scheduleNotificationIfNeeded();
+
+    PerSessionResourceLoadData takeStatistics();
+    void requestStorageAccessUnderOpener(PAL::SessionID, const WebCore::RegistrableDomain& domainInNeedOfStorageAccess, WebCore::PageIdentifier openerPageID, WebCore::Document& openerDocument);
+
+    HashMap<PAL::SessionID, std::unique_ptr<HashMap<WebCore::RegistrableDomain, WebCore::ResourceLoadStatistics>>> m_perSessionResourceStatisticsMap;
+    HashMap<WebCore::RegistrableDomain, WTF::WallTime> m_lastReportedUserInteractionMap;
+
+    WebCore::Timer m_notificationTimer;
+
+#if !RELEASE_LOG_DISABLED
+    uint64_t m_loggingCounter { 0 };
+    bool m_shouldLogUserInteraction { false };
+#endif
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(RESOURCE_LOAD_STATISTICS)

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (249602 => 249603)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2019-09-07 00:42:34 UTC (rev 249602)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2019-09-07 01:53:20 UTC (rev 249603)
@@ -67,6 +67,7 @@
 #include "WebProcessMessages.h"
 #include "WebProcessPoolMessages.h"
 #include "WebProcessProxyMessages.h"
+#include "WebResourceLoadObserver.h"
 #include "WebSWContextManagerConnection.h"
 #include "WebSWContextManagerConnectionMessages.h"
 #include "WebServiceWorkerProvider.h"
@@ -110,7 +111,6 @@
 #include <WebCore/PlatformMediaSessionManager.h>
 #include <WebCore/ProcessWarming.h>
 #include <WebCore/RegistrableDomain.h>
-#include <WebCore/ResourceLoadObserver.h>
 #include <WebCore/ResourceLoadStatistics.h>
 #include <WebCore/RuntimeApplicationChecks.h>
 #include <WebCore/RuntimeEnabledFeatures.h>
@@ -217,16 +217,7 @@
     m_plugInAutoStartOriginHashes.add(PAL::SessionID::defaultSessionID(), HashMap<unsigned, WallTime>());
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
-    ResourceLoadObserver::shared().setStatisticsUpdatedCallback([this] (auto&& statistics) {
-        ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::ResourceLoadStatisticsUpdated(WTFMove(statistics)), 0);
-    });
-
-    ResourceLoadObserver::shared().setRequestStorageAccessUnderOpenerCallback([this] (PAL::SessionID sessionID, const RegistrableDomain& domainInNeedOfStorageAccess, PageIdentifier openerPageID, const RegistrableDomain& openerDomain) {
-        ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::RequestStorageAccessUnderOpener(sessionID, domainInNeedOfStorageAccess, openerPageID, openerDomain), 0);
-    });
-    
-    ResourceLoadObserver::shared().setLogUserInteractionNotificationCallback([this] (PAL::SessionID sessionID, const RegistrableDomain& domain) {    ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::LogUserInteraction(sessionID, domain), 0);
-    });
+    ResourceLoadObserver::setShared(*new WebResourceLoadObserver);
 #endif
     
     Gigacage::disableDisablingPrimitiveGigacageIfShouldBeEnabled();
@@ -1655,7 +1646,9 @@
 
 void WebProcess::clearResourceLoadStatistics()
 {
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
     ResourceLoadObserver::shared().clearState();
+#endif
 }
 
 RefPtr<API::Object> WebProcess::transformHandlesToObjects(API::Object* object)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to