Changeset 122571 in webkit


Ignore:
Timestamp:
Jul 13, 2012 6:47:01 AM (12 years ago)
Author:
Carlos Garcia Campos
Message:

[GTK] Implement disk cache in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=90797

Reviewed by Xan Lopez.

  • WebProcess/gtk/WebProcessGtk.cpp:

(WebKit::getCacheDiskFreeSize): Use an ASSERT instead of an early
return since the cache feature is now always added to the session.
(WebKit::WebProcess::platformSetCacheModel): Get the cache from
the session and set the maximum cache size as computed by
calculateCacheSizes().
(WebKit::WebProcess::platformClearResourceCaches): Call
soup_cache_clear().
(WebKit::WebProcess::platformTerminate): Make sure all pending
data is saved to the disk before the web process finishes.

  • WebProcess/gtk/WebProcessMainGtk.cpp:

(WebKit::WebProcessMainGtk): Create a SoupCache feature and add it
to the default SoupSession.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r122570 r122571  
     12012-07-13  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Implement disk cache in WebKit2
     4        https://bugs.webkit.org/show_bug.cgi?id=90797
     5
     6        Reviewed by Xan Lopez.
     7
     8        * WebProcess/gtk/WebProcessGtk.cpp:
     9        (WebKit::getCacheDiskFreeSize): Use an ASSERT instead of an early
     10        return since the cache feature is now always added to the session.
     11        (WebKit::WebProcess::platformSetCacheModel): Get the cache from
     12        the session and set the maximum cache size as computed by
     13        calculateCacheSizes().
     14        (WebKit::WebProcess::platformClearResourceCaches): Call
     15        soup_cache_clear().
     16        (WebKit::WebProcess::platformTerminate): Make sure all pending
     17        data is saved to the disk before the web process finishes.
     18        * WebProcess/gtk/WebProcessMainGtk.cpp:
     19        (WebKit::WebProcessMainGtk): Create a SoupCache feature and add it
     20        to the default SoupSession.
     21
    1222012-07-13  Carlos Garcia Campos  <cgarcia@igalia.com>
    223
  • trunk/Source/WebKit2/WebProcess/gtk/WebProcessGtk.cpp

    r122570 r122571  
    4848static uint64_t getCacheDiskFreeSize(SoupCache* cache)
    4949{
    50     if (!cache)
    51         return 0;
     50    ASSERT(cache);
    5251
    5352    GOwnPtr<char> cacheDir;
     
    9089
    9190    SoupSession* session = WebCore::ResourceHandle::defaultSession();
    92     SoupCache* cache = reinterpret_cast<SoupCache*>(soup_session_get_feature(session, SOUP_TYPE_CACHE));
     91    SoupCache* cache = SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE));
    9392    uint64_t diskFreeSize = getCacheDiskFreeSize(cache) / 1024 / 1024;
    9493
     
    102101    WebCore::pageCache()->setCapacity(pageCacheCapacity);
    103102
    104     if (cache) {
    105         if (urlCacheDiskCapacity > soup_cache_get_max_size(cache))
    106             soup_cache_set_max_size(cache, urlCacheDiskCapacity);
    107     }
     103    if (urlCacheDiskCapacity > soup_cache_get_max_size(cache))
     104        soup_cache_set_max_size(cache, urlCacheDiskCapacity);
    108105}
    109106
    110 void WebProcess::platformClearResourceCaches(ResourceCachesToClear)
     107void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear)
    111108{
    112     notImplemented();
     109    if (cachesToClear == InMemoryResourceCachesOnly)
     110        return;
     111
     112    SoupSession* session = WebCore::ResourceHandle::defaultSession();
     113    soup_cache_clear(SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE)));
    113114}
    114115
     
    120121void WebProcess::platformTerminate()
    121122{
     123    SoupSession* session = WebCore::ResourceHandle::defaultSession();
     124    SoupCache* cache = SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE));
     125    soup_cache_flush(cache);
     126    soup_cache_dump(cache);
    122127}
    123128
  • trunk/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp

    r109338 r122571  
    2828#include "WebProcessMainGtk.h"
    2929
     30#define LIBSOUP_USE_UNSTABLE_REQUEST_API
     31
    3032#include "WebAuthDialog.h"
    3133#include "WKBase.h"
     
    3537#include <WebKit2/WebProcess.h>
    3638#include <gtk/gtk.h>
     39#include <libsoup/soup-cache.h>
    3740#include <runtime/InitializeThreading.h>
    3841#include <unistd.h>
    3942#include <wtf/MainThread.h>
     43#include <wtf/gobject/GOwnPtr.h>
     44#include <wtf/gobject/GRefPtr.h>
    4045
    4146using namespace WebCore;
     
    7176                 SOUP_SESSION_SSL_STRICT, FALSE, NULL);
    7277
     78    GOwnPtr<char> soupCacheDirectory(g_build_filename(g_get_user_cache_dir(), g_get_prgname(), NULL));
     79    GRefPtr<SoupCache> soupCache = adoptGRef(soup_cache_new(soupCacheDirectory.get(), SOUP_CACHE_SINGLE_USER));
     80    soup_session_add_feature(session, SOUP_SESSION_FEATURE(soupCache.get()));
     81    soup_cache_load(soupCache.get());
     82
    7383    RunLoop::run();
    7484
Note: See TracChangeset for help on using the changeset viewer.