Title: [218918] trunk/Source/WebCore
Revision
218918
Author
cdu...@apple.com
Date
2017-06-28 22:43:04 -0700 (Wed, 28 Jun 2017)

Log Message

[ResourceLoadStatistics] Simplify PrevalentResourceTelemetry struct
https://bugs.webkit.org/show_bug.cgi?id=173953

Reviewed by Sam Weinig.

* loader/ResourceLoadStatisticsStore.cpp:
(WebCore::ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry):
* loader/ResourceLoadStatisticsStore.h:
(WebCore::PrevalentResourceTelemetry::PrevalentResourceTelemetry): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (218917 => 218918)


--- trunk/Source/WebCore/ChangeLog	2017-06-29 04:37:53 UTC (rev 218917)
+++ trunk/Source/WebCore/ChangeLog	2017-06-29 05:43:04 UTC (rev 218918)
@@ -1,3 +1,15 @@
+2017-06-28  Chris Dumez  <cdu...@apple.com>
+
+        [ResourceLoadStatistics] Simplify PrevalentResourceTelemetry struct
+        https://bugs.webkit.org/show_bug.cgi?id=173953
+
+        Reviewed by Sam Weinig.
+
+        * loader/ResourceLoadStatisticsStore.cpp:
+        (WebCore::ResourceLoadStatisticsStore::sortedPrevalentResourceTelemetry):
+        * loader/ResourceLoadStatisticsStore.h:
+        (WebCore::PrevalentResourceTelemetry::PrevalentResourceTelemetry): Deleted.
+
 2017-06-28  Ryosuke Niwa  <rn...@webkit.org>
 
         Crash in WebCore::ScrollingTreeFixedNode::updateLayersAfterAncestorChange

Modified: trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp (218917 => 218918)


--- trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp	2017-06-29 04:37:53 UTC (rev 218917)
+++ trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp	2017-06-29 05:43:04 UTC (rev 218918)
@@ -42,7 +42,6 @@
 namespace WebCore {
 
 static const auto statisticsModelVersion = 4;
-static const auto secondsPerDay = 24 * 3600;
 static Seconds timeToLiveUserInteraction { 24_h * 30. };
 static Seconds timeToLiveCookiePartitionFree { 24_h };
 static Seconds grandfatheringTime { 1_h };
@@ -382,24 +381,23 @@
 {
     auto locker = holdLock(m_statisticsLock);
     Vector<PrevalentResourceTelemetry> sorted;
-    
     for (auto& statistic : m_resourceStatisticsMap.values()) {
-        if (statistic.isPrevalentResource) {
-            unsigned daysSinceUserInteraction = statistic.mostRecentUserInteraction <= 0 ? 0 :
-                std::floor((currentTime() - statistic.mostRecentUserInteraction) / secondsPerDay);
-            sorted.append(PrevalentResourceTelemetry(
-                statistic.dataRecordsRemoved,
-                statistic.hadUserInteraction,
-                daysSinceUserInteraction,
-                statistic.subframeUnderTopFrameOrigins.size(),
-                statistic.subresourceUnderTopFrameOrigins.size(),
-                statistic.subresourceUniqueRedirectsTo.size()
-            ));
-        }
+        if (!statistic.isPrevalentResource)
+            continue;
+
+        unsigned daysSinceUserInteraction = statistic.mostRecentUserInteraction <= 0 ? 0 : std::floor((WallTime::now() - statistic.mostRecentUserInteractionTime()) / 24_h);
+        sorted.append(PrevalentResourceTelemetry {
+            statistic.dataRecordsRemoved,
+            statistic.hadUserInteraction,
+            daysSinceUserInteraction,
+            statistic.subframeUnderTopFrameOrigins.size(),
+            statistic.subresourceUnderTopFrameOrigins.size(),
+            statistic.subresourceUniqueRedirectsTo.size()
+        });
     }
     
     if (sorted.size() < minimumPrevalentResourcesForTelemetry)
-        return Vector<PrevalentResourceTelemetry>();
+        return { };
 
     std::sort(sorted.begin(), sorted.end(), [](const PrevalentResourceTelemetry& a, const PrevalentResourceTelemetry& b) {
         return a.subframeUnderTopFrameOrigins + a.subresourceUnderTopFrameOrigins + a.subresourceUniqueRedirectsTo >

Modified: trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h (218917 => 218918)


--- trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h	2017-06-29 04:37:53 UTC (rev 218917)
+++ trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h	2017-06-29 05:43:04 UTC (rev 218918)
@@ -39,7 +39,7 @@
 class URL;
 
 static const auto minimumPrevalentResourcesForTelemetry = 3;
-    
+
 struct PrevalentResourceTelemetry {
     unsigned numberOfTimesDataRecordsRemoved;
     bool hasHadUserInteraction;
@@ -47,16 +47,8 @@
     unsigned subframeUnderTopFrameOrigins;
     unsigned subresourceUnderTopFrameOrigins;
     unsigned subresourceUniqueRedirectsTo;
-    PrevalentResourceTelemetry()
-        : numberOfTimesDataRecordsRemoved(0), hasHadUserInteraction(0), daysSinceUserInteraction(0), subframeUnderTopFrameOrigins(0), subresourceUnderTopFrameOrigins(0), subresourceUniqueRedirectsTo(0)
-    {
-    }
-    PrevalentResourceTelemetry(unsigned recordsRemoved, bool userInteraction, unsigned daysSince, unsigned subframe, unsigned subresource, unsigned uniqueRedirects)
-        : numberOfTimesDataRecordsRemoved(recordsRemoved), hasHadUserInteraction(userInteraction), daysSinceUserInteraction(daysSince), subframeUnderTopFrameOrigins(subframe), subresourceUnderTopFrameOrigins(subresource), subresourceUniqueRedirectsTo(uniqueRedirects)
-    {
-    }
 };
-    
+
 struct ResourceLoadStatistics;
 
 class ResourceLoadStatisticsStore : public ThreadSafeRefCounted<ResourceLoadStatisticsStore> {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to