Add a setting to let the client toggle support for network cache speculative validation
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Mar 2016 18:46:50 +0000 (18:46 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Mar 2016 18:46:50 +0000 (18:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155622
<rdar://problem/25233209>

Reviewed by Darin Adler.

Add SPI to toggle support for network cache speculative validation.
Enable network cache speculative validation by default for now, until
I have a chance to update the clients to use the new SPI.

* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/C/WKContext.cpp:
(WKContextSetDiskCacheSpeculativeValidationEnabled):
* UIProcess/API/C/WKContextPrivate.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration diskCacheSpeculativeValidationEnabled]):
(-[_WKProcessPoolConfiguration setDiskCacheSpeculativeValidationEnabled:]):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeNetworkProcess):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h
Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm

index a1d6d10..b8d8e75 100644 (file)
@@ -1,3 +1,26 @@
+2016-03-19  Chris Dumez  <cdumez@apple.com>
+
+        Add a setting to let the client toggle support for network cache speculative validation
+        https://bugs.webkit.org/show_bug.cgi?id=155622
+        <rdar://problem/25233209>
+
+        Reviewed by Darin Adler.
+
+        Add SPI to toggle support for network cache speculative validation.
+        Enable network cache speculative validation by default for now, until
+        I have a chance to update the clients to use the new SPI.
+
+        * UIProcess/API/APIProcessPoolConfiguration.h:
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextSetDiskCacheSpeculativeValidationEnabled):
+        * UIProcess/API/C/WKContextPrivate.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+        (-[_WKProcessPoolConfiguration diskCacheSpeculativeValidationEnabled]):
+        (-[_WKProcessPoolConfiguration setDiskCacheSpeculativeValidationEnabled:]):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+
 2016-03-19  Yongjun Zhang  <yongjun_zhang@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=155664
index 5cfcc82..d22bb83 100644 (file)
@@ -50,6 +50,9 @@ public:
     unsigned maximumProcessCount() const { return m_maximumProcessCount; }
     void setMaximumProcessCount(unsigned maximumProcessCount) { m_maximumProcessCount = maximumProcessCount; } 
 
+    bool diskCacheSpeculativeValidationEnabled() const { return m_diskCacheSpeculativeValidationEnabled; }
+    void setDiskCacheSpeculativeValidationEnabled(bool enabled) { m_diskCacheSpeculativeValidationEnabled = enabled; }
+
     WebKit::CacheModel cacheModel() const { return m_cacheModel; }
     void setCacheModel(WebKit::CacheModel cacheModel) { m_cacheModel = cacheModel; }
 
@@ -93,6 +96,8 @@ private:
     bool m_shouldHaveLegacyDataStore { false };
 
     unsigned m_maximumProcessCount { 0 };
+    // FIXME: This should be disabled by default once Safari has been updated to explicitly enable it.
+    bool m_diskCacheSpeculativeValidationEnabled { true };
     WebKit::CacheModel m_cacheModel { WebKit::CacheModelPrimaryWebBrowser };
     int64_t m_diskCacheSizeOverride { -1 };
 
index da9ad03..5cf0bca 100644 (file)
@@ -392,6 +392,11 @@ void WKContextSetCanHandleHTTPSServerTrustEvaluation(WKContextRef contextRef, bo
     toImpl(contextRef)->setCanHandleHTTPSServerTrustEvaluation(value);
 }
 
