Title: [242603] trunk
Revision
242603
Author
[email protected]
Date
2019-03-07 11:16:38 -0800 (Thu, 07 Mar 2019)

Log Message

Resource Load Statistics: Log first-party navigations with link decoration
https://bugs.webkit.org/show_bug.cgi?id=195301
<rdar://problem/48569971>

Reviewed by Brent Fulgham.

Source/WebCore:

Test: http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration.html

This patch adds two new members to WebCore::ResourceLoadStatistics:
- topFrameLinkDecorationsFrom, a set of domains
- gotLinkDecorationFromPrevalentResource, a boolean state

* loader/ResourceLoadStatistics.cpp:
(WebCore::ResourceLoadStatistics::encode const):
(WebCore::ResourceLoadStatistics::decode):
(WebCore::ResourceLoadStatistics::toString const):
(WebCore::ResourceLoadStatistics::merge):
* loader/ResourceLoadStatistics.h:

Source/WebKit:

This patch adds a call to the network process' resource load statistics to
log cross-site navigations with link decoration. The logging checks if the
source of the navigation is a prevalent resource and if so, sets the
appropriate flag for the destination.

* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
(WebKit::ResourceLoadStatisticsDatabaseStore::createSchema):
(WebKit::ResourceLoadStatisticsDatabaseStore::logSubresourceRedirect):
(WebKit::ResourceLoadStatisticsDatabaseStore::logCrossSiteLoadWithLinkDecoration):
* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::logCrossSiteLoadWithLinkDecoration):
* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
* NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::logCrossSiteLoadWithLinkDecoration):
* NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::committedCrossSiteLoadWithLinkDecoration):
    This now receives a completion handler. This is in preparation for
    test cases where we need to log such an event and wait for it to
    finish before continuing.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::committedCrossSiteLoadWithLinkDecoration):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didCommitLoadForFrame):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::committedCrossSiteLoadWithLinkDecoration):
* UIProcess/WebProcessPool.h:

LayoutTests:

* http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration-expected.txt: Added.
* http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (242602 => 242603)


--- trunk/LayoutTests/ChangeLog	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/LayoutTests/ChangeLog	2019-03-07 19:16:38 UTC (rev 242603)
@@ -1,5 +1,16 @@
 2019-03-07  John Wilander  <[email protected]>
 
+        Resource Load Statistics: Log first-party navigations with link decoration
+        https://bugs.webkit.org/show_bug.cgi?id=195301
+        <rdar://problem/48569971>
+
+        Reviewed by Brent Fulgham.
+
+        * http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration-expected.txt: Added.
+        * http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration.html: Added.
+
+2019-03-07  John Wilander  <[email protected]>
+
         Resource Load Statistics: Make it possible to purge only script-accessible cookies
         https://bugs.webkit.org/show_bug.cgi?id=195383
         <rdar://problem/48570136>

Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration-expected.txt (0 => 242603)


--- trunk/LayoutTests/http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration-expected.txt	2019-03-07 19:16:38 UTC (rev 242603)
@@ -0,0 +1,22 @@
+Test logging of link decorated cross-site navigations from a prevalent resource.
+
+Resource load statistics:
+
+Registrable domain: localhost
+    lastSeen: 0
+    hadUserInteraction: No
+    mostRecentUserInteraction: -1
+    grandfathered: No
+    topFrameLinkDecorationsFrom:
+        127.0.0.1
+    gotLinkDecorationFromPrevalentResource: Yes    isPrevalentResource: No
+    isVeryPrevalentResource: No
+    dataRecordsRemoved: 0
+Registrable domain: 127.0.0.1
+    lastSeen: 0
+    hadUserInteraction: No
+    mostRecentUserInteraction: -1
+    grandfathered: No
+    gotLinkDecorationFromPrevalentResource: No    isPrevalentResource: Yes
+    isVeryPrevalentResource: No
+    dataRecordsRemoved: 0

