- Revision
- 175982
- Author
- [email protected]
- Date
- 2014-11-11 15:13:05 -0800 (Tue, 11 Nov 2014)
Log Message
DRT and WKTR touch disk cache
https://bugs.webkit.org/show_bug.cgi?id=138622
Reviewed by Geoffrey Garen.
Source/WebKit2:
Setting a cache model has a very strange behavior in WebKit2, where it ignores
sizes that were explicitly passed from UI process, and uses different ones. As
setCacheModel() is always called on launch, it always creates a non-empty disk cache.
The design needs to be improved one day, but for now, just make sure that we never
create a disk cache during testing.
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::NetworkProcess):
(WebKit::NetworkProcess::initializeNetworkProcess):
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
(WebKit::NetworkProcess::platformSetCacheModel):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::initializeWebProcess):
* WebProcess/WebProcess.h:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformSetCacheModel):
(WebKit::WebProcess::platformInitializeWebProcess):
Tools:
* DumpRenderTree/mac/DumpRenderTree.mm: (prepareConsistentTestingEnvironment):
Set a shared cache before calling -_switchNetworkLoaderToNewTestingSession, not after,
because this function uses the shared cache.
* WebKitTestRunner/mac/TestControllerMac.mm: (WTR::TestController::platformInitializeContext):
Create an empty shared cache to prevent a default one from being created on disk.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (175981 => 175982)
--- trunk/Source/WebKit2/ChangeLog 2014-11-11 23:11:28 UTC (rev 175981)
+++ trunk/Source/WebKit2/ChangeLog 2014-11-11 23:13:05 UTC (rev 175982)
@@ -1,3 +1,32 @@
+2014-11-11 Alexey Proskuryakov <[email protected]>
+
+ DRT and WKTR touch disk cache
+ https://bugs.webkit.org/show_bug.cgi?id=138622
+
+ Reviewed by Geoffrey Garen.
+
+ Setting a cache model has a very strange behavior in WebKit2, where it ignores
+ sizes that were explicitly passed from UI process, and uses different ones. As
+ setCacheModel() is always called on launch, it always creates a non-empty disk cache.
+
+ The design needs to be improved one day, but for now, just make sure that we never
+ create a disk cache during testing.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::NetworkProcess):
+ (WebKit::NetworkProcess::initializeNetworkProcess):
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+ (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
+ (WebKit::NetworkProcess::platformSetCacheModel):
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::WebProcess):
+ (WebKit::WebProcess::initializeWebProcess):
+ * WebProcess/WebProcess.h:
+ * WebProcess/cocoa/WebProcessCocoa.mm:
+ (WebKit::WebProcess::platformSetCacheModel):
+ (WebKit::WebProcess::platformInitializeWebProcess):
+
2014-11-11 Eric Carlson <[email protected]>
[iOS] a page with video in optimized fullscreen is visible
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (175981 => 175982)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2014-11-11 23:11:28 UTC (rev 175981)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2014-11-11 23:13:05 UTC (rev 175982)
@@ -67,6 +67,7 @@
NetworkProcess::NetworkProcess()
: m_hasSetCacheModel(false)
, m_cacheModel(CacheModelDocumentViewer)
+ , m_diskCacheIsDisabledForTesting(false)
, m_canHandleHTTPSServerTrustEvaluation(true)
#if PLATFORM(COCOA)
, m_clearCacheDispatchGroup(0)
@@ -161,7 +162,9 @@
memoryPressureHandler().setLowMemoryHandler(lowMemoryHandler);
memoryPressureHandler().install();
+ m_diskCacheIsDisabledForTesting = parameters.shouldUseTestingNetworkSession;
setCacheModel(static_cast<uint32_t>(parameters.cacheModel));
+
setCanHandleHTTPSServerTrustEvaluation(parameters.canHandleHTTPSServerTrustEvaluation);
#if PLATFORM(MAC) || USE(CFNETWORK)
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (175981 => 175982)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h 2014-11-11 23:11:28 UTC (rev 175981)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h 2014-11-11 23:13:05 UTC (rev 175982)
@@ -137,6 +137,7 @@
String m_diskCacheDirectory;
bool m_hasSetCacheModel;
CacheModel m_cacheModel;
+ bool m_diskCacheIsDisabledForTesting;
bool m_canHandleHTTPSServerTrustEvaluation;
typedef HashMap<const char*, std::unique_ptr<NetworkProcessSupplement>, PtrHash<const char*>> NetworkProcessSupplementMap;
Modified: trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm (175981 => 175982)
--- trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2014-11-11 23:11:28 UTC (rev 175981)
+++ trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2014-11-11 23:13:05 UTC (rev 175982)
@@ -67,6 +67,13 @@
#endif
m_diskCacheDirectory = parameters.diskCacheDirectory;
+ // FIXME: Most of what this function does for cache size gets immediately overridden by setCacheModel().
+ // - memory cache size passed from UI process is always ignored;
+ // - disk cache size passed from UI process is effectively a minimum size.
+ // One non-obvious constraint is that we need to use -setSharedURLCache: even in testing mode, to prevent creating a default one on disk later, when some other code touches the cache.
+
+ ASSERT(!m_diskCacheIsDisabledForTesting || !parameters.nsURLCacheDiskCapacity);
+
if (!m_diskCacheDirectory.isNull()) {
SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle);
#if PLATFORM(IOS)
@@ -134,10 +141,10 @@
cacheTotalCapacity, cacheMinDeadCapacity, cacheMaxDeadCapacity, deadDecodedDataDeletionInterval,
pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity);
-
NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
[nsurlCache setMemoryCapacity:urlCacheMemoryCapacity];
- [nsurlCache setDiskCapacity:std::max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
+ if (!m_diskCacheIsDisabledForTesting)
+ [nsurlCache setDiskCapacity:std::max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
}
}
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (175981 => 175982)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2014-11-11 23:11:28 UTC (rev 175981)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2014-11-11 23:13:05 UTC (rev 175982)
@@ -156,6 +156,7 @@
, m_inDidClose(false)
, m_hasSetCacheModel(false)
, m_cacheModel(CacheModelDocumentViewer)
+ , m_diskCacheIsDisabledForTesting(false)
#if PLATFORM(COCOA)
, m_compositingRenderServerPort(MACH_PORT_NULL)
, m_clearResourceCachesDispatchGroup(0)
@@ -306,6 +307,7 @@
if (!parameters.applicationCacheDirectory.isEmpty())
cacheStorage().setCacheDirectory(parameters.applicationCacheDirectory);
+ m_diskCacheIsDisabledForTesting = parameters.shouldUseTestingNetworkSession;
setCacheModel(static_cast<uint32_t>(parameters.cacheModel));
if (!parameters.languages.isEmpty())
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (175981 => 175982)
--- trunk/Source/WebKit2/WebProcess/WebProcess.h 2014-11-11 23:11:28 UTC (rev 175981)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h 2014-11-11 23:13:05 UTC (rev 175982)
@@ -315,6 +315,7 @@
bool m_hasSetCacheModel;
CacheModel m_cacheModel;
+ bool m_diskCacheIsDisabledForTesting;
#if PLATFORM(COCOA)
mach_port_t m_compositingRenderServerPort;
Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm (175981 => 175982)
--- trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm 2014-11-11 23:11:28 UTC (rev 175981)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm 2014-11-11 23:13:05 UTC (rev 175982)
@@ -121,7 +121,8 @@
NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
[nsurlCache setMemoryCapacity:urlCacheMemoryCapacity];
- [nsurlCache setDiskCapacity:std::max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
+ if (!m_diskCacheIsDisabledForTesting)
+ [nsurlCache setDiskCapacity:std::max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
}
void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear)
@@ -168,6 +169,13 @@
#endif
#endif
+ // FIXME: Most of what this function does for cache size gets immediately overridden by setCacheModel().
+ // - memory cache size passed from UI process is always ignored;
+ // - disk cache size passed from UI process is effectively a minimum size.
+ // One non-obvious constraint is that we need to use -setSharedURLCache: even in testing mode, to prevent creating a default one on disk later, when some other code touches the cache.
+
+ ASSERT(!m_diskCacheIsDisabledForTesting || !parameters.nsURLCacheDiskCapacity);
+
#if PLATFORM(IOS)
if (!parameters.uiProcessBundleIdentifier.isNull()) {
[NSURLCache setSharedURLCache:adoptNS([[NSURLCache alloc]
Modified: trunk/Tools/ChangeLog (175981 => 175982)
--- trunk/Tools/ChangeLog 2014-11-11 23:11:28 UTC (rev 175981)
+++ trunk/Tools/ChangeLog 2014-11-11 23:13:05 UTC (rev 175982)
@@ -1,3 +1,17 @@
+2014-11-11 Alexey Proskuryakov <[email protected]>
+
+ DRT and WKTR touch disk cache
+ https://bugs.webkit.org/show_bug.cgi?id=138622
+
+ Reviewed by Geoffrey Garen.
+
+ * DumpRenderTree/mac/DumpRenderTree.mm: (prepareConsistentTestingEnvironment):
+ Set a shared cache before calling -_switchNetworkLoaderToNewTestingSession, not after,
+ because this function uses the shared cache.
+
+ * WebKitTestRunner/mac/TestControllerMac.mm: (WTR::TestController::platformInitializeContext):
+ Create an empty shared cache to prevent a default one from being created on disk.
+
2014-10-07 Sergio Villar Senin <[email protected]>
[CSS Grid Layout] Limit the size of explicit/implicit grid
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (175981 => 175982)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2014-11-11 23:11:28 UTC (rev 175981)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2014-11-11 23:13:05 UTC (rev 175982)
@@ -1088,16 +1088,16 @@
[[WebPreferences standardPreferences] setAutosaves:NO];
#if !PLATFORM(IOS)
- // FIXME: We'd like to start with a clean state for every test, but this function can't be used more than once yet.
+ // +[WebPreferences _switchNetworkLoaderToNewTestingSession] calls +[NSURLCache sharedURLCache], which initializes a default cache on disk.
+ // Making the shared cache memory-only avoids touching the file system.
+ RetainPtr<NSURLCache> sharedCache =
+ adoptNS([[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024
+ diskCapacity:0
+ diskPath:nil]);
+ [NSURLCache setSharedURLCache:sharedCache.get()];
+
[WebPreferences _switchNetworkLoaderToNewTestingSession];
- NSURLCache *sharedCache =
- [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024
- diskCapacity:0
- diskPath:[libraryPathForDumpRenderTree() stringByAppendingPathComponent:@"URLCache"]];
- [NSURLCache setSharedURLCache:sharedCache];
- [sharedCache release];
-
adjustFonts();
registerMockScrollbars();
Modified: trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm (175981 => 175982)
--- trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm 2014-11-11 23:11:28 UTC (rev 175981)
+++ trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm 2014-11-11 23:13:05 UTC (rev 175982)
@@ -106,6 +106,14 @@
void TestController::platformInitializeContext()
{
+ // Testing uses a private session, which is memory only. However creating one instantiates a shared NSURLCache,
+ // and if we haven't created one yet, the default one will be created on disk.
+ // Making the shared cache memory-only avoids touching the file system.
+ RetainPtr<NSURLCache> sharedCache =
+ adoptNS([[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024
+ diskCapacity:0
+ diskPath:nil]);
+ [NSURLCache setSharedURLCache:sharedCache.get()];
}
void TestController::setHidden(bool hidden)