+void WKContextSetDiskCacheSpeculativeValidationEnabled(WKContextRef contextRef, bool value)
+{
+    toImpl(contextRef)->configuration().setDiskCacheSpeculativeValidationEnabled(value);
+}
+
 WKCookieManagerRef WKContextGetCookieManager(WKContextRef contextRef)
 {
     return toAPI(toImpl(contextRef)->supplement<WebCookieManagerProxy>());
index 05d27fd..e8c9051 100644 (file)
@@ -60,6 +60,8 @@ WK_EXPORT void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef co
 
 WK_EXPORT void WKContextSetCanHandleHTTPSServerTrustEvaluation(WKContextRef context, bool value);
 
+WK_EXPORT void WKContextSetDiskCacheSpeculativeValidationEnabled(WKContextRef context, bool value);
+
 WK_EXPORT void WKContextSetIconDatabasePath(WKContextRef context, WKStringRef iconDatabasePath);
 
 WK_EXPORT void WKContextAllowSpecificHTTPSCertificateForHost(WKContextRef context, WKCertificateInfoRef certificate, WKStringRef host);
index 15f5674..9d10ac5 100644 (file)
@@ -36,6 +36,7 @@ WK_CLASS_AVAILABLE(10_10, 8_0)
 @property (nonatomic) NSInteger diskCacheSizeOverride WK_AVAILABLE(10_11, 9_0);
 @property (nonatomic, copy) NSArray *cachePartitionedURLSchemes;
 @property (nonatomic, copy) WK_ARRAY(NSString *) *alwaysRevalidatedURLSchemes WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+@property (nonatomic) BOOL diskCacheSpeculativeValidationEnabled WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 
 @end
 
index 8a98074..151107f 100644 (file)
     _processPoolConfiguration->setDiskCacheSizeOverride(size);
 }
 
+- (BOOL)diskCacheSpeculativeValidationEnabled
+{
+    return _processPoolConfiguration->diskCacheSpeculativeValidationEnabled();
+}
+
+- (void)setDiskCacheSpeculativeValidationEnabled:(BOOL)enabled
+{
+    _processPoolConfiguration->setDiskCacheSpeculativeValidationEnabled(enabled);
+}
+
 - (NSArray *)cachePartitionedURLSchemes
 {
     auto schemes = _processPoolConfiguration->cachePartitionedURLSchemes();
index 2662a4a..371c5b0 100644 (file)
@@ -78,9 +78,6 @@ static NSString * const WebKit2HTTPSProxyDefaultsKey = @"WebKit2HTTPSProxy";
 #if ENABLE(NETWORK_CACHE)
 static NSString * const WebKitNetworkCacheEnabledDefaultsKey = @"WebKitNetworkCacheEnabled";
 static NSString * const WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey = @"WebKitNetworkCacheEfficacyLoggingEnabled";
-#if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
-static NSString * const WebKitNetworkCacheSpeculativeRevalidationEnabledDefaultsKey = @"WebKitNetworkCacheResourceRevalidationEnabled";
-#endif
 #endif
 
 static NSString * const WebKitSuppressMemoryPressureHandlerDefaultsKey = @"WebKitSuppressMemoryPressureHandler";
@@ -105,9 +102,6 @@ static void registerUserDefaultsIfNeeded()
 #if ENABLE(NETWORK_CACHE)
     [registrationDictionary setObject:[NSNumber numberWithBool:YES] forKey:WebKitNetworkCacheEnabledDefaultsKey];
     [registrationDictionary setObject:[NSNumber numberWithBool:NO] forKey:WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey];
-#if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
-    [registrationDictionary setObject:[NSNumber numberWithBool:YES] forKey:WebKitNetworkCacheSpeculativeRevalidationEnabledDefaultsKey];
-#endif
 #endif
 
     [[NSUserDefaults standardUserDefaults] registerDefaults:registrationDictionary];
@@ -248,7 +242,7 @@ void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationPara
     parameters.shouldEnableNetworkCache = isNetworkCacheEnabled();
     parameters.shouldEnableNetworkCacheEfficacyLogging = [defaults boolForKey:WebKitNetworkCacheEfficacyLoggingEnabledDefaultsKey];
 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
-    parameters.shouldEnableNetworkCacheSpeculativeRevalidation = [defaults boolForKey:WebKitNetworkCacheSpeculativeRevalidationEnabledDefaultsKey];
+    parameters.shouldEnableNetworkCacheSpeculativeRevalidation = m_configuration->diskCacheSpeculativeValidationEnabled();
 #endif
 #endif