Added: trunk/LayoutTests/http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration.html (0 => 242603)


--- trunk/LayoutTests/http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration.html	2019-03-07 19:16:38 UTC (rev 242603)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+</head>
+<body _onload_="setTimeout('runTest()', 0)">
+<div id="description">Test logging of link decorated cross-site navigations from a prevalent resource.</div>
+<div id="output"></div>
+<script>
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+    }
+
+    function navigateCrossOrigin() {
+        document.location.href = "" + "/resourceLoadStatistics/log-cross-site-load-with-link-decoration.html?link=decoration";
+    }
+
+    const destinationOrigin = "http://localhost:8000";
+    const prevalentResourceOrigin = "http://127.0.0.1:8000";
+    function runTest() {
+        if (document.location.origin === prevalentResourceOrigin) {
+            setEnableFeature(true, function () {
+                testRunner.setStatisticsPrevalentResource(prevalentResourceOrigin, true, function() {
+                    if (!testRunner.isStatisticsPrevalentResource(prevalentResourceOrigin))
+                        testFailed("Host did not get set as prevalent resource.");
+                    testRunner.statisticsUpdateCookieBlocking(navigateCrossOrigin);
+                });
+
+            });
+        } else {
+            testRunner.dumpResourceLoadStatistics();
+            setEnableFeature(false, function () {
+                testRunner.notifyDone();
+            });
+        }
+    }
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (242602 => 242603)


--- trunk/Source/WebCore/ChangeLog	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebCore/ChangeLog	2019-03-07 19:16:38 UTC (rev 242603)
@@ -1,3 +1,24 @@
+2019-03-07  John Wilander  <[email protected]>
+
+        Resource Load Statistics: Log first-party navigations with link decoration
+        https://bugs.webkit.org/show_bug.cgi?id=195301
+        <rdar://problem/48569971>
+
+        Reviewed by Brent Fulgham.
+
+        Test: http/tests/resourceLoadStatistics/log-cross-site-load-with-link-decoration.html
+
+        This patch adds two new members to WebCore::ResourceLoadStatistics:
+        - topFrameLinkDecorationsFrom, a set of domains
+        - gotLinkDecorationFromPrevalentResource, a boolean state
+
+        * loader/ResourceLoadStatistics.cpp:
+        (WebCore::ResourceLoadStatistics::encode const):
+        (WebCore::ResourceLoadStatistics::decode):
+        (WebCore::ResourceLoadStatistics::toString const):
+        (WebCore::ResourceLoadStatistics::merge):
+        * loader/ResourceLoadStatistics.h:
+
 2019-03-07  Simon Fraser  <[email protected]>
 
         [iOS WK] REGRESSION (r242132): Fixed position banners flicker and move when scrolling (Apple, Tesla, YouTube, Reddit)

Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp (242602 => 242603)


--- trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp	2019-03-07 19:16:38 UTC (rev 242603)
@@ -93,6 +93,8 @@
     // Top frame stats
     encodeHashSet(encoder, "topFrameUniqueRedirectsTo"_s, "domain"_s, topFrameUniqueRedirectsTo);
     encodeHashSet(encoder, "topFrameUniqueRedirectsFrom"_s, "domain"_s, topFrameUniqueRedirectsFrom);
+    encodeHashSet(encoder, "topFrameLinkDecorationsFrom"_s, "domain", topFrameLinkDecorationsFrom);
+    encoder.encodeBool("gotLinkDecorationFromPrevalentResource"_s, gotLinkDecorationFromPrevalentResource);
 
     // Subframe stats
     encodeHashSet(encoder, "subframeUnderTopFrameDomains"_s, "domain"_s, subframeUnderTopFrameDomains);
@@ -217,6 +219,12 @@
             topFrameUniqueRedirectsFrom.add(domain);
     }
 
