⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 175982 in webkit


Ignore:
Timestamp:
Nov 11, 2014, 3:13:05 PM (12 years ago)
Author:
ap@apple.com
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.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r175980 r175982  
     12014-11-11  Alexey Proskuryakov  <ap@apple.com>
     2
     3        DRT and WKTR touch disk cache
     4        https://bugs.webkit.org/show_bug.cgi?id=138622
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Setting a cache model has a very strange behavior in WebKit2, where it ignores
     9        sizes that were explicitly passed from UI process, and uses different ones. As
     10        setCacheModel() is always called on launch, it always creates a non-empty disk cache.
     11
     12        The design needs to be improved one day, but for now, just make sure that we never
     13        create a disk cache during testing.
     14
     15        * NetworkProcess/NetworkProcess.cpp:
     16        (WebKit::NetworkProcess::NetworkProcess):
     17        (WebKit::NetworkProcess::initializeNetworkProcess):
     18        * NetworkProcess/NetworkProcess.h:
     19        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
     20        (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
     21        (WebKit::NetworkProcess::platformSetCacheModel):
     22        * WebProcess/WebProcess.cpp:
     23        (WebKit::WebProcess::WebProcess):
     24        (WebKit::WebProcess::initializeWebProcess):
     25        * WebProcess/WebProcess.h:
     26        * WebProcess/cocoa/WebProcessCocoa.mm:
     27        (WebKit::WebProcess::platformSetCacheModel):
     28        (WebKit::WebProcess::platformInitializeWebProcess):
     29
    1302014-11-11  Eric Carlson  <eric.carlson@apple.com>
    231
  • trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp

    r174987 r175982  
    6868    : m_hasSetCacheModel(false)
    6969    , m_cacheModel(CacheModelDocumentViewer)
     70    , m_diskCacheIsDisabledForTesting(false)
    7071    , m_canHandleHTTPSServerTrustEvaluation(true)
    7172#if PLATFORM(COCOA)
     
    162163    memoryPressureHandler().install();
    163164
     165    m_diskCacheIsDisabledForTesting = parameters.shouldUseTestingNetworkSession;
    164166    setCacheModel(static_cast<uint32_t>(parameters.cacheModel));
     167
    165168    setCanHandleHTTPSServerTrustEvaluation(parameters.canHandleHTTPSServerTrustEvaluation);
    166169
  • trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h

    r174987 r175982  
    138138    bool m_hasSetCacheModel;
    139139    CacheModel m_cacheModel;
     140    bool m_diskCacheIsDisabledForTesting;
    140141    bool m_canHandleHTTPSServerTrustEvaluation;
    141142
  • trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm

    r172500 r175982  
    6868    m_diskCacheDirectory = parameters.diskCacheDirectory;
    6969
     70    // FIXME: Most of what this function does for cache size gets immediately overridden by setCacheModel().
     71    // - memory cache size passed from UI process is always ignored;
     72    // - disk cache size passed from UI process is effectively a minimum size.
     73    // 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.
     74
     75    ASSERT(!m_diskCacheIsDisabledForTesting || !parameters.nsURLCacheDiskCapacity);
     76
    7077    if (!m_diskCacheDirectory.isNull()) {
    7178        SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle);
     
    135142        pageCacheCapacity, urlCacheMemoryCapacity, urlCacheDiskCapacity);
    136143
    137 
    138144    NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
    139145    [nsurlCache setMemoryCapacity:urlCacheMemoryCapacity];
    140     [nsurlCache setDiskCapacity:std::max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
     146    if (!m_diskCacheIsDisabledForTesting)
     147        [nsurlCache setDiskCapacity:std::max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
    141148}
    142149
  • trunk/Source/WebKit2/WebProcess/WebProcess.cpp

    r175719 r175982  
    157157    , m_hasSetCacheModel(false)
    158158    , m_cacheModel(CacheModelDocumentViewer)
     159    , m_diskCacheIsDisabledForTesting(false)
    159160#if PLATFORM(COCOA)
    160161    , m_compositingRenderServerPort(MACH_PORT_NULL)
     
    307308        cacheStorage().setCacheDirectory(parameters.applicationCacheDirectory);
    308309
     310    m_diskCacheIsDisabledForTesting = parameters.shouldUseTestingNetworkSession;
    309311    setCacheModel(static_cast<uint32_t>(parameters.cacheModel));
    310312
  • trunk/Source/WebKit2/WebProcess/WebProcess.h

    r175719 r175982  
    316316    bool m_hasSetCacheModel;
    317317    CacheModel m_cacheModel;
     318    bool m_diskCacheIsDisabledForTesting;
    318319
    319320#if PLATFORM(COCOA)
  • trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm

    r175288 r175982  
    122122
    123123    [nsurlCache setMemoryCapacity:urlCacheMemoryCapacity];
    124     [nsurlCache setDiskCapacity:std::max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
     124    if (!m_diskCacheIsDisabledForTesting)
     125        [nsurlCache setDiskCapacity:std::max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
    125126}
    126127
     
    168169#endif
    169170#endif
     171
     172    // FIXME: Most of what this function does for cache size gets immediately overridden by setCacheModel().
     173    // - memory cache size passed from UI process is always ignored;
     174    // - disk cache size passed from UI process is effectively a minimum size.
     175    // 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.
     176
     177    ASSERT(!m_diskCacheIsDisabledForTesting || !parameters.nsURLCacheDiskCapacity);
    170178
    171179#if PLATFORM(IOS)
  • trunk/Tools/ChangeLog

    r175930 r175982  
     12014-11-11  Alexey Proskuryakov  <ap@apple.com>
     2
     3        DRT and WKTR touch disk cache
     4        https://bugs.webkit.org/show_bug.cgi?id=138622
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * DumpRenderTree/mac/DumpRenderTree.mm: (prepareConsistentTestingEnvironment):
     9        Set a shared cache before calling -_switchNetworkLoaderToNewTestingSession, not after,
     10        because this function uses the shared cache.
     11
     12        * WebKitTestRunner/mac/TestControllerMac.mm: (WTR::TestController::platformInitializeContext):
     13        Create an empty shared cache to prevent a default one from being created on disk.
     14
    1152014-10-07  Sergio Villar Senin  <svillar@igalia.com>
    216
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r175783 r175982  
    10891089
    10901090#if !PLATFORM(IOS)
    1091     // FIXME: We'd like to start with a clean state for every test, but this function can't be used more than once yet.
     1091    // +[WebPreferences _switchNetworkLoaderToNewTestingSession] calls +[NSURLCache sharedURLCache], which initializes a default cache on disk.
     1092    // Making the shared cache memory-only avoids touching the file system.
     1093    RetainPtr<NSURLCache> sharedCache =
     1094        adoptNS([[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024
     1095                                      diskCapacity:0
     1096                                          diskPath:nil]);
     1097    [NSURLCache setSharedURLCache:sharedCache.get()];
     1098
    10921099    [WebPreferences _switchNetworkLoaderToNewTestingSession];
    1093 
    1094     NSURLCache *sharedCache =
    1095         [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024
    1096                                       diskCapacity:0
    1097                                           diskPath:[libraryPathForDumpRenderTree() stringByAppendingPathComponent:@"URLCache"]];
    1098     [NSURLCache setSharedURLCache:sharedCache];
    1099     [sharedCache release];
    11001100
    11011101    adjustFonts();
  • trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm

    r174824 r175982  
    107107void TestController::platformInitializeContext()
    108108{
     109    // Testing uses a private session, which is memory only. However creating one instantiates a shared NSURLCache,
     110    // and if we haven't created one yet, the default one will be created on disk.
     111    // Making the shared cache memory-only avoids touching the file system.
     112    RetainPtr<NSURLCache> sharedCache =
     113        adoptNS([[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024
     114                                      diskCapacity:0
     115                                          diskPath:nil]);
     116    [NSURLCache setSharedURLCache:sharedCache.get()];
    109117}
    110118
Note: See TracChangeset for help on using the changeset viewer.