Source/WebKit2/ChangeLog

112012-07-09 Carlos Garcia Campos <cgarcia@igalia.com>
22
 3 [GTK] Implement disk cache in WebKit2
 4 https://bugs.webkit.org/show_bug.cgi?id=90797
 5
 6 Reviewed by NOBODY (OOPS!).
 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
 222012-07-09 Carlos Garcia Campos <cgarcia@igalia.com>
 23
324 [GTK] Fix inspector detach when inspector was attached by the client
425 https://bugs.webkit.org/show_bug.cgi?id=90763
526

Source/WebKit2/WebProcess/gtk/WebProcessGtk.cpp

@@namespace WebKit {
4747
4848static uint64_t getCacheDiskFreeSize(SoupCache* cache)
4949{
50  if (!cache)
51  return 0;
 50 ASSERT(cache);
5251
5352 GOwnPtr<char> cacheDir;
5453 g_object_get(G_OBJECT(cache), "cache-dir", &cacheDir.outPtr(), NULL);

@@void WebProcess::platformSetCacheModel(CacheModel cacheModel)
8988 unsigned long urlCacheDiskCapacity = 0;
9089
9190 SoupSession* session = WebCore::ResourceHandle::defaultSession();
92  SoupCache* cache = reinterpret_cast<SoupCache*>(soup_session_get_feature(session, SOUP_TYPE_CACHE));
93  uint64_t diskFreeSize = getCacheDiskFreeSize(cache);
 91 SoupCache* cache = SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE));
 92 uint64_t diskFreeSize = getCacheDiskFreeSize(cache) / 1024 / 1024;
9493
9594 uint64_t memSize = getMemorySize();
9695 calculateCacheSizes(cacheModel, memSize, diskFreeSize,

@@void WebProcess::platformSetCacheModel(CacheModel cacheModel)
101100 WebCore::memoryCache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
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
115116void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters&, CoreIPC::ArgumentDecoder*)

@@void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
119120
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
124129} // namespace WebKit

Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp

2727#include "config.h"
2828#include "WebProcessMainGtk.h"
2929
 30#define LIBSOUP_USE_UNSTABLE_REQUEST_API
 31
3032#include "WebAuthDialog.h"
3133#include "WKBase.h"
3234#include <WebCore/GtkAuthenticationDialog.h>

3436#include <WebCore/RunLoop.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;
4247

@@WK_EXPORT int WebProcessMainGtk(int argc, char* argv[])
7075 g_object_set(session, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
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
7585 return 0;