[Webkit-unassigned] [Bug 24001] [GTK] Cache control APIs

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Dec 20 02:41:40 PST 2009


https://bugs.webkit.org/show_bug.cgi?id=24001


Xan Lopez <xan.lopez at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #45262|review?                     |review-
               Flag|                            |




--- Comment #44 from Xan Lopez <xan.lopez at gmail.com>  2009-12-20 02:41:39 PST ---
(From update of attachment 45262)
>diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
>index 1bc9b80..c4b48ff 100644
>--- a/WebKit/gtk/ChangeLog
>+++ b/WebKit/gtk/ChangeLog
>@@ -1,3 +1,21 @@
>+2009-12-18  Alejandro G. Castro  <alex at igalia.com>
>+
>+        Reviewed by NOBODY (OOPS!).
>+
>+        [GTK] Cache control APIs
>+        https://bugs.webkit.org/show_bug.cgi?id=24001
>+
>+        Original patch by Bobby Powers <bobby at laptop.org>
>+
>+        Added new API to specify cache models for GTK port.
>+
>+        * webkit/webkitprivate.cpp:
>+        (webkit_init): set a default cache model.
>+        * webkit/webkitwebview.cpp:
>+        * webkit/webkitwebview.h:
>+        (webkit_set_cache_model): Added function.
>+        (webkit_get_cache_model): Added function.
>+
> 2009-12-18  Xan Lopez  <xlopez at igalia.com>
> 
>         Reviewed by Gustavo Noronha.
>diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp
>index 7b613ba..bf0b109 100644
>--- a/WebKit/gtk/webkit/webkitprivate.cpp
>+++ b/WebKit/gtk/webkit/webkitprivate.cpp
>@@ -246,10 +246,7 @@ void webkit_init()
>     JSC::initializeThreading();
>     WebCore::InitializeLoggingChannelsIfNecessary();
> 
>-    // Page cache capacity (in pages). Comment from Mac port:
>-    // (Research indicates that value / page drops substantially after 3 pages.)
>-    // FIXME: Expose this with an API and/or calculate based on available resources
>-    WebCore::pageCache()->setCapacity(3);
>+    webkit_set_cache_model(WEBKIT_CACHE_MODEL_WEB_BROWSER);
> 
> #if ENABLE(DATABASE)
>     gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL);
>diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
>index b87eeeb..a63b8cc 100644
>--- a/WebKit/gtk/webkit/webkitwebview.cpp
>+++ b/WebKit/gtk/webkit/webkitwebview.cpp
>@@ -9,6 +9,7 @@
>  *  Copyright (C) 2008, 2009 Collabora Ltd.
>  *  Copyright (C) 2009 Igalia S.L.
>  *  Copyright (C) 2009 Movial Creative Technologies Inc.
>+ *  Copyright (C) 2009 Bobby Powers
>  *
>  *  This library is free software; you can redistribute it and/or
>  *  modify it under the terms of the GNU Lesser General Public
>@@ -41,6 +42,7 @@
> #include "AXObjectCache.h"
> #include "NotImplemented.h"
> #include "BackForwardList.h"
>+#include "Cache.h"
> #include "CString.h"
> #include "ChromeClientGtk.h"
> #include "ContextMenu.h"
>@@ -65,6 +67,7 @@
> #include "FrameLoader.h"
> #include "FrameView.h"
> #include "MouseEventWithHitTestResults.h"
>+#include "PageCache.h"
> #include "Pasteboard.h"
> #include "PasteboardHelper.h"
> #include "PasteboardHelperGtk.h"
>@@ -113,6 +116,7 @@
>  */
> 
> static const double defaultDPI = 96.0;
>+static WebKitCacheModel cacheModel;
> 
> using namespace WebKit;
> using namespace WebCore;
>@@ -4067,3 +4071,81 @@ G_CONST_RETURN gchar* webkit_web_view_get_icon_uri(WebKitWebView* webView)
>     priv->iconURI = g_strdup(iconURL.utf8().data());
>     return priv->iconURI;
> }
>+
>+/**
>+ * webkit_web_view_set_cache_model:

Wrong name.

>+ * @cache_model: a #WebKitCacheModel
>+ *
>+ * Specifies a usage model for a WebView, which WebKit will use to

for WebViews?

>+ * determine its caching behavior. All web views follow the cache
>+ * model. This cache model determines the RAM and disk space to use
>+ * for caching previously viewed content .
>+ *
>+ * Research indicates that users tend to browse within clusters of

I'm wonder if we'll ever see this research/study we all quote ;)

>+ * documents that hold resources in common, and to revisit previously
>+ * visited documents. WebKit and the frameworks below it include
>+ * built-in caches that take advantage of these patterns,
>+ * substantially improving document load speed in browsing
>+ * situations. The WebKit cache model controls the behaviors of all of
>+ * these caches, including disk and the various WebCore caches.

Maybe we shouldn't mention the disk caches until we support them?

>+ *
>+ * Browsers can improve document load speed substantially by
>+ * specifying WEBKIT_CACHE_MODEL_WEB_BROWSER. Applications without a
>+ * browsing interface can reduce memory usage substantially by
>+ * specifying WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER. Default value is
>+ * WEBKIT_CACHE_MODEL_WEB_BROWSER.
>+ *
>+ * Since: 1.1.18
>+ */
>+void webkit_set_cache_model(WebKitCacheModel model)
>+{
>+    if (cacheModel == model)
>+        return;
>+
>+    // FIXME: Add disk cache handling when soup has the API
>+    guint cacheTotalCapacity;
>+    guint cacheMinDeadCapacity;
>+    guint cacheMaxDeadCapacity;
>+    gdouble deadDecodedDataDeletionInterval;
>+    guint pageCacheCapacity;
>+
>+    switch (model) {
>+    case WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER:
>+        pageCacheCapacity = 0;
>+        cacheTotalCapacity = 0;
>+        cacheMinDeadCapacity = 0;
>+        cacheMaxDeadCapacity = 0;
>+        deadDecodedDataDeletionInterval = 0;
>+        break;
>+    case WEBKIT_CACHE_MODEL_WEB_BROWSER:
>+        pageCacheCapacity = 3;
>+        cacheTotalCapacity = 32 * 1024 * 1024;
>+        cacheMinDeadCapacity = cacheTotalCapacity / 4;
>+        cacheMaxDeadCapacity = cacheTotalCapacity / 2;
>+        deadDecodedDataDeletionInterval = 60;
>+        break;
>+    default:
>+        g_assert_not_reached();

Use g_return_if_reached, otherwise we'll always crash at runtime which is bad.

>+    }
>+
>+    cache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
>+    cache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
>+    pageCache()->setCapacity(pageCacheCapacity);
>+    cacheModel = model;
>+}
>+
>+/**
>+ * webkit_web_view_get_cache_model:

Wrong name.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list