Title: [227790] trunk/Source
Revision
227790
Author
[email protected]
Date
2018-01-30 09:44:41 -0800 (Tue, 30 Jan 2018)

Log Message

Add telemetry to track storage access API adoption
https://bugs.webkit.org/show_bug.cgi?id=182197
<rdar://problem/35803309>

Reviewed by Chris Dumez.
        
Source/WebCore:

Partial roll-out of r227755.

The original patch assumed the WebContent process kept track of user interaction. This is
only tracked in the UIProcess, so we can get rid of some of the logging code adding in
r227755.

* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::logFrameNavigation):
(WebCore::ResourceLoadObserver::logSubresourceLoading):
(WebCore::ResourceLoadObserver::setTimeToLivePartitionFree): Deleted.
(WebCore::ResourceLoadObserver::wasAccessedWithinInteractionWindow const): Deleted.
* loader/ResourceLoadObserver.h:

Source/WebKit:

This patch also handled aggregating the counts in the UIProcess, which has access to
the right data.

The original patch assumed the WebContent process kept track of user interaction. This is
only tracked in the UIProcess, so we can get rid of some of the logging code adding in
r227755.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const): Rollout of r227755 changes not
needed to track the statistics.
(WebKit::WebProcessCreationParameters::decode): Ditto.
* Shared/WebProcessCreationParameters.h:
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess): Ditto.
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::wasAccessedAsFirstPartyDueToUserInteraction): Moved from
the WebContent process, which does not keep track of user interaction.
(WebKit::WebResourceLoadStatisticsStore::mergeStatistics): Aggregate counts while processing
the statistics.
* UIProcess/WebResourceLoadStatisticsStore.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (227789 => 227790)


--- trunk/Source/WebCore/ChangeLog	2018-01-30 17:21:49 UTC (rev 227789)
+++ trunk/Source/WebCore/ChangeLog	2018-01-30 17:44:41 UTC (rev 227790)
@@ -1,3 +1,24 @@
+2018-01-30  Brent Fulgham  <[email protected]>
+
+        Add telemetry to track storage access API adoption
+        https://bugs.webkit.org/show_bug.cgi?id=182197
+        <rdar://problem/35803309>
+
+        Reviewed by Chris Dumez.
+        
+        Partial roll-out of r227755.
+
+        The original patch assumed the WebContent process kept track of user interaction. This is
+        only tracked in the UIProcess, so we can get rid of some of the logging code adding in
+        r227755.
+
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::ResourceLoadObserver::logFrameNavigation):
+        (WebCore::ResourceLoadObserver::logSubresourceLoading):
+        (WebCore::ResourceLoadObserver::setTimeToLivePartitionFree): Deleted.
+        (WebCore::ResourceLoadObserver::wasAccessedWithinInteractionWindow const): Deleted.
+        * loader/ResourceLoadObserver.h:
+
 2018-01-30  Chris Dumez  <[email protected]>
 
         Make sure we never create a WebSWClientConnection with an invalid sessionID

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (227789 => 227790)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2018-01-30 17:21:49 UTC (rev 227789)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2018-01-30 17:44:41 UTC (rev 227790)
@@ -132,16 +132,6 @@
     return WallTime::fromRawSeconds(std::floor(time.secondsSinceEpoch() / timestampResolution) * timestampResolution.seconds());
 }
 
-void ResourceLoadObserver::setTimeToLivePartitionFree(Seconds value)
-{
-    m_timeToLiveCookiePartitionFree = value;
-}
-
-bool ResourceLoadObserver::wasAccessedWithinInteractionWindow(const ResourceLoadStatistics& statistic) const
-{
-    return WallTime::now() <= statistic.mostRecentUserInteractionTime + m_timeToLiveCookiePartitionFree;
-}
-
 void ResourceLoadObserver::logFrameNavigation(const Frame& frame, const Frame& topFrame, const ResourceRequest& newRequest, const URL& redirectUrl)
 {
     ASSERT(frame.document());
@@ -181,8 +171,6 @@
         && !(areDomainsAssociated(page, targetPrimaryDomain, mainFramePrimaryDomain) || areDomainsAssociated(page, targetPrimaryDomain, sourcePrimaryDomain))) {
         auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain);
         targetStatistics.lastSeen = reduceTimeResolution(WallTime::now());
