Title: [218865] trunk/Source
Revision
218865
Author
cdu...@apple.com
Date
2017-06-27 22:14:24 -0700 (Tue, 27 Jun 2017)

Log Message

[ResourceLoadStatistics] Update minimumTimeBetweeenDataRecordsRemoval to 1 hour instead of 1 minute
https://bugs.webkit.org/show_bug.cgi?id=173895
<rdar://problem/32984366>

Reviewed by Brent Fulgham.

Update minimumTimeBetweeenDataRecordsRemoval to 1 hour instead of 1 minute to save battery.
Also port code to modern time types.

Source/WebCore:

* loader/ResourceLoadObserver.cpp:
(WebCore::reduceTimeResolution):
(WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
(WebCore::ResourceLoadObserver::setTimeToLiveUserInteraction):
(WebCore::ResourceLoadObserver::setTimeToLiveCookiePartitionFree):
(WebCore::ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval):
(WebCore::ResourceLoadObserver::setReducedTimestampResolution):
(WebCore::ResourceLoadObserver::setGrandfatheringTime):
* loader/ResourceLoadObserver.h:
* loader/ResourceLoadStatistics.h:
(WebCore::ResourceLoadStatistics::mostRecentUserInteractionTime):
* loader/ResourceLoadStatisticsStore.cpp:
(WebCore::ResourceLoadStatisticsStore::createEncoderFromData):
(WebCore::ResourceLoadStatisticsStore::readDataFromDecoder):
(WebCore::shouldPartitionCookies):
(WebCore::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
(WebCore::ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
(WebCore::ResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval):
(WebCore::ResourceLoadStatisticsStore::setGrandfatheringTime):
(WebCore::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
(WebCore::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
(WebCore::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
(WebCore::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
(WebCore::ResourceLoadStatisticsStore::dataRecordsBeingRemoved):
* loader/ResourceLoadStatisticsStore.h:

Source/WebKit2:

* UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
(WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction):
(WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree):
(WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval):
(WKResourceLoadStatisticsManagerSetGrandfatheringTime):
* UIProcess/WebResourceLoadStatisticsManager.cpp:
(WebKit::WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction):
(WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
(WebKit::WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval):
(WebKit::WebResourceLoadStatisticsManager::setGrandfatheringTime):
* UIProcess/WebResourceLoadStatisticsManager.h:
* UIProcess/WebResourceLoadStatisticsStore.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (218864 => 218865)


--- trunk/Source/WebCore/ChangeLog	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebCore/ChangeLog	2017-06-28 05:14:24 UTC (rev 218865)
@@ -1,5 +1,42 @@
 2017-06-27  Chris Dumez  <cdu...@apple.com>
 
+        [ResourceLoadStatistics] Update minimumTimeBetweeenDataRecordsRemoval to 1 hour instead of 1 minute
+        https://bugs.webkit.org/show_bug.cgi?id=173895
+        <rdar://problem/32984366>
+
+        Reviewed by Brent Fulgham.
+
+        Update minimumTimeBetweeenDataRecordsRemoval to 1 hour instead of 1 minute to save battery.
+        Also port code to modern time types.
+
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::reduceTimeResolution):
+        (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+        (WebCore::ResourceLoadObserver::setTimeToLiveUserInteraction):
+        (WebCore::ResourceLoadObserver::setTimeToLiveCookiePartitionFree):
+        (WebCore::ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval):
+        (WebCore::ResourceLoadObserver::setReducedTimestampResolution):
+        (WebCore::ResourceLoadObserver::setGrandfatheringTime):
+        * loader/ResourceLoadObserver.h:
+        * loader/ResourceLoadStatistics.h:
+        (WebCore::ResourceLoadStatistics::mostRecentUserInteractionTime):
+        * loader/ResourceLoadStatisticsStore.cpp:
+        (WebCore::ResourceLoadStatisticsStore::createEncoderFromData):
+        (WebCore::ResourceLoadStatisticsStore::readDataFromDecoder):
+        (WebCore::shouldPartitionCookies):
+        (WebCore::ResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
+        (WebCore::ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree):
+        (WebCore::ResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval):
+        (WebCore::ResourceLoadStatisticsStore::setGrandfatheringTime):
+        (WebCore::ResourceLoadStatisticsStore::hasHadRecentUserInteraction):
+        (WebCore::ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor):
+        (WebCore::ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore):
+        (WebCore::ResourceLoadStatisticsStore::shouldRemoveDataRecords):
+        (WebCore::ResourceLoadStatisticsStore::dataRecordsBeingRemoved):
+        * loader/ResourceLoadStatisticsStore.h:
+
+2017-06-27  Chris Dumez  <cdu...@apple.com>
+
         Port HysteresisActivity to Seconds type
         https://bugs.webkit.org/show_bug.cgi?id=173902
 

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (218864 => 218865)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2017-06-28 05:14:24 UTC (rev 218865)
@@ -50,8 +50,7 @@
 
 namespace WebCore {
 
-// One hour in seconds.
-static auto timestampResolution = 3600;
+static Seconds timestampResolution { 1_h };
 
 ResourceLoadObserver& ResourceLoadObserver::sharedObserver()
 {
@@ -350,9 +349,9 @@
     });
 }
 
-static double reduceTimeResolution(double seconds)
+static WallTime reduceTimeResolution(WallTime time)
 {
-    return std::floor(seconds / timestampResolution) * timestampResolution;
+    return WallTime::fromRawSeconds(std::floor(time.secondsSinceEpoch() / timestampResolution) * timestampResolution.seconds());
 }
 
 void ResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Document& document)
@@ -373,12 +372,12 @@
         {
         auto locker = holdLock(m_store->statisticsLock());
         auto& statistics = m_store->ensureResourceStatisticsForPrimaryDomain(primaryDomainString);
-        double newTimestamp = reduceTimeResolution(WTF::currentTime());
-        if (newTimestamp == statistics.mostRecentUserInteraction)
+        WallTime newTime = reduceTimeResolution(WallTime::now());
+        if (newTime == statistics.mostRecentUserInteractionTime())
             return;
 
         statistics.hadUserInteraction = true;
-        statistics.mostRecentUserInteraction = newTimestamp;
+        statistics.mostRecentUserInteraction = newTime.secondsSinceEpoch().value();
         }
         
         m_store->fireDataModificationHandler();
@@ -531,28 +530,28 @@
     });
 }
 
-void ResourceLoadObserver::setTimeToLiveUserInteraction(double seconds)
+void ResourceLoadObserver::setTimeToLiveUserInteraction(Seconds seconds)
 {
     m_store->setTimeToLiveUserInteraction(seconds);
 }
 
-void ResourceLoadObserver::setTimeToLiveCookiePartitionFree(double seconds)
+void ResourceLoadObserver::setTimeToLiveCookiePartitionFree(Seconds seconds)
 {
     m_store->setTimeToLiveCookiePartitionFree(seconds);
 }
 
-void ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval(double seconds)
+void ResourceLoadObserver::setMinimumTimeBetweeenDataRecordsRemoval(Seconds seconds)
 {
     m_store->setMinimumTimeBetweeenDataRecordsRemoval(seconds);
 }
     
-void ResourceLoadObserver::setReducedTimestampResolution(double seconds)
+void ResourceLoadObserver::setReducedTimestampResolution(Seconds seconds)
 {
-    if (seconds > 0)
+    if (seconds > 0_s)
         timestampResolution = seconds;
 }
 
-void ResourceLoadObserver::setGrandfatheringTime(double seconds)
+void ResourceLoadObserver::setGrandfatheringTime(Seconds seconds)
 {
     m_store->setMinimumTimeBetweeenDataRecordsRemoval(seconds);
 }

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.h (218864 => 218865)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.h	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.h	2017-06-28 05:14:24 UTC (rev 218865)
@@ -69,11 +69,11 @@
     WEBCORE_EXPORT void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame);
     WEBCORE_EXPORT void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo);
 
-    WEBCORE_EXPORT void setTimeToLiveUserInteraction(double seconds);
-    WEBCORE_EXPORT void setTimeToLiveCookiePartitionFree(double seconds);
-    WEBCORE_EXPORT void setMinimumTimeBetweeenDataRecordsRemoval(double seconds);
-    WEBCORE_EXPORT void setReducedTimestampResolution(double seconds);
-    WEBCORE_EXPORT void setGrandfatheringTime(double seconds);
+    WEBCORE_EXPORT void setTimeToLiveUserInteraction(Seconds);
+    WEBCORE_EXPORT void setTimeToLiveCookiePartitionFree(Seconds);
+    WEBCORE_EXPORT void setMinimumTimeBetweeenDataRecordsRemoval(Seconds);
+    WEBCORE_EXPORT void setReducedTimestampResolution(Seconds);
+    WEBCORE_EXPORT void setGrandfatheringTime(Seconds);
     
     WEBCORE_EXPORT void fireDataModificationHandler();
     WEBCORE_EXPORT void fireShouldPartitionCookiesHandler();

Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.h (218864 => 218865)


--- trunk/Source/WebCore/loader/ResourceLoadStatistics.h	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.h	2017-06-28 05:14:24 UTC (rev 218865)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include <wtf/HashCountedSet.h>
+#include <wtf/WallTime.h>
 #include <wtf/text/StringHash.h>
 #include <wtf/text/WTFString.h>
 
@@ -49,11 +50,14 @@
 
     void merge(const ResourceLoadStatistics&);
 
+    WallTime mostRecentUserInteractionTime() const { return WallTime::fromRawSeconds(mostRecentUserInteraction); }
+
     String highLevelDomain;
 
     // User interaction
     bool hadUserInteraction { false };
     // Timestamp. Default value is negative, 0 means it was reset.
+    // FIXME: Can this use WallTime?
     double mostRecentUserInteraction { -1 };
     bool grandfathered { false };
 

Modified: trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp (218864 => 218865)


--- trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.cpp	2017-06-28 05:14:24 UTC (rev 218865)
@@ -42,12 +42,11 @@
 namespace WebCore {
 
 static const auto statisticsModelVersion = 4;
-static const auto secondsPerHour = 3600;
-static const auto secondsPerDay = 24 * secondsPerHour;
-static auto timeToLiveUserInteraction = 30 * secondsPerDay;
-static auto timeToLiveCookiePartitionFree = 1 * secondsPerDay;
-static auto grandfatheringTime = 1 * secondsPerHour;
-static auto minimumTimeBetweeenDataRecordsRemoval = 60;
+static const auto secondsPerDay = 24 * 3600;
+static Seconds timeToLiveUserInteraction { 24_h * 30. };
+static Seconds timeToLiveCookiePartitionFree { 24_h };
+static Seconds grandfatheringTime { 1_h };
+static Seconds minimumTimeBetweeenDataRecordsRemoval { 1_h };
 
 Ref<ResourceLoadStatisticsStore> ResourceLoadStatisticsStore::create()
 {
@@ -90,7 +89,7 @@
 
     auto locker = holdLock(m_statisticsLock);
     encoder->encodeUInt32("version", statisticsModelVersion);
-    encoder->encodeDouble("endOfGrandfatheringTimestamp", m_endOfGrandfatheringTimestamp);
+    encoder->encodeDouble("endOfGrandfatheringTimestamp", m_endOfGrandfatheringTimestamp.secondsSinceEpoch().value());
     
     encoder->encodeObjects("browsingStatistics", m_resourceStatisticsMap.begin(), m_resourceStatisticsMap.end(), [](KeyedEncoder& encoderInner, const StatisticsValue& origin) {
         origin.value.encode(encoderInner);
@@ -114,9 +113,9 @@
     if (version > minimumVersionWithGrandfathering) {
         double endOfGrandfatheringTimestamp;
         if (decoder.decodeDouble("endOfGrandfatheringTimestamp", endOfGrandfatheringTimestamp))
-            m_endOfGrandfatheringTimestamp = endOfGrandfatheringTimestamp;
+            m_endOfGrandfatheringTimestamp = WallTime::fromRawSeconds(endOfGrandfatheringTimestamp);
         else
-            m_endOfGrandfatheringTimestamp = 0;
+            m_endOfGrandfatheringTimestamp = { };
     }
 
     Vector<ResourceLoadStatistics> loadedStatistics;
@@ -247,7 +246,7 @@
 static inline bool shouldPartitionCookies(const ResourceLoadStatistics& statistic)
 {
     return statistic.isPrevalentResource
-        && (!statistic.hadUserInteraction || currentTime() > statistic.mostRecentUserInteraction + timeToLiveCookiePartitionFree);
+        && (!statistic.hadUserInteraction || WallTime::now() > statistic.mostRecentUserInteractionTime() + timeToLiveCookiePartitionFree);
 }
 
 void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler()
@@ -301,27 +300,27 @@
         ensureResourceStatisticsForPrimaryDomain(domain).isMarkedForCookiePartitioning = true;
 }
 
-void ResourceLoadStatisticsStore::setTimeToLiveUserInteraction(double seconds)
+void ResourceLoadStatisticsStore::setTimeToLiveUserInteraction(Seconds seconds)
 {
-    if (seconds >= 0)
+    if (seconds >= 0_s)
         timeToLiveUserInteraction = seconds;
 }
 
-void ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree(double seconds)
+void ResourceLoadStatisticsStore::setTimeToLiveCookiePartitionFree(Seconds seconds)
 {
-    if (seconds >= 0)
+    if (seconds >= 0_s)
         timeToLiveCookiePartitionFree = seconds;
 }
 
-void ResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval(double seconds)
+void ResourceLoadStatisticsStore::setMinimumTimeBetweeenDataRecordsRemoval(Seconds seconds)
 {
-    if (seconds >= 0)
+    if (seconds >= 0_s)
         minimumTimeBetweeenDataRecordsRemoval = seconds;
 }
 
-void ResourceLoadStatisticsStore::setGrandfatheringTime(double seconds)
+void ResourceLoadStatisticsStore::setGrandfatheringTime(Seconds seconds)
 {
-    if (seconds >= 0)
+    if (seconds >= 0_s)
         grandfatheringTime = seconds;
 }
 
@@ -338,7 +337,7 @@
     if (!resourceStatistic.hadUserInteraction)
         return false;
 
-    if (currentTime() > resourceStatistic.mostRecentUserInteraction + timeToLiveUserInteraction) {
+    if (WallTime::now() > resourceStatistic.mostRecentUserInteractionTime() + timeToLiveUserInteraction) {
         // Drop privacy sensitive data because we no longer need it.
         // Set timestamp to 0.0 so that statistics merge will know
         // it has been reset as opposed to its default -1.
@@ -353,11 +352,11 @@
 
 Vector<String> ResourceLoadStatisticsStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor()
 {
-    bool shouldCheckForGrandfathering = m_endOfGrandfatheringTimestamp > currentTime();
+    bool shouldCheckForGrandfathering = m_endOfGrandfatheringTimestamp > WallTime::now();
     bool shouldClearGrandfathering = !shouldCheckForGrandfathering && m_endOfGrandfatheringTimestamp;
 
     if (shouldClearGrandfathering)
-        m_endOfGrandfatheringTimestamp = 0;
+        m_endOfGrandfatheringTimestamp = { };
 
     Vector<String> prevalentResources;
     auto locker = holdLock(m_statisticsLock);
@@ -421,7 +420,7 @@
         ResourceLoadStatistics& statistic = ensureResourceStatisticsForPrimaryDomain(topPrivatelyControlledDomain);
         statistic.grandfathered = true;
     }
-    m_endOfGrandfatheringTimestamp = std::floor(currentTime()) + grandfatheringTime;
+    m_endOfGrandfatheringTimestamp = WallTime::now() + grandfatheringTime;
 }
 
 bool ResourceLoadStatisticsStore::shouldRemoveDataRecords() const
@@ -430,7 +429,7 @@
     if (m_dataRecordsRemovalPending)
         return false;
 
-    if (m_lastTimeDataRecordsWereRemoved && currentTime() < m_lastTimeDataRecordsWereRemoved + minimumTimeBetweeenDataRecordsRemoval)
+    if (m_lastTimeDataRecordsWereRemoved && MonotonicTime::now() < (m_lastTimeDataRecordsWereRemoved + minimumTimeBetweeenDataRecordsRemoval))
         return false;
 
     return true;
@@ -439,7 +438,7 @@
 void ResourceLoadStatisticsStore::dataRecordsBeingRemoved()
 {
     ASSERT(!isMainThread());
-    m_lastTimeDataRecordsWereRemoved = currentTime();
+    m_lastTimeDataRecordsWereRemoved = MonotonicTime::now();
     m_dataRecordsRemovalPending = true;
 }
 

Modified: trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h (218864 => 218865)


--- trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebCore/loader/ResourceLoadStatisticsStore.h	2017-06-28 05:14:24 UTC (rev 218865)
@@ -28,7 +28,9 @@
 #include "ResourceLoadStatistics.h"
 #include <wtf/Function.h>
 #include <wtf/HashSet.h>
+#include <wtf/MonotonicTime.h>
 #include <wtf/RecursiveLockAdapter.h>
+#include <wtf/WallTime.h>
 
 namespace WebCore {
 
@@ -87,10 +89,10 @@
 
     void fireDataModificationHandler();
     void fireTelemetryHandler();
-    void setTimeToLiveUserInteraction(double seconds);
-    void setTimeToLiveCookiePartitionFree(double seconds);
-    void setMinimumTimeBetweeenDataRecordsRemoval(double seconds);
-    void setGrandfatheringTime(double seconds);    
+    void setTimeToLiveUserInteraction(Seconds);
+    void setTimeToLiveCookiePartitionFree(Seconds);
+    void setMinimumTimeBetweeenDataRecordsRemoval(Seconds);
+    void setGrandfatheringTime(Seconds);
     WEBCORE_EXPORT void fireShouldPartitionCookiesHandler();
     void fireShouldPartitionCookiesHandler(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst);
 
@@ -119,8 +121,8 @@
     WTF::Function<void()> m_grandfatherExistingWebsiteDataHandler;
     WTF::Function<void()> m_fireTelemetryHandler;
 
-    double m_endOfGrandfatheringTimestamp { 0 };
-    double m_lastTimeDataRecordsWereRemoved { 0 };
+    WallTime m_endOfGrandfatheringTimestamp;
+    MonotonicTime m_lastTimeDataRecordsWereRemoved;
     bool m_dataRecordsRemovalPending { false };
 };
     

Modified: trunk/Source/WebKit2/ChangeLog (218864 => 218865)


--- trunk/Source/WebKit2/ChangeLog	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-28 05:14:24 UTC (rev 218865)
@@ -1,5 +1,29 @@
 2017-06-27  Chris Dumez  <cdu...@apple.com>
 
+        [ResourceLoadStatistics] Update minimumTimeBetweeenDataRecordsRemoval to 1 hour instead of 1 minute
+        https://bugs.webkit.org/show_bug.cgi?id=173895
+        <rdar://problem/32984366>
+
+        Reviewed by Brent Fulgham.
+
+        Update minimumTimeBetweeenDataRecordsRemoval to 1 hour instead of 1 minute to save battery.
+        Also port code to modern time types.
+
+        * UIProcess/API/C/WKResourceLoadStatisticsManager.cpp:
+        (WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction):
+        (WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree):
+        (WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval):
+        (WKResourceLoadStatisticsManagerSetGrandfatheringTime):
+        * UIProcess/WebResourceLoadStatisticsManager.cpp:
+        (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction):
+        (WebKit::WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree):
+        (WebKit::WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval):
+        (WebKit::WebResourceLoadStatisticsManager::setGrandfatheringTime):
+        * UIProcess/WebResourceLoadStatisticsManager.h:
+        * UIProcess/WebResourceLoadStatisticsStore.h:
+
+2017-06-27  Chris Dumez  <cdu...@apple.com>
+
         Port HysteresisActivity to Seconds type
         https://bugs.webkit.org/show_bug.cgi?id=173902
 

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp (218864 => 218865)


--- trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp	2017-06-28 05:14:24 UTC (rev 218865)
@@ -28,6 +28,7 @@
 
 #include "WKAPICast.h"
 #include "WebResourceLoadStatisticsManager.h"
+#include <wtf/Seconds.h>
 
 using namespace WebKit;
 
@@ -83,22 +84,22 @@
 
 void WKResourceLoadStatisticsManagerSetTimeToLiveUserInteraction(double seconds)
 {
-    WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(seconds);
+    WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(Seconds { seconds });
 }
 
 void WKResourceLoadStatisticsManagerSetTimeToLiveCookiePartitionFree(double seconds)
 {
-    WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree(seconds);
+    WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree(Seconds { seconds });
 }
 
 void WKResourceLoadStatisticsManagerSetMinimumTimeBetweeenDataRecordsRemoval(double seconds)
 {
-    WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval(seconds);
+    WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval(Seconds { seconds });
 }
 
 void WKResourceLoadStatisticsManagerSetGrandfatheringTime(double seconds)
 {
-    WebResourceLoadStatisticsManager::setGrandfatheringTime(seconds);
+    WebResourceLoadStatisticsManager::setGrandfatheringTime(Seconds { seconds });
 }
 
 void WKResourceLoadStatisticsManagerFireDataModificationHandler()

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm (218864 => 218865)


--- trunk/Source/WebKit2/UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm	2017-06-28 05:14:24 UTC (rev 218865)
@@ -43,19 +43,19 @@
         
         double timeToLiveUserInteraction = [[NSUserDefaults standardUserDefaults] doubleForKey: WebPreferencesKey::resourceLoadStatisticsTimeToLiveUserInteractionKey()];
         if (timeToLiveUserInteraction > 0 && timeToLiveUserInteraction <= 30 * dayInSeconds)
-            ResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(timeToLiveUserInteraction);
+            ResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(Seconds { timeToLiveUserInteraction });
         
         double timeToLiveCookiePartitionFree = [[NSUserDefaults standardUserDefaults] doubleForKey: WebPreferencesKey::resourceLoadStatisticsTimeToLiveCookiePartitionFreeKey()];
         if (timeToLiveCookiePartitionFree > 0 && timeToLiveCookiePartitionFree <= dayInSeconds)
-            ResourceLoadObserver::sharedObserver().setTimeToLiveCookiePartitionFree(timeToLiveCookiePartitionFree);
+            ResourceLoadObserver::sharedObserver().setTimeToLiveCookiePartitionFree(Seconds { timeToLiveCookiePartitionFree });
         
         double reducedTimestampResolution = [[NSUserDefaults standardUserDefaults] doubleForKey: WebPreferencesKey::resourceLoadStatisticsReducedTimestampResolutionKey()];
         if (reducedTimestampResolution > 0 && reducedTimestampResolution <= hourInSeconds)
-            ResourceLoadObserver::sharedObserver().setReducedTimestampResolution(reducedTimestampResolution);
+            ResourceLoadObserver::sharedObserver().setReducedTimestampResolution(Seconds { reducedTimestampResolution });
 
         double grandfatheringTime = [[NSUserDefaults standardUserDefaults] doubleForKey: WebPreferencesKey::resourceLoadStatisticsGrandfatheringTimeKey()];
         if (grandfatheringTime > 0 && grandfatheringTime <= 7 * dayInSeconds)
-            ResourceLoadObserver::sharedObserver().setGrandfatheringTime(grandfatheringTime);
+            ResourceLoadObserver::sharedObserver().setGrandfatheringTime(Seconds { grandfatheringTime });
     });
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp (218864 => 218865)


--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp	2017-06-28 05:14:24 UTC (rev 218865)
@@ -86,22 +86,22 @@
     WebCore::ResourceLoadObserver::sharedObserver().setSubresourceUniqueRedirectTo(URL(URL(), hostName), URL(URL(), hostNameRedirectedTo));
 }
 
-void WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(double seconds)
+void WebResourceLoadStatisticsManager::setTimeToLiveUserInteraction(Seconds seconds)
 {
     WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(seconds);
 }
 
-void WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree(double seconds)
+void WebResourceLoadStatisticsManager::setTimeToLiveCookiePartitionFree(Seconds seconds)
 {
     WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveCookiePartitionFree(seconds);
 }
 
-void WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval(double seconds)
+void WebResourceLoadStatisticsManager::setMinimumTimeBetweeenDataRecordsRemoval(Seconds seconds)
 {
     WebCore::ResourceLoadObserver::sharedObserver().setMinimumTimeBetweeenDataRecordsRemoval(seconds);
 }
 
-void WebResourceLoadStatisticsManager::setGrandfatheringTime(double seconds)
+void WebResourceLoadStatisticsManager::setGrandfatheringTime(Seconds seconds)
 {
     WebCore::ResourceLoadObserver::sharedObserver().setGrandfatheringTime(seconds);
 }
@@ -156,10 +156,10 @@
     
 void WebResourceLoadStatisticsManager::resetToConsistentState()
 {
-    WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(2592000);
-    WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveCookiePartitionFree(86400);
-    WebCore::ResourceLoadObserver::sharedObserver().setMinimumTimeBetweeenDataRecordsRemoval(60);
-    WebCore::ResourceLoadObserver::sharedObserver().setGrandfatheringTime(3600);
+    WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveUserInteraction(24_h * 30.);
+    WebCore::ResourceLoadObserver::sharedObserver().setTimeToLiveCookiePartitionFree(24_h);
+    WebCore::ResourceLoadObserver::sharedObserver().setMinimumTimeBetweeenDataRecordsRemoval(1_h);
+    WebCore::ResourceLoadObserver::sharedObserver().setGrandfatheringTime(1_h);
     WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(false);
     WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(false);
     WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(true);

Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h (218864 => 218865)


--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h	2017-06-28 05:14:24 UTC (rev 218865)
@@ -28,6 +28,7 @@
 #include "APIObject.h"
 
 #include <wtf/RefPtr.h>
+#include <wtf/Seconds.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
@@ -47,11 +48,11 @@
     static void setSubframeUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
     static void setSubresourceUnderTopFrameOrigin(const String& hostName, const String& topFrameHostName);
     static void setSubresourceUniqueRedirectTo(const String& hostName, const String& hostNameRedirectedTo);
-    static void setTimeToLiveUserInteraction(double seconds);
-    static void setTimeToLiveCookiePartitionFree(double seconds);
-    static void setMinimumTimeBetweeenDataRecordsRemoval(double seconds);
-    static void setGrandfatheringTime(double seconds);
-    static void setReducedTimestampResolution(double seconds);
+    static void setTimeToLiveUserInteraction(Seconds);
+    static void setTimeToLiveCookiePartitionFree(Seconds);
+    static void setMinimumTimeBetweeenDataRecordsRemoval(Seconds);
+    static void setGrandfatheringTime(Seconds);
+    static void setReducedTimestampResolution(Seconds);
     static void fireDataModificationHandler();
     static void fireShouldPartitionCookiesHandler();
     static void fireShouldPartitionCookiesHandlerForOneDomain(const String& hostName, bool value);

Modified: trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h (218864 => 218865)


--- trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h	2017-06-28 05:06:03 UTC (rev 218864)
+++ trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h	2017-06-28 05:14:24 UTC (rev 218865)
@@ -59,7 +59,7 @@
     static Ref<WebResourceLoadStatisticsStore> create(const String&);
     static void setNotifyPagesWhenDataRecordsWereScanned(bool);
     static void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
-    static void setMinimumTimeBetweeenDataRecordsRemoval(double);
+    static void setMinimumTimeBetweeenDataRecordsRemoval(Seconds);
     virtual ~WebResourceLoadStatisticsStore();
     
     void setResourceLoadStatisticsEnabled(bool);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to