Title: [122571] trunk/Source/WebKit2
Revision
122571
Author
[email protected]
Date
2012-07-13 06:47:01 -0700 (Fri, 13 Jul 2012)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (122570 => 122571)


--- trunk/Source/WebKit2/ChangeLog	2012-07-13 13:41:51 UTC (rev 122570)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-13 13:47:01 UTC (rev 122571)
@@ -1,5 +1,26 @@
 2012-07-13  Carlos Garcia Campos  <[email protected]>
 
+        [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.
+
+2012-07-13  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Fix disk cache size computation in WebKit2
         https://bugs.webkit.org/show_bug.cgi?id=91226
 

Modified: trunk/Source/WebKit2/WebProcess/gtk/WebProcessGtk.cpp (122570 => 122571)


--- trunk/Source/WebKit2/WebProcess/gtk/WebProcessGtk.cpp	2012-07-13 13:41:51 UTC (rev 122570)
+++ trunk/Source/WebKit2/WebProcess/gtk/WebProcessGtk.cpp	2012-07-13 13:47:01 UTC (rev 122571)
@@ -47,8 +47,7 @@
 
 static uint64_t getCacheDiskFreeSize(SoupCache* cache)
 {
-    if (!cache)
-        return 0;
+    ASSERT(cache);
 
     GOwnPtr<char> cacheDir;
     g_object_get(G_OBJECT(cache), "cache-dir", &cacheDir.outPtr(), NULL);
@@ -89,7 +88,7 @@
     unsigned long urlCacheDiskCapacity = 0;
 
     SoupSession* session = WebCore::ResourceHandle::defaultSession();
-    SoupCache* cache = reinterpret_cast<SoupCache*>(soup_session_get_feature(session, SOUP_TYPE_CACHE));
+    SoupCache* cache = SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE));
     uint64_t diskFreeSize = getCacheDiskFreeSize(cache) / 1024 / 1024;
 
     uint64_t memSize = getMemorySize();
@@ -101,15 +100,17 @@
     WebCore::memoryCache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
     WebCore::pageCache()->setCapacity(pageCacheCapacity);
 
-    if (cache) {
-        if (urlCacheDiskCapacity > soup_cache_get_max_size(cache))
-            soup_cache_set_max_size(cache, urlCacheDiskCapacity);
-    }
+    if (urlCacheDiskCapacity > soup_cache_get_max_size(cache))
+        soup_cache_set_max_size(cache, urlCacheDiskCapacity);
 }
 
-void WebProcess::platformClearResourceCaches(ResourceCachesToClear)
+void WebProcess::platformClearResourceCaches(ResourceCachesToClear cachesToClear)
 {
-    notImplemented();
+    if (cachesToClear == InMemoryResourceCachesOnly)
+        return;
+
+    SoupSession* session = WebCore::ResourceHandle::defaultSession();
+    soup_cache_clear(SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE)));
 }
 
 void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters&, CoreIPC::ArgumentDecoder*)
@@ -119,6 +120,10 @@
 
 void WebProcess::platformTerminate()
 {
+    SoupSession* session = WebCore::ResourceHandle::defaultSession();
+    SoupCache* cache = SOUP_CACHE(soup_session_get_feature(session, SOUP_TYPE_CACHE));
+    soup_cache_flush(cache);
+    soup_cache_dump(cache);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp (122570 => 122571)


--- trunk/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp	2012-07-13 13:41:51 UTC (rev 122570)
+++ trunk/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp	2012-07-13 13:47:01 UTC (rev 122571)
@@ -27,6 +27,8 @@
 #include "config.h"
 #include "WebProcessMainGtk.h"
 
+#define LIBSOUP_USE_UNSTABLE_REQUEST_API
+
 #include "WebAuthDialog.h"
 #include "WKBase.h"
 #include <WebCore/GtkAuthenticationDialog.h>
@@ -34,9 +36,12 @@
 #include <WebCore/RunLoop.h>
 #include <WebKit2/WebProcess.h>
 #include <gtk/gtk.h>
+#include <libsoup/soup-cache.h>
 #include <runtime/InitializeThreading.h>
 #include <unistd.h>
 #include <wtf/MainThread.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GRefPtr.h>
 
 using namespace WebCore;
 
@@ -70,6 +75,11 @@
     g_object_set(session, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
                  SOUP_SESSION_SSL_STRICT, FALSE, NULL);
 
+    GOwnPtr<char> soupCacheDirectory(g_build_filename(g_get_user_cache_dir(), g_get_prgname(), NULL));
+    GRefPtr<SoupCache> soupCache = adoptGRef(soup_cache_new(soupCacheDirectory.get(), SOUP_CACHE_SINGLE_USER));
+    soup_session_add_feature(session, SOUP_SESSION_FEATURE(soupCache.get()));
+    soup_cache_load(soupCache.get());
+
     RunLoop::run();
 
     return 0;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to