ChangeLog

 12009-03-07 Bobby Powers <bobby@laptop.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Implement and expose cache models for GTK
 6
 7 Based off the Mac implementation in WebView.mm. Expose this as
 8 a property in WebKitWebSettings, even though it is a global setting.
 9 Update GtkLauncher to use the 'web browser' cache model.
 10
 11 * GNUmakefile.am:
 12 * configure.ac:
 13
1142009-03-02 Xan Lopez <xan@gnome.org>
215
316 Reviewed by Mark Rowe.

GNUmakefile.am

@@libwebkit_1_0_la_CXXFLAGS = \
236236
237237libwebkit_1_0_la_CFLAGS = \
238238 $(libWebCore_la_CFLAGS) \
239  $(GNOMEKEYRING_CFLAGS)
 239 $(GNOMEKEYRING_CFLAGS) \
 240 $(LIBGTOP_CFLAGS)
240241
241242libwebkit_1_0_la_CPPFLAGS = \
242243 $(libWebCore_la_CPPFLAGS) \

@@libwebkit_1_0_la_LDFLAGS = \
250251
251252libwebkit_1_0_la_LIBADD = \
252253 libWebCore.la \
253  $(GNOMEKEYRING_LIBS)
 254 $(GNOMEKEYRING_LIBS) \
 255 $(LIBGTOP_LIBS)
254256
255257#
256258# Extra checks and flags

@@webkitgtk_cppflags += \
360362 -I$(srcdir)/WebKit/gtk \
361363 -I$(srcdir)/WebKit/gtk/WebCoreSupport \
362364 -I$(srcdir)/WebKit/gtk/webkit \
363  -I$(top_builddir)/WebKit/gtk/webkit
 365 -I$(top_builddir)/WebKit/gtk/webkit \
 366 $(LIBGTOP_CFLAGS)
364367
365368webkitgtk_cleanfiles += \
366369 $(top_builddir)/Programs/GtkLauncher \

WebKit/gtk/ChangeLog

 12009-03-07 Bobby Powers <bobby@laptop.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Implement and expose cache models for GTK
 6
 7 Based off the Mac implementation in WebView.mm. Expose this as
 8 a property in WebKitWebSettings, even though it is a global setting.
 9 Update GtkLauncher to use the 'web browser' cache model.
 10
 11 * webkit/webkitdefines.h:
 12 * webkit/webkitprivate.cpp:
 13 (webkit_init):
 14 * webkit/webkitprivate.h:
 15 * webkit/webkitwebsettings.cpp:
 16 (_WebKitWebSettingsPrivate::):
 17 (_WebKitWebSettingsPrivate::webkit_web_settings_class_init):
 18 (_WebKitWebSettingsPrivate::webkit_web_settings_set_property):
 19 (_WebKitWebSettingsPrivate::webkit_web_settings_get_property):
 20 * webkit/webkitwebsettings.h:
 21 * webkit/webkitwebview.cpp:
 22 (WebMemorySize):
 23 (webkit_web_view_set_cache_model):
 24 (webkit_web_view_cache_model):
 25 (webkit_web_view_did_set_cache_model):
 26
1272009-03-05 Gustavo Noronha Silva <gns@gnome.org>
228
329 Reviewed by Olliej.

WebKit/gtk/webkit/webkitdefines.h

3939 #define WEBKIT_API
4040#endif
4141
 42/* not having this produces a warning when including glibtop.h */
 43#define TIME_WITH_SYS_TIME 1
 44
4245G_BEGIN_DECLS
4346
4447typedef struct _WebKitNetworkRequest WebKitNetworkRequest;

WebKit/gtk/webkit/webkitprivate.cpp

3737#include "ResourceHandleInternal.h"
3838#include <runtime/InitializeThreading.h>
3939
 40#include <glibtop.h>
 41
4042#if ENABLE(DATABASE)
4143#include "DatabaseTracker.h"
4244#endif

@@void webkit_init()
133135 return;
134136 isInitialized = true;
135137
 138 // initialize glibtop so we can get memory and disk usage.
 139 glibtop_init();
 140
136141 JSC::initializeThreading();
137142 WebCore::InitializeLoggingChannelsIfNecessary();
138143
139  // Page cache capacity (in pages). Comment from Mac port:
140  // (Research indicates that value / page drops substantially after 3 pages.)
141  // FIXME: Expose this with an API and/or calculate based on available resources
142  WebCore::pageCache()->setCapacity(3);
143 
144144#if ENABLE(DATABASE)
145145 // FIXME: It should be possible for client applications to override this default location
146146 gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL);

WebKit/gtk/webkit/webkitprivate.h

