Changeset 173200 in webkit


Ignore:
Timestamp:
Sep 2, 2014 11:04:44 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[WinCairo] Memory cache capacity is not set.
https://bugs.webkit.org/show_bug.cgi?id=136432

Patch by peavo@outlook.com <peavo@outlook.com> on 2014-09-02
Reviewed by Alex Christensen.

Reuse code from AppleWin to set memory and disk cache capacity.

  • WebKitSystemBits.cpp:

(WebVolumeFreeSize):

  • WebKitSystemBits.h:
  • WebView.cpp:

(WebView::setCacheModel):

Location:
trunk/Source/WebKit/win
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/win/ChangeLog

    r172977 r173200  
     12014-09-02  peavo@outlook.com  <peavo@outlook.com>
     2
     3        [WinCairo] Memory cache capacity is not set.
     4        https://bugs.webkit.org/show_bug.cgi?id=136432
     5
     6        Reviewed by Alex Christensen.
     7
     8        Reuse code from AppleWin to set memory and disk cache capacity.
     9
     10        * WebKitSystemBits.cpp:
     11        (WebVolumeFreeSize):
     12        * WebKitSystemBits.h:
     13        * WebView.cpp:
     14        (WebView::setCacheModel):
     15
    1162014-08-26  Brent Fulgham  <bfulgham@apple.com>
    217
  • trunk/Source/WebKit/win/WebKitSystemBits.cpp

    r165676 r173200  
    3030#include "WebKitSystemBits.h"
    3131
    32 #include <CoreFoundation/CoreFoundation.h>
    3332#include <windows.h>
    34 #include <wtf/text/WTFString.h>
    3533
    3634unsigned long long WebMemorySize()
     
    4240}
    4341
    44 unsigned long long WebVolumeFreeSize(CFStringRef cfstringPath)
     42unsigned long long WebVolumeFreeSize(const String& path)
    4543{
    46     WTF::String path(cfstringPath);
    4744    ULARGE_INTEGER freeBytesToCaller;
    4845    BOOL result = GetDiskFreeSpaceExW((LPCWSTR)path.charactersWithNullTermination().data(), &freeBytesToCaller, 0, 0);
  • trunk/Source/WebKit/win/WebKitSystemBits.h

    r165676 r173200  
    3030#define WebKitSystemBits_h
    3131
    32 typedef const struct __CFString* CFStringRef;
     32#include <wtf/text/WTFString.h>
    3333
    3434unsigned long long WebMemorySize();
    35 unsigned long long WebVolumeFreeSize(CFStringRef path);
     35unsigned long long WebVolumeFreeSize(const String& path);
    3636
    3737#endif // WebKitSystemBits_h
  • trunk/Source/WebKit/win/WebView.cpp

    r172977 r173200  
    163163#include <CFNetwork/CFURLCachePriv.h>
    164164#include <CFNetwork/CFURLProtocolPriv.h>
    165 #include <WebKitSystemInterface/WebKitSystemInterface.h>
     165#include <WebKitSystemInterface/WebKitSystemInterface.h>
     166#elif USE(CURL)
     167#include <WebCore/CurlCacheManager.h>
    166168#endif
    167169
     
    484486void WebView::setCacheModel(WebCacheModel cacheModel)
    485487{
    486 #if USE(CFNETWORK)
    487488    if (s_didSetCacheModel && cacheModel == s_cacheModel)
    488489        return;
    489490
     491    String cacheDirectory;
     492
     493#if USE(CFNETWORK)
    490494    RetainPtr<CFURLCacheRef> cfurlCache = adoptCF(CFURLCacheCopySharedURLCache());
    491495    RetainPtr<CFStringRef> cfurlCacheDirectory = adoptCF(wkCopyFoundationCacheDirectory(0));
     
    497501            cfurlCacheDirectory = WebCore::localUserSpecificStorageDirectory().createCFString();
    498502    }
     503    cacheDirectory = String(cfurlCacheDirectory);
     504#elif USE(CURL)
     505    cacheDirectory = CurlCacheManager::getInstance().cacheDirectory();
     506#endif
     507
     508    long cacheMemoryCapacity = 0;
     509    long cacheDiskCapacity = 0;
    499510
    500511    // As a fudge factor, use 1000 instead of 1024, in case the reported byte
    501512    // count doesn't align exactly to a megabyte boundary.
    502513    unsigned long long memSize = WebMemorySize() / 1024 / 1000;
    503     unsigned long long diskFreeSize = WebVolumeFreeSize(cfurlCacheDirectory.get()) / 1024 / 1000;
     514    unsigned long long diskFreeSize = WebVolumeFreeSize(cacheDirectory) / 1024 / 1000;
    504515
    505516    unsigned cacheTotalCapacity = 0;
     
    510521    unsigned pageCacheCapacity = 0;
    511522
    512     CFIndex cfurlCacheMemoryCapacity = 0;
    513     CFIndex cfurlCacheDiskCapacity = 0;
    514523
    515524    switch (cacheModel) {
     
    531540        cacheMaxDeadCapacity = 0;
    532541
    533         // Foundation memory cache capacity (in bytes)
    534         cfurlCacheMemoryCapacity = 0;
    535 
     542        // Memory cache capacity (in bytes)
     543        cacheMemoryCapacity = 0;
     544
     545#if USE(CFNETWORK)
    536546        // Foundation disk cache capacity (in bytes)
    537         cfurlCacheDiskCapacity = CFURLCacheDiskCapacity(cfurlCache.get());
    538 
     547        cacheDiskCapacity = CFURLCacheDiskCapacity(cfurlCache.get());
     548#endif
    539549        break;
    540550    }
     
    563573        cacheMaxDeadCapacity = cacheTotalCapacity / 4;
    564574
    565         // Foundation memory cache capacity (in bytes)
     575        // Memory cache capacity (in bytes)
    566576        if (memSize >= 2048)
    567             cfurlCacheMemoryCapacity = 4 * 1024 * 1024;
     577            cacheMemoryCapacity = 4 * 1024 * 1024;
    568578        else if (memSize >= 1024)
    569             cfurlCacheMemoryCapacity = 2 * 1024 * 1024;
     579            cacheMemoryCapacity = 2 * 1024 * 1024;
    570580        else if (memSize >= 512)
    571             cfurlCacheMemoryCapacity = 1 * 1024 * 1024;
     581            cacheMemoryCapacity = 1 * 1024 * 1024;
    572582        else
    573             cfurlCacheMemoryCapacity =      512 * 1024;
    574 
    575         // Foundation disk cache capacity (in bytes)
     583            cacheMemoryCapacity =      512 * 1024;
     584
     585        // Disk cache capacity (in bytes)
    576586        if (diskFreeSize >= 16384)
    577             cfurlCacheDiskCapacity = 50 * 1024 * 1024;
     587            cacheDiskCapacity = 50 * 1024 * 1024;
    578588        else if (diskFreeSize >= 8192)
    579             cfurlCacheDiskCapacity = 40 * 1024 * 1024;
     589            cacheDiskCapacity = 40 * 1024 * 1024;
    580590        else if (diskFreeSize >= 4096)
    581             cfurlCacheDiskCapacity = 30 * 1024 * 1024;
     591            cacheDiskCapacity = 30 * 1024 * 1024;
    582592        else
    583             cfurlCacheDiskCapacity = 20 * 1024 * 1024;
     593            cacheDiskCapacity = 20 * 1024 * 1024;
    584594
    585595        break;
     
    621631        deadDecodedDataDeletionInterval = std::chrono::seconds { 60 };
    622632
    623         // Foundation memory cache capacity (in bytes)
     633        // Memory cache capacity (in bytes)
    624634        // (These values are small because WebCore does most caching itself.)
    625635        if (memSize >= 1024)
    626             cfurlCacheMemoryCapacity = 4 * 1024 * 1024;
     636            cacheMemoryCapacity = 4 * 1024 * 1024;
    627637        else if (memSize >= 512)
    628             cfurlCacheMemoryCapacity = 2 * 1024 * 1024;
     638            cacheMemoryCapacity = 2 * 1024 * 1024;
    629639        else if (memSize >= 256)
    630             cfurlCacheMemoryCapacity = 1 * 1024 * 1024;
     640            cacheMemoryCapacity = 1 * 1024 * 1024;
    631641        else
    632             cfurlCacheMemoryCapacity =      512 * 1024;
    633 
    634         // Foundation disk cache capacity (in bytes)
     642            cacheMemoryCapacity =      512 * 1024;
     643
     644        // Disk cache capacity (in bytes)
    635645        if (diskFreeSize >= 16384)
    636             cfurlCacheDiskCapacity = 175 * 1024 * 1024;
     646            cacheDiskCapacity = 175 * 1024 * 1024;
    637647        else if (diskFreeSize >= 8192)
    638             cfurlCacheDiskCapacity = 150 * 1024 * 1024;
     648            cacheDiskCapacity = 150 * 1024 * 1024;
    639649        else if (diskFreeSize >= 4096)
    640             cfurlCacheDiskCapacity = 125 * 1024 * 1024;
     650            cacheDiskCapacity = 125 * 1024 * 1024;
    641651        else if (diskFreeSize >= 2048)
    642             cfurlCacheDiskCapacity = 100 * 1024 * 1024;
     652            cacheDiskCapacity = 100 * 1024 * 1024;
    643653        else if (diskFreeSize >= 1024)
    644             cfurlCacheDiskCapacity = 75 * 1024 * 1024;
     654            cacheDiskCapacity = 75 * 1024 * 1024;
    645655        else
    646             cfurlCacheDiskCapacity = 50 * 1024 * 1024;
     656            cacheDiskCapacity = 50 * 1024 * 1024;
    647657
    648658        break;
     
    651661        ASSERT_NOT_REACHED();
    652662    }
    653 
    654     // Don't shrink a big disk cache, since that would cause churn.
    655     cfurlCacheDiskCapacity = max(cfurlCacheDiskCapacity, CFURLCacheDiskCapacity(cfurlCache.get()));
    656663
    657664    memoryCache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
     
    659666    pageCache()->setCapacity(pageCacheCapacity);
    660667
    661     CFURLCacheSetMemoryCapacity(cfurlCache.get(), cfurlCacheMemoryCapacity);
    662     CFURLCacheSetDiskCapacity(cfurlCache.get(), cfurlCacheDiskCapacity);
     668#if USE(CFNETWORK)
     669    // Don't shrink a big disk cache, since that would cause churn.
     670    cacheDiskCapacity = max(cacheDiskCapacity, CFURLCacheDiskCapacity(cfurlCache.get()));
     671
     672    CFURLCacheSetMemoryCapacity(cfurlCache.get(), cacheMemoryCapacity);
     673    CFURLCacheSetDiskCapacity(cfurlCache.get(), cacheDiskCapacity);
     674#elif USE(CURL)
     675    CurlCacheManager::getInstance().setStorageSizeLimit(cacheDiskCapacity);
     676#endif
    663677
    664678    s_didSetCacheModel = true;
    665679    s_cacheModel = cacheModel;
    666680    return;
    667 #endif
    668681}
    669682
Note: See TracChangeset for help on using the changeset viewer.