aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-request-about.c
diff options
context:
space:
mode:
authorXan Lopez <xlopez@igalia.com>2011-06-28 00:18:58 +0800
committerXan Lopez <xlopez@igalia.com>2011-06-28 01:34:52 +0800
commit836a072b8a9404be59187f66f46c64998670a534 (patch)
tree09e8769a144518730455cf40e62679c2e473a7fe /lib/ephy-request-about.c
parentfe909aa62629a5994dd643450b0de45e0e3f508d (diff)
downloadgsoc2013-epiphany-836a072b8a9404be59187f66f46c64998670a534.tar
gsoc2013-epiphany-836a072b8a9404be59187f66f46c64998670a534.tar.gz
gsoc2013-epiphany-836a072b8a9404be59187f66f46c64998670a534.tar.bz2
gsoc2013-epiphany-836a072b8a9404be59187f66f46c64998670a534.tar.lz
gsoc2013-epiphany-836a072b8a9404be59187f66f46c64998670a534.tar.xz
gsoc2013-epiphany-836a072b8a9404be59187f66f46c64998670a534.tar.zst
gsoc2013-epiphany-836a072b8a9404be59187f66f46c64998670a534.zip
Implement about:memory
Gives an estimate of how much memory the browser process is using, extracted from /proc/$PID/smaps. Only works in GNU/Linux systems.
Diffstat (limited to 'lib/ephy-request-about.c')
-rw-r--r--lib/ephy-request-about.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/lib/ephy-request-about.c b/lib/ephy-request-about.c
index a809f29f5..4601e4787 100644
--- a/lib/ephy-request-about.c
+++ b/lib/ephy-request-about.c
@@ -1,8 +1,21 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
- * ephy-request-about.c: about: URI request object
+ * Copyright © 2011 Igalia S.L.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * Copyright (C) 2011, Igalia S.L.
*/
#ifdef HAVE_CONFIG_H
@@ -16,12 +29,14 @@
#include "ephy-file-helpers.h"
#include "ephy-request-about.h"
+#include "ephy-smaps.h"
G_DEFINE_TYPE (EphyRequestAbout, ephy_request_about, SOUP_TYPE_REQUEST)
struct _EphyRequestAboutPrivate {
gssize content_length;
gchar *css_style;
+ EphySMaps *smaps;
};
static void
@@ -30,12 +45,16 @@ ephy_request_about_init (EphyRequestAbout *about)
about->priv = G_TYPE_INSTANCE_GET_PRIVATE (about, EPHY_TYPE_REQUEST_ABOUT, EphyRequestAboutPrivate);
about->priv->content_length = 0;
about->priv->css_style = NULL;
+ about->priv->smaps = ephy_smaps_new ();
}
static void
ephy_request_about_finalize (GObject *obj)
{
- g_free (EPHY_REQUEST_ABOUT (obj)->priv->css_style);
+ EphyRequestAboutPrivate *priv = EPHY_REQUEST_ABOUT (obj)->priv;
+
+ g_object_unref (priv->smaps);
+ g_free (priv->css_style);
G_OBJECT_CLASS (ephy_request_about_parent_class)->finalize (obj);
}
@@ -114,6 +133,18 @@ ephy_request_about_send (SoupRequest *request,
webkit_web_plugin_database_plugins_list_free (plugin_list);
g_string_append (data_str, "</body>");
+ } else if (!g_strcmp0 (uri->path, "memory")) {
+ char *memory = ephy_smaps_to_html (EPHY_REQUEST_ABOUT (request)->priv->smaps);
+
+ if (memory) {
+ g_string_append_printf (data_str, "<head><title>%s</title>" \
+ "<style type=\"text/css\">%s</style></head><body>",
+ _("Memory usage"),
+ about->priv->css_style);
+
+ g_string_append (data_str, memory);
+ g_free (memory);
+ }
} else if (!g_strcmp0 (uri->path, "epiphany")) {
g_string_append_printf (data_str, "<head><title>Epiphany</title>" \