@@extern "C" {
196196
197197 WEBKIT_API void
198198 webkit_web_settings_add_extra_plugin_directory (WebKitWebView *web_view, const gchar* directory);
 199
 200 WEBKIT_API void
 201 webkit_web_view_set_cache_model (WebKitCacheModel cache_model);
 202
 203 WEBKIT_API WebKitCacheModel
 204 webkit_web_view_cache_model (void);
 205
 206 WEBKIT_API gboolean
 207 webkit_web_view_did_set_cache_model (void);
199208}
200209
201210#endif

WebKit/gtk/webkit/webkitwebsettings.cpp

33 * Copyright (C) 2008 Nuanti Ltd.
44 * Copyright (C) 2008 Collabora Ltd.
55 * Copyright (C) 2008 Holger Hans Peter Freyther
 6 * Copyright (C) 2009 Bobby Powers (bobbypowers@gmail.com)
67 *
78 * This library is free software; you can redistribute it and/or
89 * modify it under the terms of the GNU Library General Public

@@enum {
101102 PROP_RESIZABLE_TEXT_AREAS,
102103 PROP_USER_STYLESHEET_URI,
103104 PROP_ZOOM_STEP,
104  PROP_ENABLE_DEVELOPER_EXTRAS
 105 PROP_ENABLE_DEVELOPER_EXTRAS,
 106 PROP_CACHE_MODEL
105107};
106108
107109static void webkit_web_settings_finalize(GObject* object);

@@static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
335337 FALSE,
336338 flags));
337339
 340 /**
 341 * WebKitWebSettings:cache-model:
 342 *
 343 * Specifies a usage model for a WebView, which WebKit will use to
 344 * determine its caching behavior.
 345 *
 346 * Research indicates that users tend to browse within clusters of
 347 * documents that hold resources in common, and to revisit previously visited
 348 * documents. WebKit and the frameworks below it include built-in caches that take
 349 * advantage of these patterns, substantially improving document load speed in
 350 * browsing situations. The WebKit cache model controls the behaviors of all of
 351 * these caches, including NSURLCache and the various WebCore caches.
 352 *
 353 * Applications with a browsing interface can improve document load speed
 354 * substantially by specifying WebCacheModelDocumentBrowser. Applications without
 355 * a browsing interface can reduce memory usage substantially by specifying
 356 * WebCacheModelDocumentViewer.
 357 *
 358 * Since: 1.1.1
 359 */
 360 g_object_class_install_property(gobject_class,
 361 PROP_CACHE_MODEL,
 362 g_param_spec_int(
 363 "cache-model",
 364 "Cache Model",
 365 "The cache model for all WebViews to use.",
 366 0, 2, 0,
 367 flags));
 368
338369 g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate));
339370}
340371

