Enable network cache speculative revalidation in MiniBrowser
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Dec 2016 19:49:56 +0000 (19:49 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Dec 2016 19:49:56 +0000 (19:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165616

Reviewed by Darin Adler.

Match Safari. Also add a menu item to disable it.

* MiniBrowser/mac/AppDelegate.m:
(defaultConfiguration):
* MiniBrowser/mac/SettingsController.h:
* MiniBrowser/mac/SettingsController.m:
(-[SettingsController _populateMenu]):
(-[SettingsController validateMenuItem:]):
(-[SettingsController networkCacheSpeculativeRevalidationDisabled]):
(-[SettingsController toggleNetworkCacheSpeculativeRevalidationDisabled:]):

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

Tools/ChangeLog
Tools/MiniBrowser/mac/AppDelegate.m
Tools/MiniBrowser/mac/SettingsController.h
Tools/MiniBrowser/mac/SettingsController.m

index b3bbb84..2a260b4 100644 (file)
@@ -1,3 +1,21 @@
+2016-12-08  Antti Koivisto  <antti@apple.com>
+
+        Enable network cache speculative revalidation in MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=165616
+
+        Reviewed by Darin Adler.
+
+        Match Safari. Also add a menu item to disable it.
+
+        * MiniBrowser/mac/AppDelegate.m:
+        (defaultConfiguration):
+        * MiniBrowser/mac/SettingsController.h:
+        * MiniBrowser/mac/SettingsController.m:
+        (-[SettingsController _populateMenu]):
+        (-[SettingsController validateMenuItem:]):
+        (-[SettingsController networkCacheSpeculativeRevalidationDisabled]):
+        (-[SettingsController toggleNetworkCacheSpeculativeRevalidationDisabled:]):
+
 2016-12-12  Alexey Proskuryakov  <ap@apple.com>
 
         ChangeLogs become readonly after resolving a conflict
index 7081df5..7811b77 100644 (file)
@@ -92,12 +92,12 @@ static WKWebViewConfiguration *defaultConfiguration()
         configuration.preferences._fullScreenEnabled = YES;
         configuration.preferences._developerExtrasEnabled = YES;
 
-        if ([SettingsController shared].perWindowWebProcessesDisabled) {
-            _WKProcessPoolConfiguration *singleProcessConfiguration = [[_WKProcessPoolConfiguration alloc] init];
-            singleProcessConfiguration.maximumProcessCount = 1;
-            configuration.processPool = [[[WKProcessPool alloc] _initWithConfiguration:singleProcessConfiguration] autorelease];
-            [singleProcessConfiguration release];
-        }
+        _WKProcessPoolConfiguration *processConfiguration = [[[_WKProcessPoolConfiguration alloc] init] autorelease];
+        processConfiguration.diskCacheSpeculativeValidationEnabled = ![SettingsController shared].networkCacheSpeculativeRevalidationDisabled;
+        if ([SettingsController shared].perWindowWebProcessesDisabled)
+            processConfiguration.maximumProcessCount = 1;
+        
+        configuration.processPool = [[[WKProcessPool alloc] _initWithConfiguration:processConfiguration] autorelease];
 
 #if WK_API_ENABLED
         NSArray<_WKExperimentalFeature *> *features = [WKPreferences _experimentalFeatures];
index 0e0862b..f20fe60 100644 (file)
@@ -54,6 +54,7 @@
 @property (nonatomic, readonly) BOOL animatedImageAsyncDecodingEnabled;
 @property (nonatomic, readonly) BOOL loadsAllSiteIcons;
 @property (nonatomic, readonly) BOOL usesGameControllerFramework;
+@property (nonatomic, readonly) BOOL networkCacheSpeculativeRevalidationDisabled;
 
 @property (nonatomic, readonly) NSString *defaultURL;
 
index 6c131d4..0e1b735 100644 (file)
@@ -63,6 +63,7 @@ static NSString * const AnimatedImageAsyncDecodingEnabledPreferenceKey = @"Anima
 static NSString * const UseRemoteLayerTreeDrawingAreaPreferenceKey = @"WebKit2UseRemoteLayerTreeDrawingArea";
 
 static NSString * const PerWindowWebProcessesDisabledKey = @"PerWindowWebProcessesDisabled";
+static NSString * const NetworkCacheSpeculativeRevalidationDisabledKey = @"NetworkCacheSpeculativeRevalidationDisabled";
 
 typedef NS_ENUM(NSInteger, DebugOverylayMenuItemTag) {
     NonFastScrollableRegionOverlayTag = 100,
@@ -140,6 +141,7 @@ typedef NS_ENUM(NSInteger, DebugOverylayMenuItemTag) {
     [self _addItemWithTitle:@"Show Resource Usage Overlay" action:@selector(toggleShowResourceUsageOverlay:) indented:YES];
     [self _addItemWithTitle:@"Load All Site Icons Per-Page" action:@selector(toggleLoadsAllSiteIcons:) indented:YES];
     [self _addItemWithTitle:@"Use GameController.framework on macOS (Restart required)" action:@selector(toggleUsesGameControllerFramework:) indented:YES];
+    [self _addItemWithTitle:@"Disable network cache speculative revalidation" action:@selector(toggleNetworkCacheSpeculativeRevalidationDisabled:) indented:YES];
 
     NSMenuItem *debugOverlaysSubmenuItem = [[NSMenuItem alloc] initWithTitle:@"Debug Overlays" action:nil keyEquivalent:@""];
     NSMenu *debugOverlaysMenu = [[NSMenu alloc] initWithTitle:@"Debug Overlays"];
@@ -219,6 +221,8 @@ typedef NS_ENUM(NSInteger, DebugOverylayMenuItemTag) {
         [menuItem setState:[self loadsAllSiteIcons] ? NSOnState : NSOffState];
     else if (action == @selector(toggleUsesGameControllerFramework:))
         [menuItem setState:[self usesGameControllerFramework] ? NSOnState : NSOffState];
+    else if (action == @selector(toggleNetworkCacheSpeculativeRevalidationDisabled:))
+        [menuItem setState:[self networkCacheSpeculativeRevalidationDisabled] ? NSOnState : NSOffState];
     else if (action == @selector(toggleUseUISideCompositing:))
         [menuItem setState:[self useUISideCompositing] ? NSOnState : NSOffState];
     else if (action == @selector(togglePerWindowWebProcessesDisabled:))
@@ -386,6 +390,16 @@ typedef NS_ENUM(NSInteger, DebugOverylayMenuItemTag) {
     [self _toggleBooleanDefault:UsesGameControllerFrameworkKey];
 }
 
+- (BOOL)networkCacheSpeculativeRevalidationDisabled
+{
+    return [[NSUserDefaults standardUserDefaults] boolForKey:NetworkCacheSpeculativeRevalidationDisabledKey];
+}
+
+- (void)toggleNetworkCacheSpeculativeRevalidationDisabled:(id)sender
+{
+    [self _toggleBooleanDefault:NetworkCacheSpeculativeRevalidationDisabledKey];
+}
+
 - (BOOL)tiledScrollingIndicatorVisible
 {
     return [[NSUserDefaults standardUserDefaults] boolForKey:TiledScrollingIndicatorVisiblePreferenceKey];