-        if (targetStatistics.hadUserInteraction && wasAccessedWithinInteractionWindow(targetStatistics))
-            targetStatistics.timesAccessedAsFirstPartyDueToUserInteraction++;
         if (targetStatistics.subframeUnderTopFrameOrigins.add(mainFramePrimaryDomain).isNewEntry)
             shouldCallNotificationCallback = true;
     }
@@ -240,8 +228,6 @@
     {
         auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain);
         targetStatistics.lastSeen = reduceTimeResolution(WallTime::now());
-        if (targetStatistics.hadUserInteraction && wasAccessedWithinInteractionWindow(targetStatistics))
-            targetStatistics.timesAccessedAsFirstPartyDueToUserInteraction++;
         if (targetStatistics.subresourceUnderTopFrameOrigins.add(mainFramePrimaryDomain).isNewEntry)
             shouldCallNotificationCallback = true;
     }

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (227789 => 227790)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.h	2018-01-30 17:21:49 UTC (rev 227789)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h	2018-01-30 17:44:41 UTC (rev 227790)
@@ -69,7 +69,6 @@
     bool shouldLogUserInteraction() const { return m_shouldLogUserInteraction; }
     void setShouldLogUserInteraction(bool shouldLogUserInteraction) { m_shouldLogUserInteraction = shouldLogUserInteraction; }
 #endif
-    WEBCORE_EXPORT void setTimeToLivePartitionFree(Seconds);
 
 private:
     ResourceLoadObserver();
@@ -76,7 +75,6 @@
 
     bool shouldLog(Page*) const;
     ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
-    bool wasAccessedWithinInteractionWindow(const ResourceLoadStatistics&) const;
 
     void scheduleNotificationIfNeeded();
     Vector<ResourceLoadStatistics> takeStatistics();
@@ -85,7 +83,6 @@
     HashMap<String, WTF::WallTime> m_lastReportedUserInteractionMap;
     WTF::Function<void (Vector<ResourceLoadStatistics>&&)> m_notificationCallback;
     Timer m_notificationTimer;
-    Seconds m_timeToLiveCookiePartitionFree { 24_h };
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
     uint64_t m_loggingCounter { 0 };
     bool m_shouldLogUserInteraction { false };

Modified: trunk/Source/WebKit/ChangeLog (227789 => 227790)


--- trunk/Source/WebKit/ChangeLog	2018-01-30 17:21:49 UTC (rev 227789)
+++ trunk/Source/WebKit/ChangeLog	2018-01-30 17:44:41 UTC (rev 227790)
@@ -1,3 +1,34 @@
+2018-01-30  Brent Fulgham  <[email protected]>
+
+        Add telemetry to track storage access API adoption
+        https://bugs.webkit.org/show_bug.cgi?id=182197
+        <rdar://problem/35803309>
+
+        Reviewed by Chris Dumez.
+        
+        This patch also handled aggregating the counts in the UIProcess, which has access to
+        the right data.
+
+        The original patch assumed the WebContent process kept track of user interaction. This is
+        only tracked in the UIProcess, so we can get rid of some of the logging code adding in
+        r227755.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const): Rollout of r227755 changes not
+        needed to track the statistics.
+        (WebKit::WebProcessCreationParameters::decode): Ditto.
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess): Ditto.
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::wasAccessedAsFirstPartyDueToUserInteraction): Moved from
+        the WebContent process, which does not keep track of user interaction.
+        (WebKit::WebResourceLoadStatisticsStore::mergeStatistics): Aggregate counts while processing
+        the statistics.
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+
 2018-01-30  Chris Dumez  <[email protected]>
 
         Make sure we never create a WebSWClientConnection with an invalid sessionID

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (227789 => 227790)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2018-01-30 17:21:49 UTC (rev 227789)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2018-01-30 17:44:41 UTC (rev 227790)
@@ -154,8 +154,6 @@
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
     encoder << shouldLogUserInteraction;
 #endif