+    if (modelVersion >= 16) {
+        decodeHashSet(decoder, "topFrameLinkDecorationsFrom", "domain", topFrameLinkDecorationsFrom);
+        if (!decoder.decodeBool("gotLinkDecorationFromPrevalentResource", gotLinkDecorationFromPrevalentResource))
+            return false;
+    }
+
     // Subframe stats
     if (modelVersion >= 15)
         decodeHashSet(decoder, "subframeUnderTopFrameDomains", "domain", subframeUnderTopFrameDomains);
@@ -422,6 +430,8 @@
     // Top frame stats
     appendHashSet(builder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo);
     appendHashSet(builder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom);
+    appendHashSet(builder, "topFrameLinkDecorationsFrom", topFrameLinkDecorationsFrom);
+    appendBoolean(builder, "gotLinkDecorationFromPrevalentResource", gotLinkDecorationFromPrevalentResource);
 
     // Subframe stats
     appendHashSet(builder, "subframeUnderTopFrameDomains", subframeUnderTopFrameDomains);
@@ -496,6 +506,8 @@
     // Top frame stats
     mergeHashSet(topFrameUniqueRedirectsTo, other.topFrameUniqueRedirectsTo);
     mergeHashSet(topFrameUniqueRedirectsFrom, other.topFrameUniqueRedirectsFrom);
+    mergeHashSet(topFrameLinkDecorationsFrom, other.topFrameLinkDecorationsFrom);
+    gotLinkDecorationFromPrevalentResource |= other.gotLinkDecorationFromPrevalentResource;
 
     // Subframe stats
     mergeHashSet(subframeUnderTopFrameDomains, other.subframeUnderTopFrameDomains);

Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.h (242602 => 242603)


--- trunk/Source/WebCore/loader/ResourceLoadStatistics.h	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.h	2019-03-07 19:16:38 UTC (rev 242603)
@@ -78,6 +78,8 @@
     // Top frame stats
     HashSet<RegistrableDomain> topFrameUniqueRedirectsTo;
     HashSet<RegistrableDomain> topFrameUniqueRedirectsFrom;
+    HashSet<RegistrableDomain> topFrameLinkDecorationsFrom;
+    bool gotLinkDecorationFromPrevalentResource { false };
 
     // Subframe stats
     HashSet<RegistrableDomain> subframeUnderTopFrameDomains;

Modified: trunk/Source/WebKit/ChangeLog (242602 => 242603)


--- trunk/Source/WebKit/ChangeLog	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/ChangeLog	2019-03-07 19:16:38 UTC (rev 242603)
@@ -1,3 +1,45 @@
+2019-03-07  John Wilander  <[email protected]>
+
+        Resource Load Statistics: Log first-party navigations with link decoration
+        https://bugs.webkit.org/show_bug.cgi?id=195301
+        <rdar://problem/48569971>
+
+        Reviewed by Brent Fulgham.
+
+        This patch adds a call to the network process' resource load statistics to
+        log cross-site navigations with link decoration. The logging checks if the
+        source of the navigation is a prevalent resource and if so, sets the
+        appropriate flag for the destination.
+
+        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+        (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
+        (WebKit::ResourceLoadStatisticsDatabaseStore::createSchema):
+        (WebKit::ResourceLoadStatisticsDatabaseStore::logSubresourceRedirect):
+        (WebKit::ResourceLoadStatisticsDatabaseStore::logCrossSiteLoadWithLinkDecoration):
+        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h:
+        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
+        (WebKit::ResourceLoadStatisticsMemoryStore::logCrossSiteLoadWithLinkDecoration):
+        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
+        * NetworkProcess/Classifier/ResourceLoadStatisticsStore.h:
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::logCrossSiteLoadWithLinkDecoration):
+        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::committedCrossSiteLoadWithLinkDecoration):
+            This now receives a completion handler. This is in preparation for
+            test cases where we need to log such an event and wait for it to
+            finish before continuing.
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::committedCrossSiteLoadWithLinkDecoration):
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didCommitLoadForFrame):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::committedCrossSiteLoadWithLinkDecoration):
+        * UIProcess/WebProcessPool.h:
+
 2019-03-07  Per Arne Vollan  <[email protected]>
 
         [iOS] Disable permissive call logging in sandbox

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (242602 => 242603)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp	2019-03-07 19:16:38 UTC (rev 242603)
@@ -75,6 +75,10 @@
     "SELECT ?, domainID FROM ObservedDomains WHERE registrableDomain = ?"_s;
 constexpr auto topFrameUniqueRedirectsFromExistsQuery = "SELECT EXISTS (SELECT 1 FROM TopFrameUniqueRedirectsFrom WHERE targetDomainID = ? "
     "AND fromDomainID = (SELECT domainID FROM ObservedDomains WHERE registrableDomain = ?))"_s;
