aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2013-03-28 02:29:04 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2013-06-05 00:20:40 +0800
commit030cc2e27a3bbad68d8aa40cc39e8b4778070d26 (patch)
tree1e22ccf81f715dbb860d5e2704a683e5e6d66644
parent4e3ff1b24118a1913a77285efc33ca38685a3ea5 (diff)
downloadgsoc2013-epiphany-030cc2e27a3bbad68d8aa40cc39e8b4778070d26.tar
gsoc2013-epiphany-030cc2e27a3bbad68d8aa40cc39e8b4778070d26.tar.gz
gsoc2013-epiphany-030cc2e27a3bbad68d8aa40cc39e8b4778070d26.tar.bz2
gsoc2013-epiphany-030cc2e27a3bbad68d8aa40cc39e8b4778070d26.tar.lz
gsoc2013-epiphany-030cc2e27a3bbad68d8aa40cc39e8b4778070d26.tar.xz
gsoc2013-epiphany-030cc2e27a3bbad68d8aa40cc39e8b4778070d26.tar.zst
gsoc2013-epiphany-030cc2e27a3bbad68d8aa40cc39e8b4778070d26.zip
Make about:memory handler asynchronous
https://bugzilla.gnome.org/show_bug.cgi?id=696728
-rw-r--r--embed/ephy-about-handler.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c
index ef15a120d..d876107d4 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -200,18 +200,18 @@ ephy_about_handler_handle_plugins (EphyAboutHandler *handler,
return TRUE;
}
-static gboolean
-ephy_about_handler_handle_memory (EphyAboutHandler *handler,
- WebKitURISchemeRequest *request)
+static void
+handle_memory_finished_cb (EphyAboutHandler *handler,
+ GAsyncResult *result,
+ WebKitURISchemeRequest *request)
{
GString *data_str;
gsize data_length;
char *memory;
- memory = ephy_smaps_to_html (ephy_about_handler_get_smaps (handler));
-
data_str = g_string_new ("<html>");
+ memory = g_task_propagate_pointer (G_TASK (result), NULL);
if (memory) {
g_string_append_printf (data_str, "<head><title>%s</title>" \
"<style type=\"text/css\">%s</style></head><body>",
@@ -227,6 +227,33 @@ ephy_about_handler_handle_memory (EphyAboutHandler *handler,
data_length = data_str->len;
ephy_about_handler_finish_request (request, g_string_free (data_str, FALSE), data_length);
+ g_object_unref (request);
+}
+
+static void
+handle_memory_sync (GTask *task,
+ gpointer source_object,
+ gpointer task_data,
+ GCancellable *cancellable)
+{
+ EphyAboutHandler *handler = EPHY_ABOUT_HANDLER (source_object);
+
+ g_task_return_pointer (task,
+ ephy_smaps_to_html (ephy_about_handler_get_smaps (handler)),
+ g_free);
+}
+
+static gboolean
+ephy_about_handler_handle_memory (EphyAboutHandler *handler,
+ WebKitURISchemeRequest *request)
+{
+ GTask *task;
+
+ task = g_task_new (handler, NULL,
+ (GAsyncReadyCallback)handle_memory_finished_cb,
+ g_object_ref (request));
+ g_task_run_in_thread (task, handle_memory_sync);
+ g_object_unref (task);
return TRUE;
}