-
-    encoder << cookiePartitionTimeToLive;
 }
 
 bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreationParameters& parameters)
@@ -402,9 +400,6 @@
         return false;
 #endif
 
-    if (!decoder.decode(parameters.cookiePartitionTimeToLive))
-        return false;
-
     return true;
 }
 

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (227789 => 227790)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2018-01-30 17:21:49 UTC (rev 227789)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2018-01-30 17:44:41 UTC (rev 227790)
@@ -188,7 +188,6 @@
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
     bool shouldLogUserInteraction { false };
 #endif
-    Seconds cookiePartitionTimeToLive;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (227789 => 227790)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2018-01-30 17:21:49 UTC (rev 227789)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2018-01-30 17:44:41 UTC (rev 227790)
@@ -279,11 +279,6 @@
 #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
     parameters.shouldLogUserInteraction = [defaults boolForKey:WebKitLogCookieInformationDefaultsKey];
 #endif
-
-    Seconds timeToLiveUserInteraction([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsTimeToLiveUserInteraction"]);
-    if (timeToLiveUserInteraction < 0_s || timeToLiveUserInteraction > 24_h * 30)
-        timeToLiveUserInteraction = 24_h;
-    parameters.cookiePartitionTimeToLive = timeToLiveUserInteraction;
 }
 
 void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (227789 => 227790)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2018-01-30 17:21:49 UTC (rev 227789)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp	2018-01-30 17:44:41 UTC (rev 227790)
@@ -757,6 +757,16 @@
     updateCookiePartitioningForDomains({ }, { }, { }, ShouldClearFirst::Yes);
 }
 
+bool WebResourceLoadStatisticsStore::wasAccessedAsFirstPartyDueToUserInteraction(const ResourceLoadStatistics& current, const ResourceLoadStatistics& updated)
+{
+    if (!current.hadUserInteraction && !updated.hadUserInteraction)
+        return false;
+
+    auto mostRecentUserInteractionTime = std::max(current.mostRecentUserInteractionTime, updated.mostRecentUserInteractionTime);
+
+    return updated.lastSeen <= mostRecentUserInteractionTime + m_parameters.timeToLiveCookiePartitionFree;
+}
+
 void WebResourceLoadStatisticsStore::mergeStatistics(Vector<ResourceLoadStatistics>&& statistics)
 {
     ASSERT(!RunLoop::isMain());
@@ -764,8 +774,11 @@
         auto result = m_resourceStatisticsMap.ensure(statistic.highLevelDomain, [&statistic] {
             return WTFMove(statistic);
         });
-        if (!result.isNewEntry)
+        if (!result.isNewEntry) {
+            if (wasAccessedAsFirstPartyDueToUserInteraction(result.iterator->value, statistic))
+                result.iterator->value.timesAccessedAsFirstPartyDueToUserInteraction++;
             result.iterator->value.merge(statistic);
+        }
     }
 }
 

Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h (227789 => 227790)


--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2018-01-30 17:21:49 UTC (rev 227789)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h	2018-01-30 17:44:41 UTC (rev 227790)
@@ -175,6 +175,8 @@
     void registerUserDefaultsIfNeeded();
 #endif
 
+    bool wasAccessedAsFirstPartyDueToUserInteraction(const WebCore::ResourceLoadStatistics& current, const WebCore::ResourceLoadStatistics& updated);
+
     struct Parameters {
         size_t pruneEntriesDownTo { 800 };
         size_t maxStatisticsEntries { 1000 };

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (227789 => 227790)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2018-01-30 17:21:49 UTC (rev 227789)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2018-01-30 17:44:41 UTC (rev 227790)
@@ -424,8 +424,6 @@
     ResourceLoadObserver::shared().setShouldLogUserInteraction(parameters.shouldLogUserInteraction);
 #endif
 
-    ResourceLoadObserver::shared().setTimeToLivePartitionFree(parameters.cookiePartitionTimeToLive);
-
     RELEASE_LOG(Process, "%p - WebProcess::initializeWebProcess: Presenting process = %d", this, WebCore::presentingApplicationPID());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to