+constexpr auto topFrameLinkDecorationsFromQuery = "INSERT INTO TopFrameLinkDecorationsFrom (fromDomainID, toDomainID) "
+    "SELECT ?, domainID FROM ObservedDomains WHERE registrableDomain = ?"_s;
+constexpr auto topFrameLinkDecorationsFromExistsQuery = "SELECT EXISTS (SELECT 1 FROM TopFrameLinkDecorationsFrom WHERE fromDomainID = ? "
+    "AND toDomainID = (SELECT domainID FROM ObservedDomains WHERE registrableDomain = ?))"_s;
 constexpr auto subframeUnderTopFrameDomainsQuery = "INSERT INTO SubframeUnderTopFrameDomains (subFrameDomainID, topFrameDomainID) "
     "SELECT ?, domainID FROM ObservedDomains WHERE registrableDomain = ?"_s;
 constexpr auto subframeUnderTopFrameDomainExistsQuery = "SELECT EXISTS (SELECT 1 FROM SubframeUnderTopFrameDomains WHERE subFrameDomainID = ? "
@@ -128,7 +132,12 @@
     "targetDomainID INTEGER NOT NULL, fromDomainID INTEGER NOT NULL, "
     "FOREIGN KEY(targetDomainID) REFERENCES TopLevelDomains(topLevelDomainID) ON DELETE CASCADE, "
     "FOREIGN KEY(fromDomainID) REFERENCES TopLevelDomains(topLevelDomainID) ON DELETE CASCADE);"_s;
-    
+
+constexpr auto createTopFrameLinkDecorationsFrom = "CREATE TABLE TopFrameLinkDecorationsFrom ("
+    "fromDomainID INTEGER NOT NULL, toDomainID INTEGER NOT NULL, "
+    "FOREIGN KEY(fromDomainID) REFERENCES TopLevelDomains(topLevelDomainID) ON DELETE CASCADE, "
+    "FOREIGN KEY(toDomainID) REFERENCES TopLevelDomains(topLevelDomainID) ON DELETE CASCADE);"_s;
+
 constexpr auto createSubframeUnderTopFrameDomains = "CREATE TABLE SubframeUnderTopFrameDomains ("
     "subFrameDomainID INTEGER NOT NULL, topFrameDomainID INTEGER NOT NULL, "
     "FOREIGN KEY(subFrameDomainID) REFERENCES ObservedDomains(domainID) ON DELETE CASCADE, "
@@ -161,6 +170,8 @@
     , m_topFrameUniqueRedirectsToExists(m_database, topFrameUniqueRedirectsToExistsQuery)
     , m_topFrameUniqueRedirectsFrom(m_database, topFrameUniqueRedirectsFromQuery)
     , m_topFrameUniqueRedirectsFromExists(m_database, topFrameUniqueRedirectsFromExistsQuery)
