[evolution/wip/webkit2] Share one web_context between all editors



commit 024ed6db0814cc75917e512bede53d26e1c44847
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jun 27 11:08:33 2016 +0200

    Share one web_context between all editors
    
    ... thus there is one WebProcess for all the editors (and one for the preview).
    And do not even leak it on the application exit.

 modules/webkit-editor/e-webkit-editor.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/modules/webkit-editor/e-webkit-editor.c b/modules/webkit-editor/e-webkit-editor.c
index 2b41a71..8af3259 100644
--- a/modules/webkit-editor/e-webkit-editor.c
+++ b/modules/webkit-editor/e-webkit-editor.c
@@ -5025,15 +5025,20 @@ webkit_editor_constructor (GType type,
                        g_value_take_object (param->value, webkit_user_content_manager_new ());
                param_spec = g_object_class_find_property (object_class, "web-context");
                if ((param = find_property (n_construct_properties, construct_properties, param_spec))) {
-                       WebKitWebContext *web_context;
+                       /* Share one web_context between all editors, thus there is one WebProcess
+                          for all the editors (and one for the preview). */
+                       static gpointer web_context = NULL;
 
-                       web_context = webkit_web_context_new ();
+                       if (!web_context) {
+                               web_context = webkit_web_context_new ();
 
-                       webkit_web_context_set_cache_model (
-                               web_context, WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
+                               webkit_web_context_set_cache_model (web_context, 
WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
+                               webkit_web_context_set_web_extensions_directory (web_context, 
EVOLUTION_WEB_EXTENSIONS_WEBKIT_EDITOR_DIR);
 
-                       webkit_web_context_set_web_extensions_directory (
-                               web_context, EVOLUTION_WEB_EXTENSIONS_WEBKIT_EDITOR_DIR);
+                               g_object_add_weak_pointer (G_OBJECT (web_context), &web_context);
+                       } else {
+                               g_object_ref (web_context);
+                       }
 
                        g_value_take_object (param->value, web_context);
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]