Title: [219242] trunk/Source/WebKit2
Revision
219242
Author
cdu...@apple.com
Date
2017-07-06 22:19:14 -0700 (Thu, 06 Jul 2017)

Log Message

Fix bad usage of static variables in ResourceLoadStatisticsStore
https://bugs.webkit.org/show_bug.cgi?id=174237

Reviewed by Brent Fulgham.

Fix bad usage of static variables in ResourceLoadStatisticsStore. Those can be set via
member functions on ResourceLoadStatisticsStore so they should be data members. The
API to set them is associated to a particular store and there can in theory be several
stores.

* UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
(WebKit::ResourceLoadStatisticsStore::shouldPartitionCookies):
(WebKit::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
(WebKit::ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
(WebKit::ResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
(WebKit::ResourceLoadStatisticsStore::setGrandfatheringTime):
(WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
(WebKit::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
(WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
(WebKit::shouldPartitionCookies): Deleted.
* UIProcess/Storage/ResourceLoadStatisticsStore.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (219241 => 219242)


--- trunk/Source/WebKit2/ChangeLog	2017-07-07 05:18:57 UTC (rev 219241)
+++ trunk/Source/WebKit2/ChangeLog	2017-07-07 05:19:14 UTC (rev 219242)
@@ -1,3 +1,27 @@
+2017-07-06  Chris Dumez  <cdu...@apple.com>
+
+        Fix bad usage of static variables in ResourceLoadStatisticsStore
+        https://bugs.webkit.org/show_bug.cgi?id=174237
+
+        Reviewed by Brent Fulgham.
+
+        Fix bad usage of static variables in ResourceLoadStatisticsStore. Those can be set via
+        member functions on ResourceLoadStatisticsStore so they should be data members. The
+        API to set them is associated to a particular store and there can in theory be several
+        stores.
+
+        * UIProcess/Storage/ResourceLoadStatisticsStore.cpp:
+        (WebKit::ResourceLoadStatisticsStore::shouldPartitionCookies):
+        (WebKit::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
+        (WebKit::ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
+        (WebKit::ResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval):
+        (WebKit::ResourceLoadStatisticsStore::setGrandfatheringTime):
+        (WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
+        (WebKit::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
+        (WebKit::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
+        (WebKit::shouldPartitionCookies): Deleted.
+        * UIProcess/Storage/ResourceLoadStatisticsStore.h:
+
 2017-07-05  Yusuke Suzuki  <utatane....@gmail.com>
 
         [WTF] Implement WTF::ThreadGroup

Modified: trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.cpp (219241 => 219242)


--- trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.cpp	2017-07-07 05:18:57 UTC (rev 219241)
+++ trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.cpp	2017-07-07 05:19:14 UTC (rev 219242)
@@ -39,11 +39,7 @@
 
 using namespace WebCore;
 
-static const auto statisticsModelVersion = 5;
-static Seconds timeToLiveUserInteraction { 24_h * 30. };
-static Seconds timeToLiveCookiePartitionFree { 24_h };
-static Seconds grandfatheringTime { 1_h };
-static Seconds minimumTimeBetweenDataRecordsRemoval { 1_h };
+const unsigned statisticsModelVersion { 5 };
 
 Ref<ResourceLoadStatisticsStore> ResourceLoadStatisticsStore::create()
 {
@@ -207,9 +203,9 @@
         m_fireTelemetryHandler();
 }
     
-static inline bool shouldPartitionCookies(const ResourceLoadStatistics& statistic)
+inline bool ResourceLoadStatisticsStore::shouldPartitionCookies(const ResourceLoadStatistics& statistic) const
 {
-    return statistic.isPrevalentResource && (!statistic.hadUserInteraction || WallTime::now() > statistic.mostRecentUserInteractionTime + timeToLiveCookiePartitionFree);
+    return statistic.isPrevalentResource && (!statistic.hadUserInteraction || WallTime::now() > statistic.mostRecentUserInteractionTime + m_timeToLiveCookiePartitionFree);
 }
 
 void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler()
@@ -263,26 +259,26 @@
 
 void ResourceLoadStatisticsStore::setTimeToLiveUserInteraction(Seconds seconds)
 {
-    if (seconds >= 0_s)
-        timeToLiveUserInteraction = seconds;
+    ASSERT(seconds >= 0_s);
+    m_timeToLiveUserInteraction = seconds;
 }
 
 void ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree(Seconds seconds)
 {
-    if (seconds >= 0_s)
-        timeToLiveCookiePartitionFree = seconds;
+    ASSERT(seconds >= 0_s);
+    m_timeToLiveCookiePartitionFree = seconds;
 }
 
 void ResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds)
 {
-    if (seconds >= 0_s)
-        minimumTimeBetweenDataRecordsRemoval = seconds;
+    ASSERT(seconds >= 0_s);
+    m_minimumTimeBetweenDataRecordsRemoval = seconds;
 }
 
 void ResourceLoadStatisticsStore::setGrandfatheringTime(Seconds seconds)
 {
-    if (seconds >= 0_s)
-        grandfatheringTime = seconds;
+    ASSERT(seconds >= 0_s);
+    m_grandfatheringTime = seconds;
 }
 
 void ResourceLoadStatisticsStore::processStatistics(WTF::Function<void(ResourceLoadStatistics&)>&& processFunction)
@@ -297,7 +293,7 @@
     if (!resourceStatistic.hadUserInteraction)
         return false;
 
-    if (WallTime::now() > resourceStatistic.mostRecentUserInteractionTime + timeToLiveUserInteraction) {
+    if (WallTime::now() > resourceStatistic.mostRecentUserInteractionTime + m_timeToLiveUserInteraction) {
         // Drop privacy sensitive data because we no longer need it.
         // Set timestamp to 0 so that statistics merge will know
         // it has been reset as opposed to its default -1.
@@ -380,7 +376,7 @@
         ResourceLoadStatistics& statistic = ensureResourceStatisticsForPrimaryDomain(topPrivatelyControlledDomain);
         statistic.grandfathered = true;
     }
-    m_endOfGrandfatheringTimestamp = WallTime::now() + grandfatheringTime;
+    m_endOfGrandfatheringTimestamp = WallTime::now() + m_grandfatheringTime;
 }
 
 bool ResourceLoadStatisticsStore::shouldRemoveDataRecords() const
@@ -389,7 +385,7 @@
     if (m_dataRecordsRemovalPending)
         return false;
 
-    if (m_lastTimeDataRecordsWereRemoved && MonotonicTime::now() < (m_lastTimeDataRecordsWereRemoved + minimumTimeBetweenDataRecordsRemoval))
+    if (m_lastTimeDataRecordsWereRemoved && MonotonicTime::now() < (m_lastTimeDataRecordsWereRemoved + m_minimumTimeBetweenDataRecordsRemoval))
         return false;
 
     return true;

Modified: trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h (219241 => 219242)


--- trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h	2017-07-07 05:18:57 UTC (rev 219241)
+++ trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h	2017-07-07 05:19:14 UTC (rev 219242)
@@ -103,6 +103,8 @@
 private:
     ResourceLoadStatisticsStore() = default;
 
+    bool shouldPartitionCookies(const WebCore::ResourceLoadStatistics&) const;
+
     HashMap<String, WebCore::ResourceLoadStatistics> m_resourceStatisticsMap;
 
     WTF::Function<void()> m_dataAddedHandler;
@@ -111,6 +113,11 @@
     WTF::Function<void()> m_deletePersistentStoreHandler;
     WTF::Function<void()> m_fireTelemetryHandler;
 
+    Seconds m_timeToLiveUserInteraction { 24_h * 30. };
+    Seconds m_timeToLiveCookiePartitionFree { 24_h };
+    Seconds m_grandfatheringTime { 1_h };
+    Seconds m_minimumTimeBetweenDataRecordsRemoval { 1_h };
+
     WallTime m_endOfGrandfatheringTimestamp;
     MonotonicTime m_lastTimeDataRecordsWereRemoved;
     bool m_dataRecordsRemovalPending { false };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to