+    , m_topFrameLinkDecorationsFrom(m_database, topFrameLinkDecorationsFromQuery)
+    , m_topFrameLinkDecorationsFromExists(m_database, topFrameLinkDecorationsFromExistsQuery)
     , m_subframeUnderTopFrameDomains(m_database, subframeUnderTopFrameDomainsQuery)
     , m_subframeUnderTopFrameDomainExists(m_database, subframeUnderTopFrameDomainExistsQuery)
     , m_subresourceUnderTopFrameDomains(m_database, subresourceUnderTopFrameDomainsQuery)
@@ -259,6 +270,11 @@
         return false;
     }
 
+    if (!m_database.executeCommand(createTopFrameLinkDecorationsFrom)) {
+        LOG_ERROR("Could not create TopFrameLinkDecorationsFrom table in database (%i) - %s", m_database.lastError(), m_database.lastErrorMsg());
+        return false;
+    }
+    
     if (!m_database.executeCommand(createSubframeUnderTopFrameDomains)) {
         LOG_ERROR("Could not create SubframeUnderTopFrameDomains table in database (%i) - %s", m_database.lastError(), m_database.lastErrorMsg());
         return false;
@@ -966,6 +982,19 @@
         scheduleStatisticsProcessingRequestIfNecessary();
 }
 
+void ResourceLoadStatisticsDatabaseStore::logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain& fromDomain, const NavigatedToDomain& toDomain)
+{
+    ASSERT(!RunLoop::isMain());
+    ASSERT(fromDomain != toDomain);
+
+    auto fromDomainResult = ensureResourceStatisticsForRegistrableDomain(fromDomain);
+
+    if (!relationshipExists(m_topFrameLinkDecorationsFromExists, fromDomainResult.second, toDomain)) {
+        insertDomainRelationship(m_topFrameLinkDecorationsFrom, fromDomainResult.second, toDomain);
+        scheduleStatisticsProcessingRequestIfNecessary();
+    }
+}
+
 void ResourceLoadStatisticsDatabaseStore::setUserInteraction(const RegistrableDomain& domain, bool hadUserInteraction, WallTime mostRecentInteraction)
 {
     ASSERT(!RunLoop::isMain());

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h (242602 => 242603)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.h	2019-03-07 19:16:38 UTC (rev 242603)
@@ -98,6 +98,7 @@
     void logUserInteraction(const TopFrameDomain&) override;
     void logSubresourceLoading(const SubResourceDomain&, const TopFrameDomain&, WallTime lastSeen) override;
     void logSubresourceRedirect(const RedirectedFromDomain&, const RedirectedToDomain&) override;
+    void logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain&, const NavigatedToDomain&) override;
 
     void clearUserInteraction(const RegistrableDomain&) override;
     bool hasHadUserInteraction(const RegistrableDomain&) override;
@@ -174,6 +175,8 @@
     mutable WebCore::SQLiteStatement m_topFrameUniqueRedirectsToExists;
     WebCore::SQLiteStatement m_topFrameUniqueRedirectsFrom;
     mutable WebCore::SQLiteStatement m_topFrameUniqueRedirectsFromExists;
