[WK2][Cocoa] Allow overriding the ITP data removal internal using a default
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Jul 2017 03:07:26 +0000 (03:07 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Jul 2017 03:07:26 +0000 (03:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174802
<rdar://problem/33497898>

Reviewed by Sam Weinig.

Allow overriding the ITP data removal internal using a default to facilitate testing.
Can be used like so:
defaults write -g ResourceLoadStatisticsMinimumTimeBetweenDataRecordsRemoval 60

Will cause us to write every 60 seconds instead of 3600.

* Shared/WebPreferencesDefinitions.h:
* UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:
(WebKit::WebResourceLoadStatisticsStore::registerUserDefaultsIfNeeded):

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

Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferencesDefinitions.h
Source/WebKit/UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm

index ad39e7f766b41219b338f04538a6f468d8dc7cbf..c149acbf433d238b5cdfd79d32c4e97f5c483942 100644 (file)
@@ -1,3 +1,21 @@
+2017-07-24  Chris Dumez  <cdumez@apple.com>
+
+        [WK2][Cocoa] Allow overriding the ITP data removal internal using a default
+        https://bugs.webkit.org/show_bug.cgi?id=174802
+        <rdar://problem/33497898>
+
+        Reviewed by Sam Weinig.
+
+        Allow overriding the ITP data removal internal using a default to facilitate testing.
+        Can be used like so:
+        defaults write -g ResourceLoadStatisticsMinimumTimeBetweenDataRecordsRemoval 60
+
+        Will cause us to write every 60 seconds instead of 3600.
+
+        * Shared/WebPreferencesDefinitions.h:
+        * UIProcess/Cocoa/WebResourceLoadStatisticsStoreCocoa.mm:
+        (WebKit::WebResourceLoadStatisticsStore::registerUserDefaultsIfNeeded):
+
 2017-07-24  Simon Fraser  <simon.fraser@apple.com>
 
         [iOS WK2] Crash under PageOverlayController::uninstallPageOverlay when doing multiple finds
index 1a3696262c05e226e6aa54a3eb03ebf4d62139cb..f58ef35e5411758dfba3fcd14cbd62d015bdd3bd 100644 (file)
     macro(LayoutInterval, layoutInterval, Double, double, -1, "", "") \
     macro(MaxParseDuration, maxParseDuration, Double, double, -1, "", "") \
     macro(PasswordEchoDuration, passwordEchoDuration, Double, double, 2, "", "") \
-    macro(ResourceLoadStatisticsTimeToLiveUserInteraction, resourceLoadStatisticsTimeToLiveUserInteraction, Double, double, 2592000, "", "") \
-    macro(ResourceLoadStatisticsTimeToLiveCookiePartitionFree, resourceLoadStatisticsTimeToLiveCookiePartitionFree, Double, double, 86400, "", "") \
-    macro(ResourceLoadStatisticsReducedTimestampResolution, resourceLoadStatisticsReducedTimestampResolution, Double, double, 3600, "", "") \
-    macro(ResourceLoadStatisticsGrandfatheringTime, resourceLoadStatisticsGrandfatheringTime, Double, double, 3600, "", "") \
 \
 
 #define FOR_EACH_WEBKIT_UINT32_PREFERENCE(macro) \
index 0a5d6953dc626a2f4c7b469225656b82808cb4de..ea6cc268609027a41a2a8335c9edd5e47b7ee1ae 100644 (file)
 #include "config.h"
 #import "WebResourceLoadStatisticsStore.h"
 
-#import "WebPreferencesKeys.h"
-
-using namespace WebCore;
-
 namespace WebKit {
 
 void WebResourceLoadStatisticsStore::registerUserDefaultsIfNeeded()
@@ -37,20 +33,21 @@ void WebResourceLoadStatisticsStore::registerUserDefaultsIfNeeded()
     static dispatch_once_t initOnce;
 
     dispatch_once(&initOnce, ^ {
-        const size_t hourInSeconds = 3600;
-        const size_t dayInSeconds = 24 * hourInSeconds;
+        Seconds timeToLiveUserInteraction([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsTimeToLiveUserInteraction"]);
+        if (timeToLiveUserInteraction > 0_s && timeToLiveUserInteraction <= 24_h * 30)
+            setTimeToLiveUserInteraction(timeToLiveUserInteraction);
 
-        double timeToLiveUserInteraction = [[NSUserDefaults standardUserDefaults] doubleForKey: WebPreferencesKey::resourceLoadStatisticsTimeToLiveUserInteractionKey()];
-        if (timeToLiveUserInteraction > 0 && timeToLiveUserInteraction <= 30 * dayInSeconds)
-            setTimeToLiveUserInteraction(Seconds { timeToLiveUserInteraction });
+        Seconds timeToLiveCookiePartitionFree([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsTimeToLiveCookiePartitionFree"]);
+        if (timeToLiveCookiePartitionFree > 0_s && timeToLiveCookiePartitionFree <= 24_h)
+            setTimeToLiveCookiePartitionFree(timeToLiveCookiePartitionFree);
 
-        double timeToLiveCookiePartitionFree = [[NSUserDefaults standardUserDefaults] doubleForKey: WebPreferencesKey::resourceLoadStatisticsTimeToLiveCookiePartitionFreeKey()];
-        if (timeToLiveCookiePartitionFree > 0 && timeToLiveCookiePartitionFree <= dayInSeconds)
-            setTimeToLiveCookiePartitionFree(Seconds { timeToLiveCookiePartitionFree });
+        Seconds minimumTimeBetweenDataRecordsRemoval([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsMinimumTimeBetweenDataRecordsRemoval"]);
+        if (minimumTimeBetweenDataRecordsRemoval > 0_s && minimumTimeBetweenDataRecordsRemoval < 1_h)
+            setMinimumTimeBetweenDataRecordsRemoval(minimumTimeBetweenDataRecordsRemoval);
 
-        double grandfatheringTime = [[NSUserDefaults standardUserDefaults] doubleForKey: WebPreferencesKey::resourceLoadStatisticsGrandfatheringTimeKey()];
-        if (grandfatheringTime > 0 && grandfatheringTime <= 7 * dayInSeconds)
-            setGrandfatheringTime(Seconds { grandfatheringTime });
+        Seconds grandfatheringTime([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsGrandfatheringTime"]);
+        if (grandfatheringTime > 0_s && grandfatheringTime <= 24_h * 7)
+            setGrandfatheringTime(grandfatheringTime);
     });
 }