[ResourceLoadStatistics] Update minimumTimeBetweeenDataRecordsRemoval to 1 hour inste...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jun 2017 05:14:24 +0000 (05:14 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jun 2017 05:14:24 +0000 (05:14 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218865 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoadObserver.cpp
Source/WebCore/loader/ResourceLoadObserver.h
Source/WebCore/loader/ResourceLoadStatistics.h
Source/WebCore/loader/ResourceLoadStatisticsStore.cpp
Source/WebCore/loader/ResourceLoadStatisticsStore.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/Cocoa/WebResourceLoadStatisticsManagerCocoa.mm
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsManager.h
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h

index f780880..39186af 100644 (file)
@@ -1,5 +1,42 @@
 2017-06-27  Chris Dumez  <cdumez@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  <cdumez@apple.com>
+
         Port HysteresisActivity to Seconds type
         https://bugs.webkit.org/show_bug.cgi?id=173902
 
index 91a7d8d..f8a66f9 100644 (file)
@@ -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 @@ void ResourceLoadObserver::logWebSocketLoading(const Frame* frame, const URL& ta
     });
 }
 
-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 @@ void ResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Doc
         {
         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::setSubresourceUniqueRedirectTo(const URL& subresource
     });
 }
 
-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);
 }
index 01ac2f6..bd7590b 100644 (file)
@@ -69,11 +69,11 @@ public:
     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();
index 3583e96..c487575 100644 (file)
@@ -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 @@ struct ResourceLoadStatistics {
 
     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 };
 
index 64e7cc8..1cdb96f 100644 (file)
 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 @@ std::unique_ptr<KeyedEncoder> ResourceLoadStatisticsStore::createEncoderFromData
 
     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 @@ void ResourceLoadStatisticsStore::readDataFromDecoder(KeyedDecoder& decoder)
     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 @@ void ResourceLoadStatisticsStore::fireTelemetryHandler()
 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 @@ void ResourceLoadStatisticsStore::fireShouldPartitionCookiesHandler(const Vector
         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 @@ bool ResourceLoadStatisticsStore::hasHadRecentUserInteraction(ResourceLoadStatis
     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 @@ bool ResourceLoadStatisticsStore::hasHadRecentUserInteraction(ResourceLoadStatis
 
 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 @@ void ResourceLoadStatisticsStore::handleFreshStartWithEmptyOrNoStore(HashSet<Str
         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 @@ bool ResourceLoadStatisticsStore::shouldRemoveDataRecords() const
     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 @@ bool ResourceLoadStatisticsStore::shouldRemoveDataRecords() const
 void ResourceLoadStatisticsStore::dataRecordsBeingRemoved()
 {
     ASSERT(!isMainThread());
-    m_lastTimeDataRecordsWereRemoved = currentTime();
+    m_lastTimeDataRecordsWereRemoved = MonotonicTime::now();
     m_dataRecordsRemovalPending = true;
 }
 
index dd9ff35..90a5b18 100644 (file)
@@ -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 @@ public:
 
     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 @@ private:
     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 };
 };
     
index 7b9618a..4f51c8a 100644 (file)
@@ -1,5 +1,29 @@
 2017-06-27  Chris Dumez  <cdumez@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  <cdumez@apple.com>
+
         Port HysteresisActivity to Seconds type
         https://bugs.webkit.org/show_bug.cgi?id=173902
 
index e988d15..517d29d 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "WKAPICast.h"
 #include "WebResourceLoadStatisticsManager.h"
+#include <wtf/Seconds.h>
 
 using namespace WebKit;
 
@@ -83,22 +84,22 @@ void WKResourceLoadStatisticsManagerSetSubresourceUniqueRedirectTo(WKStringRef h
 
 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()
index d570e4f..be1d954 100644 (file)
@@ -43,19 +43,19 @@ void WebResourceLoadStatisticsManager::registerUserDefaultsIfNeeded()
         
         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 });
     });
 }
 
index a8ac182..150b387 100644 (file)
@@ -86,22 +86,22 @@ void WebResourceLoadStatisticsManager::setSubresourceUniqueRedirectTo(const Stri
     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::clearInMemoryAndPersistentStoreModifiedSi
     
 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);
index 7ccd855..5041ec8 100644 (file)
@@ -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 @@ public:
     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);
index f1fcc64..1fad18d 100644 (file)
@@ -59,7 +59,7 @@ public:
     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);