+    WebCore::SQLiteStatement m_topFrameLinkDecorationsFrom;
+    mutable WebCore::SQLiteStatement m_topFrameLinkDecorationsFromExists;
     WebCore::SQLiteStatement m_subframeUnderTopFrameDomains;
     mutable WebCore::SQLiteStatement m_subframeUnderTopFrameDomainExists;
     WebCore::SQLiteStatement m_subresourceUnderTopFrameDomains;

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp (242602 => 242603)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp	2019-03-07 19:16:38 UTC (rev 242603)
@@ -48,7 +48,7 @@
 namespace WebKit {
 using namespace WebCore;
 
-constexpr unsigned statisticsModelVersion { 15 };
+constexpr unsigned statisticsModelVersion { 16 };
 
 struct StatisticsLastSeen {
     RegistrableDomain domain;
@@ -424,6 +424,19 @@
     statistics.mostRecentUserInteractionTime = WallTime::now();
 }
 
+void ResourceLoadStatisticsMemoryStore::logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain& fromDomain, const NavigatedToDomain& toDomain)
+{
+    ASSERT(!RunLoop::isMain());
+    ASSERT(fromDomain != toDomain);
+
+    auto& toStatistics = ensureResourceStatisticsForRegistrableDomain(toDomain);
+    toStatistics.topFrameLinkDecorationsFrom.add(fromDomain);
+    
+    auto& fromStatistics = ensureResourceStatisticsForRegistrableDomain(fromDomain);
+    if (fromStatistics.isPrevalentResource)
+        toStatistics.gotLinkDecorationFromPrevalentResource = true;
+}
+
 void ResourceLoadStatisticsMemoryStore::clearUserInteraction(const RegistrableDomain& domain)
 {
     ASSERT(!RunLoop::isMain());

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h (242602 => 242603)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h	2019-03-07 19:16:38 UTC (rev 242603)
@@ -103,6 +103,7 @@
     void logUserInteraction(const TopFrameDomain&) override;
     void logSubresourceLoading(const SubResourceDomain&, const TopFrameDomain&, WallTime lastSeen) override;
     void logSubresourceRedirect(const RedirectedFromDomain&, const RedirectedToDomain&) override;
+    void logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain&, const NavigatedToDomain&) override;
 
     void clearUserInteraction(const RegistrableDomain&) override;
     bool hasHadUserInteraction(const RegistrableDomain&) override;

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h (242602 => 242603)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.h	2019-03-07 19:16:38 UTC (rev 242603)
@@ -163,6 +163,7 @@
     virtual void logUserInteraction(const TopFrameDomain&) = 0;
     virtual void logSubresourceLoading(const SubResourceDomain&, const TopFrameDomain&, WallTime lastSeen) = 0;
     virtual void logSubresourceRedirect(const RedirectedFromDomain&, const RedirectedToDomain&) = 0;
+    virtual void logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain&, const NavigatedToDomain&) = 0;
 
     virtual void clearUserInteraction(const RegistrableDomain&) = 0;
     virtual bool hasHadUserInteraction(const RegistrableDomain&) = 0;

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (242602 => 242603)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp	2019-03-07 19:16:38 UTC (rev 242603)
@@ -543,6 +543,18 @@
     });
 }
 
+void WebResourceLoadStatisticsStore::logCrossSiteLoadWithLinkDecoration(const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, CompletionHandler<void()>&& completionHandler)
+{
+    ASSERT(RunLoop::isMain());
+    ASSERT(fromDomain != toDomain);
+    
+    postTask([this, fromDomain = fromDomain.isolatedCopy(), toDomain = toDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
+        if (m_statisticsStore)
+            m_statisticsStore->logCrossSiteLoadWithLinkDecoration(fromDomain, toDomain);
+        postTaskReply(WTFMove(completionHandler));
+    });
+}
+
 void WebResourceLoadStatisticsStore::clearUserInteraction(const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler)
 {
     ASSERT(RunLoop::isMain());

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (242602 => 242603)


--- trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h	2019-03-07 19:16:38 UTC (rev 242603)
@@ -103,6 +103,7 @@
     void logWebSocketLoading(const SubResourceDomain&, const TopFrameDomain&, WallTime lastSeen, CompletionHandler<void()>&&);
     void logSubresourceLoading(const SubResourceDomain&, const TopFrameDomain&, WallTime lastSeen, CompletionHandler<void()>&&);
     void logSubresourceRedirect(const RedirectedFromDomain&, const RedirectedToDomain&, CompletionHandler<void()>&&);
+    void logCrossSiteLoadWithLinkDecoration(const NavigatedFromDomain&, const NavigatedToDomain&, CompletionHandler<void()>&&);
     void clearUserInteraction(const TopFrameDomain&, CompletionHandler<void()>&&);
     void deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<RegistrableDomain>&&, bool shouldNotifyPage, WebCore::IncludeHttpOnlyCookies, CompletionHandler<void(const HashSet<RegistrableDomain>&)>&&);
     void registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (242602 => 242603)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2019-03-07 19:16:38 UTC (rev 242603)