@@static void webkit_web_settings_set_property(GObject* object, guint prop_id, con
437468 case PROP_ENABLE_DEVELOPER_EXTRAS:
438469 priv->enable_developer_extras = g_value_get_boolean(value);
439470 break;
 471 case PROP_CACHE_MODEL:
 472 webkit_web_view_set_cache_model((WebKitCacheModel)g_value_get_int(value));
 473 break;
440474 default:
441475 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
442476 break;

@@static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa
512546 case PROP_ENABLE_DEVELOPER_EXTRAS:
513547 g_value_set_boolean(value, priv->enable_developer_extras);
514548 break;
 549 case PROP_CACHE_MODEL:
 550 g_value_set_int(value, (gint)webkit_web_view_cache_model());
 551 break;
515552 default:
516553 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
517554 break;

WebKit/gtk/webkit/webkitwebsettings.h

@@G_BEGIN_DECLS
3535
3636typedef struct _WebKitWebSettingsPrivate WebKitWebSettingsPrivate;
3737
 38typedef enum {
 39 WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER,
 40 WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER,
 41 WEBKIT_CACHE_MODEL_WEB_BROWSER
 42} WebKitCacheModel;
 43
3844struct _WebKitWebSettings {
3945 GObject parent_instance;
4046

WebKit/gtk/webkit/webkitwebview.cpp

88 * Copyright (C) 2008 Nuanti Ltd.
99 * Copyright (C) 2008 Collabora Ltd.
1010 * Copyright (C) 2009 Igalia S.L.
 11 * Copyright (C) 2009 Bobby Powers (bobbypowers@gmail.com)
1112 *
1213 * This library is free software; you can redistribute it and/or
1314 * modify it under the terms of the GNU Lesser General Public

6970
7071#include <gdk/gdkkeysyms.h>
7172
 73#include <glibtop/mem.h>
 74#include "Cache.h"
 75#include "PageCache.h"
 76
7277/**
7378 * SECTION:webkitwebview
7479 * @short_description: The central class of the WebKit/Gtk+ API

@@enum {
155160 PROP_CUSTOM_ENCODING
156161};
157162
 163static bool s_didSetCacheModel = false;
 164static WebKitCacheModel s_cacheModel = WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER;
 165
158166static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, };
159167
160168G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)

@@static void webkit_web_view_init(WebKitWebView* webView)
18671875 g_signal_connect(webView, "screen-changed", G_CALLBACK(webkit_web_view_screen_changed), NULL);
18681876 g_signal_connect(priv->webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView);
18691877
 1878 if (!webkit_web_view_did_set_cache_model())
 1879 {
 1880 // the Mac port checks the running app against a list of known
 1881 // apps with preferred cache models, and then falls back on
 1882 // WEBWEBKIT_CACHE_MODEL_DOCUMENT_VIEWER
 1883 webkit_web_view_set_cache_model(WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
 1884 }
 1885
18701886 priv->webWindowFeatures = webkit_web_window_features_new();
18711887}
18721888

@@const char* webkit_web_view_get_custom_encoding(WebKitWebView* webView)
29112927 } else
29122928 return NULL;
29132929}
 2930
 2931// for internal use only. returns the total memory available on the system.
 2932static uint64_t WebMemorySize()
 2933{
 2934 glibtop_mem memory;
 2935 glibtop_get_mem(&memory);
 2936 return (uint64_t)memory.total;
 2937}
 2938
 2939/**
 2940 * webkit_web_view_set_cache_model:
 2941 * @cache_model: a #WebKitCacheModel
 2942 *
 2943 * Sets the cache model all web views should follow. This cache model
 2944 * determines the RAM and disk space to use for caching previously viewed
 2945 * content.
 2946 *
 2947 * Since: 1.1.1
 2948 */
 2949void webkit_web_view_set_cache_model(WebKitCacheModel cacheModel)
 2950{
 2951 if (s_didSetCacheModel && cacheModel == s_cacheModel)
 2952 return;
 2953
 2954 // mac version sets cache directory here
 2955
 2956 uint64_t memSize = WebMemorySize() / 1024 / 1000;
 2957 // mac version gets disk size here
 2958
 2959 unsigned cacheTotalCapacity = 0;
 2960 unsigned cacheMinDeadCapacity = 0;
 2961 unsigned cacheMaxDeadCapacity = 0;
 2962 double deadDecodedDataDeletionInterval = 0;
 2963
 2964 unsigned pageCacheCapacity = 0;
 2965
 2966 switch (cacheModel) {
 2967 case WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER: {
 2968 // Page cache capacity (in pages)
 2969 pageCacheCapacity = 0;
 2970
 2971 // Object cache capacities (in bytes)
 2972 if (memSize >= 2048)
 2973 cacheTotalCapacity = 96 * 1024 * 1024;
 2974 else if (memSize >= 1536)
 2975 cacheTotalCapacity = 64 * 1024 * 1024;
 2976 else if (memSize >= 1024)
 2977 cacheTotalCapacity = 32 * 1024 * 1024;
 2978 else if (memSize >= 512)
 2979 cacheTotalCapacity = 16 * 1024 * 1024;
 2980
 2981 cacheMinDeadCapacity = 0;
 2982 cacheMaxDeadCapacity = 0;
 2983
 2984 break;
 2985 }
 2986 case WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER: {
 2987 // Page cache capacity (in pages)
 2988 if (memSize >= 1024)
 2989 pageCacheCapacity = 3;
 2990 else if (memSize >= 512)
 2991 pageCacheCapacity = 2;
 2992 else if (memSize >= 256)
 2993 pageCacheCapacity = 1;
 2994 else
 2995 pageCacheCapacity = 0;
 2996
 2997 // Object cache capacities (in bytes)
 2998 if (memSize >= 2048)
 2999 cacheTotalCapacity = 96 * 1024 * 1024;
 3000 else if (memSize >= 1536)
 3001 cacheTotalCapacity = 64 * 1024 * 1024;
 3002 else if (memSize >= 1024)
 3003 cacheTotalCapacity = 32 * 1024 * 1024;
 3004 else if (memSize >= 512)
 3005 cacheTotalCapacity = 16 * 1024 * 1024;
 3006
 3007 cacheMinDeadCapacity = cacheTotalCapacity / 8;
 3008 cacheMaxDeadCapacity = cacheTotalCapacity / 4;
 3009
 3010 break;
 3011 }
 3012 case WEBKIT_CACHE_MODEL_WEB_BROWSER: {
 3013 // Page cache capacity (in pages)
 3014 // (Research indicates that value / page drops substantially after 3 pages.)
 3015 if (memSize >= 2048)
 3016 pageCacheCapacity = 5;
 3017 else if (memSize >= 1024)
 3018 pageCacheCapacity = 4;
 3019 else if (memSize >= 512)
 3020 pageCacheCapacity = 3;
 3021 else if (memSize >= 256)
 3022 pageCacheCapacity = 2;
 3023 else
 3024 pageCacheCapacity = 1;
 3025
 3026 // Object cache capacities (in bytes)
 3027 // (Testing indicates that value / MB depends heavily on content and
 3028 // browsing pattern. Even growth above 128MB can have substantial
 3029 // value / MB for some content / browsing patterns.)
 3030 if (memSize >= 2048)
 3031 cacheTotalCapacity = 128 * 1024 * 1024;
 3032 else if (memSize >= 1536)
 3033 cacheTotalCapacity = 96 * 1024 * 1024;
 3034 else if (memSize >= 1024)
 3035 cacheTotalCapacity = 64 * 1024 * 1024;
 3036 else if (memSize >= 512)
 3037 cacheTotalCapacity = 32 * 1024 * 1024;
 3038
 3039 cacheMinDeadCapacity = cacheTotalCapacity / 4;
 3040 cacheMaxDeadCapacity = cacheTotalCapacity / 2;
 3041
 3042 // This code is here to avoid a PLT regression. We can remove it if we
 3043 // can prove that the overall system gain would justify the regression.
 3044 cacheMaxDeadCapacity = max(24u, cacheMaxDeadCapacity);
 3045
 3046 deadDecodedDataDeletionInterval = 60;
 3047
 3048 break;
 3049 }
 3050 default:
 3051 ASSERT_NOT_REACHED();
 3052 }
 3053
 3054 WebCore::cache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
 3055 WebCore::cache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
 3056 WebCore::pageCache()->setCapacity(pageCacheCapacity);
 3057
 3058 s_cacheModel = cacheModel;
 3059 s_didSetCacheModel = true;
 3060}
 3061
 3062/**
 3063 * webkit_web_view_cache_model:
 3064 *
 3065 * Returns the current cache model.
 3066 *
 3067 * Return value: the current @webkit_cache_model.
 3068 *
 3069 * Since: 1.1.1
 3070 */
 3071WebKitCacheModel webkit_web_view_cache_model()
 3072{
 3073 return s_cacheModel;
 3074}
 3075
 3076/**
 3077 * webkit_web_view_did_set_cache_model:
 3078 *
 3079 * Returns whether or not we have set the cache model and are not just
 3080 * using the default.
 3081 *
 3082 * Return value: a boolean value, with TRUE indicating that we have specified
 3083 * a cache model.
 3084 *
 3085 * Since: 1.1.1
 3086 */
 3087gboolean webkit_web_view_did_set_cache_model()
 3088{
 3089 return s_didSetCacheModel ? TRUE : FALSE;
 3090}
 3091

WebKitTools/ChangeLog

 12009-03-07 Bobby Powers <bobby@laptop.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Implement and expose cache models for GTK
 6
 7 Based off the Mac implementation in WebView.mm. Expose this as
 8 a property in WebKitWebSettings, even though it is a global setting.
 9 Update GtkLauncher to use the 'web browser' cache model.
 10
 11 * GtkLauncher/main.c:
 12 (create_browser):
 13
1142009-03-07 Jan Michael Alonzo <jmalonzo@webkit.org>
215
316 Reviewed by Holger Freyther.

WebKitTools/GtkLauncher/main.c

@@create_browser ()
120120 g_signal_connect (G_OBJECT (web_view), "load-committed", G_CALLBACK (load_commit_cb), web_view);
121121 g_signal_connect (G_OBJECT (web_view), "hovering-over-link", G_CALLBACK (link_hover_cb), web_view);
122122
 123 /* set the cache model to 'web browser', to improve performance at
 124 * the expense of increased memory pressure. */
 125 WebKitWebSettings* settings = webkit_web_view_get_settings (web_view);
 126 g_object_set (G_OBJECT (settings), "cache-model", WEBKIT_CACHE_MODEL_WEB_BROWSER, NULL);
 127
123128 return scrolled_window;
124129}
125130

configure.ac

@@GTK_REQUIRED_VERSION=2.8
187187
188188# optional modules
189189LIBSOUP_REQUIRED_VERSION=2.25.91
 190LIBGTOP_REQUIRED_VERSION=2.22.3
190191LIBXSLT_REQUIRED_VERSION=1.1.7
191192SQLITE_REQUIRED_VERSION=3.0
192193GSTREAMER_REQUIRED_VERSION=0.10

@@PKG_CHECK_MODULES([LIBSOUP],
525526AC_SUBST([LIBSOUP_CFLAGS])
526527AC_SUBST([LIBSOUP_LIBS])
527528
 529PKG_CHECK_MODULES([LIBGTOP],
 530 [libgtop-2.0 >= $LIBGTOP_REQUIRED_VERSION])
 531AC_SUBST([LIBGTOP_CFLAGS])
 532AC_SUBST([LIBGTOP_LIBS])
 533
528534if test "$enable_gnomekeyring" = "yes"; then
529535 PKG_CHECK_MODULES([GNOMEKEYRING],
530536 [gnome-keyring-1])