@@ -1187,12 +1187,22 @@
     completionHandler();
 }
 
-void NetworkProcess::committedCrossSiteLoadWithLinkDecoration(PAL::SessionID sessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, uint64_t pageID)
+void NetworkProcess::committedCrossSiteLoadWithLinkDecoration(PAL::SessionID sessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, uint64_t pageID, CompletionHandler<void()>&& completionHandler)
 {
     if (auto* networkStorageSession = storageSession(sessionID))
         networkStorageSession->committedCrossSiteLoadWithLinkDecoration(fromDomain, toDomain, pageID);
     else
         ASSERT_NOT_REACHED();
+    
+    if (auto* networkSession = this->networkSession(sessionID)) {
+        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
+            resourceLoadStatistics->logCrossSiteLoadWithLinkDecoration(fromDomain, toDomain, WTFMove(completionHandler));
+        else
+            completionHandler();
+    } else {
+        ASSERT_NOT_REACHED();
+        completionHandler();
+    }
 }
 
 void NetworkProcess::resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (242602 => 242603)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2019-03-07 19:16:38 UTC (rev 242603)
@@ -256,7 +256,7 @@
     void setTopFrameUniqueRedirectTo(PAL::SessionID, const TopFrameDomain&, const RedirectedToDomain&, CompletionHandler<void()>&&);
     void setTopFrameUniqueRedirectFrom(PAL::SessionID, const TopFrameDomain&, const RedirectedFromDomain&, CompletionHandler<void()>&&);
     void registrableDomainsWithWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&);
-    void committedCrossSiteLoadWithLinkDecoration(PAL::SessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, uint64_t pageID);
+    void committedCrossSiteLoadWithLinkDecoration(PAL::SessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, uint64_t pageID, CompletionHandler<void()>&&);
     void resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID, CompletionHandler<void()>&&);
 #endif
 

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (242602 => 242603)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2019-03-07 19:16:38 UTC (rev 242603)
@@ -132,7 +132,7 @@
     SetTopFrameUniqueRedirectTo(PAL::SessionID sessionID, WebCore::RegistrableDomain topFrameDomain, WebCore::RegistrableDomain redirectedToDomain) -> () Async
     SetTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, WebCore::RegistrableDomain topFrameDomain, WebCore::RegistrableDomain redirectedFromDomain) -> () Async
     ResetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID) -> () Async
-    CommittedCrossSiteLoadWithLinkDecoration(PAL::SessionID sessionID, WebCore::RegistrableDomain fromDomain, WebCore::RegistrableDomain toDomain, uint64_t pageID)
+    CommittedCrossSiteLoadWithLinkDecoration(PAL::SessionID sessionID, WebCore::RegistrableDomain fromDomain, WebCore::RegistrableDomain toDomain, uint64_t pageID) -> () Async
     ResetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID sessionID) -> () Async
     DeleteCookiesForTesting(PAL::SessionID sessionID, WebCore::RegistrableDomain domain, bool includeHttpOnlyCookies) -> () Async
 #endif

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (242602 => 242603)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2019-03-07 19:16:38 UTC (rev 242603)
@@ -932,6 +932,16 @@
     WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr());
 }
 
+void NetworkProcessProxy::committedCrossSiteLoadWithLinkDecoration(PAL::SessionID sessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, uint64_t pageID, CompletionHandler<void()>&& completionHandler)
+{
+    if (!canSendMessage()) {
+        completionHandler();
+        return;
+    }
+    
+    sendWithAsyncReply(Messages::NetworkProcess::CommittedCrossSiteLoadWithLinkDecoration(sessionID, fromDomain, toDomain, pageID), WTFMove(completionHandler));
+}
+
 void NetworkProcessProxy::resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
 {
     if (!canSendMessage()) {

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (242602 => 242603)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2019-03-07 19:16:38 UTC (rev 242603)
@@ -144,6 +144,7 @@
     void setResourceLoadStatisticsDebugMode(PAL::SessionID, bool debugMode, CompletionHandler<void()>&&);
     void setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID, bool, CompletionHandler<void()>&&);
     void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, CompletionHandler<void()>&&);
+    void committedCrossSiteLoadWithLinkDecoration(PAL::SessionID, const NavigatedFromDomain&, const NavigatedToDomain&, PageID, CompletionHandler<void()>&&);
     void resetCrossSiteLoadsWithLinkDecorationForTesting(PAL::SessionID, CompletionHandler<void()>&&);
     void deleteCookiesForTesting(PAL::SessionID, const RegistrableDomain&, bool includeHttpOnlyCookies, CompletionHandler<void()>&&);
 #endif

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (242602 => 242603)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-03-07 19:16:38 UTC (rev 242603)
@@ -4083,7 +4083,7 @@
             RegistrableDomain currentDomain { currentURL };
             URL requesterURL { URL(), requesterOrigin.toString() };
             if (!currentDomain.matches(requesterURL))
-                m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::CommittedCrossSiteLoadWithLinkDecoration(m_websiteDataStore->sessionID(), RegistrableDomain { requesterURL }, currentDomain, m_pageID));
+                m_process->processPool().committedCrossSiteLoadWithLinkDecoration(m_websiteDataStore->sessionID(), RegistrableDomain { requesterURL }, currentDomain, m_pageID);
         }
 #endif
     }

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (242602 => 242603)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-03-07 19:16:38 UTC (rev 242603)
@@ -2472,5 +2472,20 @@
     
     m_networkProcess->clearAdClickAttribution(sessionID, WTFMove(completionHandler));
 }
+    
+void WebProcessPool::committedCrossSiteLoadWithLinkDecoration(PAL::SessionID sessionID, const RegistrableDomain& fromDomain, const RegistrableDomain& toDomain, uint64_t pageID)
+{
+#if ENABLE(RESOURCE_LOAD_STATISTICS)
+    if (!m_networkProcess)
+        return;
 
+    m_networkProcess->committedCrossSiteLoadWithLinkDecoration(sessionID, fromDomain, toDomain, pageID, [] { });
+#else
+    UNUSED_PARAM(sessionID);
+    UNUSED_PARAM(fromDomain);
+    UNUSED_PARAM(toDomain);
+    UNUSED_PARAM(pageID);
+#endif
+}
+
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (242602 => 242603)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2019-03-07 19:11:52 UTC (rev 242602)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2019-03-07 19:16:38 UTC (rev 242603)
@@ -44,6 +44,7 @@
 #include "WebContextClient.h"
 #include "WebContextConnectionClient.h"
 #include "WebProcessProxy.h"
+#include <WebCore/RegistrableDomain.h>
 #include <WebCore/SecurityOriginHash.h>
 #include <WebCore/SharedStringHash.h>
 #include <pal/SessionID.h>
@@ -486,6 +487,7 @@
 
     void dumpAdClickAttribution(PAL::SessionID, CompletionHandler<void(const String&)>&&);
     void clearAdClickAttribution(PAL::SessionID, CompletionHandler<void()>&&);
+    void committedCrossSiteLoadWithLinkDecoration(PAL::SessionID, const WebCore::RegistrableDomain& fromDomain, const WebCore::RegistrableDomain& toDomain, uint64_t pageID);
 
 #if PLATFORM(GTK) || PLATFORM(WPE)
     void setSandboxEnabled(bool enabled) { m_sandboxEnabled = enabled; };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to