[gnome-software] Use AsProfile to clean up our profiling code
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Use AsProfile to clean up our profiling code
- Date: Thu, 24 Sep 2015 16:08:06 +0000 (UTC)
commit 5fcdc20f27ab9009aad014b19c4d9dfc3bc1d559
Author: Richard Hughes <richard hughsie com>
Date: Thu Sep 24 17:07:49 2015 +0100
Use AsProfile to clean up our profiling code
We also get a lot more information from appstream-glib this way too.
configure.ac | 2 +-
src/Makefile.am | 6 +-
src/gs-application.c | 7 +-
src/gs-cmd.c | 12 +-
src/gs-main.c | 10 +-
src/gs-plugin-loader.c | 276 ++++++++++---------------
src/gs-plugin.h | 4 +-
src/gs-profile.c | 308 ----------------------------
src/gs-profile.h | 44 ----
src/plugins/gs-plugin-appstream.c | 38 ++--
src/plugins/gs-plugin-limba.c | 13 +-
src/plugins/gs-plugin-moduleset.c | 12 +-
src/plugins/gs-plugin-packagekit-refine.c | 43 ++---
src/plugins/gs-plugin-packagekit-refresh.c | 8 +-
src/plugins/gs-plugin-packagekit.c | 12 +-
15 files changed, 184 insertions(+), 611 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ae77dd5..f1c1e32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -61,7 +61,7 @@ dnl - Check library dependencies
dnl ---------------------------------------------------------------------------
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.17.7 gio-unix-2.0)
PKG_CHECK_MODULES(PACKAGEKIT, packagekit-glib2 >= 1.0.9)
-PKG_CHECK_MODULES(APPSTREAM, appstream-glib >= 0.5.1)
+PKG_CHECK_MODULES(APPSTREAM, appstream-glib >= 0.5.2)
PKG_CHECK_MODULES(SQLITE, sqlite3)
PKG_CHECK_MODULES(SOUP, libsoup-2.4 >= 2.51.92)
PKG_CHECK_MODULES(GSETTINGS_DESKTOP_SCHEMAS, gsettings-desktop-schemas >= 3.11.5)
diff --git a/src/Makefile.am b/src/Makefile.am
index 903caf7..7f722d8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -81,8 +81,7 @@ gnome_software_cmd_SOURCES = \
gs-plugin-loader.c \
gs-plugin-loader-sync.c \
gs-category.c \
- gs-plugin.c \
- gs-profile.c
+ gs-plugin.c
gnome_software_cmd_LDADD = \
$(APPSTREAM_LIBS) \
@@ -138,8 +137,6 @@ gnome_software_SOURCES = \
gs-page.h \
gs-plugin.c \
gs-plugin.h \
- gs-profile.c \
- gs-profile.h \
gs-progress-button.c \
gs-progress-button.h \
gs-screenshot-image.c \
@@ -259,7 +256,6 @@ gs_self_test_SOURCES = \
gs-plugin-loader-sync.c \
gs-plugin-loader.c \
gs-plugin.c \
- gs-profile.c \
gs-utils.c \
gs-self-test.c
diff --git a/src/gs-application.c b/src/gs-application.c
index f07f32d..43dd957 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -42,7 +42,6 @@
#include "gs-update-monitor.h"
#include "gs-proxy-settings.h"
#include "gs-plugin-loader.h"
-#include "gs-profile.h"
#include "gs-shell-search-provider.h"
#include "gs-offline-updates.h"
#include "gs-folders.h"
@@ -51,7 +50,7 @@
struct _GsApplication {
GtkApplication parent;
- GsProfile *profile;
+ AsProfile *profile;
GCancellable *cancellable;
GtkApplication *application;
GtkCssProvider *provider;
@@ -107,7 +106,7 @@ gs_application_init (GsApplication *application)
g_application_add_main_option_entries (G_APPLICATION (application), options);
- application->profile = gs_profile_new ();
+ application->profile = as_profile_new ();
}
static void
@@ -359,7 +358,7 @@ profile_activated (GSimpleAction *action,
gpointer data)
{
GsApplication *app = GS_APPLICATION (data);
- gs_profile_dump (app->profile);
+ as_profile_dump (app->profile);
}
static void
diff --git a/src/gs-cmd.c b/src/gs-cmd.c
index e425137..492e1bf 100644
--- a/src/gs-cmd.c
+++ b/src/gs-cmd.c
@@ -21,11 +21,11 @@
#include "config.h"
+#include <appstream-glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <locale.h>
-#include "gs-profile.h"
#include "gs-plugin-loader.h"
#include "gs-plugin-loader-sync.h"
@@ -184,7 +184,8 @@ main (int argc, char **argv)
g_autofree gchar *refine_flags_str = NULL;
g_autoptr(GsApp) app = NULL;
g_autoptr(GsPluginLoader) plugin_loader = NULL;
- g_autoptr(GsProfile) profile = NULL;
+ g_autoptr(AsProfile) profile = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
const GOptionEntry options[] = {
{ "show-results", '\0', 0, G_OPTION_ARG_NONE, &show_results,
"Show the results for the action", NULL },
@@ -227,8 +228,8 @@ main (int argc, char **argv)
goto out;
}
- profile = gs_profile_new ();
- gs_profile_start (profile, "GsCmd");
+ profile = as_profile_new ();
+ ptask = as_profile_start_literal (profile, "GsCmd");
/* load plugins */
plugin_loader = gs_plugin_loader_new ();
@@ -397,8 +398,7 @@ main (int argc, char **argv)
gs_cmd_show_results_categories (categories);
}
out:
- gs_profile_stop (profile, "GsCmd");
- gs_profile_dump (profile);
+ as_profile_dump (profile);
g_option_context_free (context);
gs_plugin_list_free (list);
gs_plugin_list_free (categories);
diff --git a/src/gs-main.c b/src/gs-main.c
index a92b5cb..2a7bd3a 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -22,20 +22,21 @@
#include "config.h"
+#include <appstream-glib.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <locale.h>
#include "gs-application.h"
-#include "gs-profile.h"
int
main (int argc, char **argv)
{
int status = 0;
g_autoptr(GsApplication) application = NULL;
- g_autoptr(GsProfile) profile = NULL;
+ g_autoptr(AsProfile) profile = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
setlocale (LC_ALL, "");
@@ -43,11 +44,10 @@ main (int argc, char **argv)
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- profile = gs_profile_new ();
- gs_profile_start (profile, "GsMain");
+ profile = as_profile_new ();
+ ptask = as_profile_start_literal (profile, "GsMain");
application = gs_application_new ();
status = g_application_run (G_APPLICATION (application), argc, argv);
- gs_profile_stop (profile, "GsMain");
return status;
}
diff --git a/src/gs-plugin-loader.c b/src/gs-plugin-loader.c
index 15199cf..f463e52 100644
--- a/src/gs-plugin-loader.c
+++ b/src/gs-plugin-loader.c
@@ -26,7 +26,6 @@
#include "gs-plugin-loader.h"
#include "gs-plugin.h"
-#include "gs-profile.h"
#define GS_PLUGIN_LOADER_UPDATES_CHANGED_DELAY 3 /* s */
@@ -35,7 +34,7 @@ typedef struct
GPtrArray *plugins;
gchar *location;
GsPluginStatus status_last;
- GsProfile *profile;
+ AsProfile *profile;
GMutex pending_apps_mutex;
GPtrArray *pending_apps;
@@ -188,10 +187,10 @@ gs_plugin_loader_run_refine_plugin (GsPluginLoader *plugin_loader,
{
GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
GsPluginRefineFunc plugin_func = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
const gchar *function_name = "gs_plugin_refine";
gboolean exists;
gboolean ret = TRUE;
- g_autofree gchar *profile_id = NULL;
/* load the symbol */
exists = g_module_symbol (plugin->module,
@@ -202,16 +201,17 @@ gs_plugin_loader_run_refine_plugin (GsPluginLoader *plugin_loader,
/* profile the plugin runtime */
if (function_name_parent == NULL) {
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name,
- function_name);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
} else {
- profile_id = g_strdup_printf ("GsPlugin::%s(%s;%s)",
- plugin->name,
- function_name_parent,
- function_name);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s;%s)",
+ plugin->name,
+ function_name_parent,
+ function_name);
}
- gs_profile_start (priv->profile, profile_id);
ret = plugin_func (plugin, list, flags, cancellable, error);
if (!ret) {
/* check the plugin is well behaved and sets error
@@ -235,10 +235,7 @@ gs_plugin_loader_run_refine_plugin (GsPluginLoader *plugin_loader,
goto out;
}
out:
- if (profile_id != NULL) {
- gs_profile_stop (priv->profile, profile_id);
- gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- }
+ gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
return ret;
}
@@ -363,7 +360,7 @@ gs_plugin_loader_run_results_plugin (GsPluginLoader *plugin_loader,
GsPluginResultsFunc plugin_func = NULL;
gboolean exists;
gboolean ret = TRUE;
- g_autofree gchar *profile_id = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
/* get symbol */
exists = g_module_symbol (plugin->module,
@@ -373,18 +370,15 @@ gs_plugin_loader_run_results_plugin (GsPluginLoader *plugin_loader,
goto out;
/* run function */
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name, function_name);
g_assert (error == NULL || *error == NULL);
ret = plugin_func (plugin, list, cancellable, error);
if (!ret)
goto out;
out:
- if (profile_id != NULL) {
- gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
- }
+ gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
return ret;
}
@@ -403,7 +397,7 @@ gs_plugin_loader_run_results (GsPluginLoader *plugin_loader,
GList *list = NULL;
GsPlugin *plugin;
guint i;
- g_autofree gchar *profile_id_parent = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
g_return_val_if_fail (GS_IS_PLUGIN_LOADER (plugin_loader), NULL);
g_return_val_if_fail (function_name != NULL, NULL);
@@ -411,9 +405,7 @@ gs_plugin_loader_run_results (GsPluginLoader *plugin_loader,
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
/* profile */
- profile_id_parent = g_strdup_printf ("GsPlugin::*(%s)",
- function_name);
- gs_profile_start (priv->profile, profile_id_parent);
+ ptask = as_profile_start (priv->profile, "GsPlugin::*(%s)", function_name);
/* run each plugin */
for (i = 0; i < priv->plugins->len; i++) {
@@ -460,7 +452,6 @@ gs_plugin_loader_run_results (GsPluginLoader *plugin_loader,
goto out;
}
out:
- gs_profile_stop (priv->profile, profile_id_parent);
if (!ret) {
gs_plugin_list_free (list);
list = NULL;
@@ -659,16 +650,17 @@ gs_plugin_loader_run_action_plugin (GsPluginLoader *plugin_loader,
GsPluginActionFunc plugin_func = NULL;
gboolean exists;
gboolean ret = TRUE;
- g_autofree gchar *profile_id = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
exists = g_module_symbol (plugin->module,
function_name,
(gpointer *) &plugin_func);
if (!exists)
goto out;
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
ret = plugin_func (plugin, app, cancellable, &error_local);
if (!ret) {
if (g_error_matches (error_local,
@@ -685,10 +677,7 @@ gs_plugin_loader_run_action_plugin (GsPluginLoader *plugin_loader,
}
}
out:
- if (profile_id != NULL) {
- gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
- }
+ gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
return ret;
}
@@ -1409,7 +1398,6 @@ gs_plugin_loader_search_thread_cb (GTask *task,
GsPlugin *plugin;
GsPluginSearchFunc plugin_func = NULL;
guint i;
- g_autofree gchar *profile_id = NULL;
g_auto(GStrv) values = NULL;
/* run each plugin */
@@ -1419,31 +1407,31 @@ gs_plugin_loader_search_thread_cb (GTask *task,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"no valid search terms");
- goto out;
+ return;
}
for (i = 0; i < priv->plugins->len; i++) {
+ g_autoptr(AsProfileTask) ptask = NULL;
plugin = g_ptr_array_index (priv->plugins, i);
if (!plugin->enabled)
continue;
ret = g_task_return_error_if_cancelled (task);
if (ret)
- goto out;
+ return;
ret = g_module_symbol (plugin->module,
function_name,
(gpointer *) &plugin_func);
if (!ret)
continue;
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
ret = plugin_func (plugin, values, &state->list, cancellable, &error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
- g_clear_pointer (&profile_id, g_free);
}
/* dedupe applications we already know about */
@@ -1458,7 +1446,7 @@ gs_plugin_loader_search_thread_cb (GTask *task,
&error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
/* convert any unavailables */
@@ -1474,21 +1462,18 @@ gs_plugin_loader_search_thread_cb (GTask *task,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"no search results to show");
- goto out;
+ return;
}
if (g_list_length (state->list) > 500) {
g_task_return_new_error (task,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"Too many search results returned");
- goto out;
+ return;
}
/* success */
g_task_return_pointer (task, gs_plugin_list_copy (state->list), (GDestroyNotify) gs_plugin_list_free);
-out:
- if (profile_id != NULL)
- gs_profile_stop (priv->profile, profile_id);
}
/**
@@ -1576,7 +1561,6 @@ gs_plugin_loader_search_files_thread_cb (GTask *task,
GsPlugin *plugin;
GsPluginSearchFunc plugin_func = NULL;
guint i;
- g_autofree gchar *profile_id = NULL;
g_auto(GStrv) values = NULL;
values = g_new0 (gchar *, 2);
@@ -1584,28 +1568,28 @@ gs_plugin_loader_search_files_thread_cb (GTask *task,
/* run each plugin */
for (i = 0; i < priv->plugins->len; i++) {
+ g_autoptr(AsProfileTask) ptask = NULL;
plugin = g_ptr_array_index (priv->plugins, i);
if (!plugin->enabled)
continue;
ret = g_task_return_error_if_cancelled (task);
if (ret)
- goto out;
+ return;
ret = g_module_symbol (plugin->module,
function_name,
(gpointer *) &plugin_func);
if (!ret)
continue;
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
ret = plugin_func (plugin, values, &state->list, cancellable, &error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
- g_clear_pointer (&profile_id, g_free);
}
/* dedupe applications we already know about */
@@ -1620,7 +1604,7 @@ gs_plugin_loader_search_files_thread_cb (GTask *task,
&error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
/* convert any unavailables */
@@ -1637,21 +1621,18 @@ gs_plugin_loader_search_files_thread_cb (GTask *task,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"no search results to show");
- goto out;
+ return;
}
if (g_list_length (state->list) > 500) {
g_task_return_new_error (task,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"Too many search results returned");
- goto out;
+ return;
}
/* success */
g_task_return_pointer (task, gs_plugin_list_copy (state->list), (GDestroyNotify) gs_plugin_list_free);
-out:
- if (profile_id != NULL)
- gs_profile_stop (priv->profile, profile_id);
}
/**
@@ -1739,7 +1720,6 @@ gs_plugin_loader_search_what_provides_thread_cb (GTask *task,
GsPlugin *plugin;
GsPluginSearchFunc plugin_func = NULL;
guint i;
- g_autofree gchar *profile_id = NULL;
g_auto(GStrv) values = NULL;
values = g_new0 (gchar *, 2);
@@ -1747,28 +1727,28 @@ gs_plugin_loader_search_what_provides_thread_cb (GTask *task,
/* run each plugin */
for (i = 0; i < priv->plugins->len; i++) {
+ g_autoptr(AsProfileTask) ptask = NULL;
plugin = g_ptr_array_index (priv->plugins, i);
if (!plugin->enabled)
continue;
ret = g_task_return_error_if_cancelled (task);
if (ret)
- goto out;
+ return;
ret = g_module_symbol (plugin->module,
function_name,
(gpointer *) &plugin_func);
if (!ret)
continue;
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
ret = plugin_func (plugin, values, &state->list, cancellable, &error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
- g_clear_pointer (&profile_id, g_free);
}
/* dedupe applications we already know about */
@@ -1783,7 +1763,7 @@ gs_plugin_loader_search_what_provides_thread_cb (GTask *task,
&error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
/* convert any unavailables */
@@ -1800,21 +1780,18 @@ gs_plugin_loader_search_what_provides_thread_cb (GTask *task,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"no search results to show");
- goto out;
+ return;
}
if (g_list_length (state->list) > 500) {
g_task_return_new_error (task,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"Too many search results returned");
- goto out;
+ return;
}
/* success */
g_task_return_pointer (task, gs_plugin_list_copy (state->list), (GDestroyNotify) gs_plugin_list_free);
-out:
- if (profile_id != NULL)
- gs_profile_stop (priv->profile, profile_id);
}
/**
@@ -1913,32 +1890,31 @@ gs_plugin_loader_get_categories_thread_cb (GTask *task,
GsPluginResultsFunc plugin_func = NULL;
GList *l;
guint i;
- g_autofree gchar *profile_id = NULL;
/* run each plugin */
for (i = 0; i < priv->plugins->len; i++) {
+ g_autoptr(AsProfileTask) ptask = NULL;
plugin = g_ptr_array_index (priv->plugins, i);
if (!plugin->enabled)
continue;
ret = g_task_return_error_if_cancelled (task);
if (ret)
- goto out;
+ return;
ret = g_module_symbol (plugin->module,
function_name,
(gpointer *) &plugin_func);
if (!ret)
continue;
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
ret = plugin_func (plugin, &state->list, cancellable, &error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
- g_clear_pointer (&profile_id, g_free);
}
/* sort by name */
@@ -1952,14 +1928,11 @@ gs_plugin_loader_get_categories_thread_cb (GTask *task,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"no categories to show");
- goto out;
+ return;
}
/* success */
g_task_return_pointer (task, gs_plugin_list_copy (state->list), (GDestroyNotify) gs_plugin_list_free);
-out:
- if (profile_id != NULL)
- gs_profile_stop (priv->profile, profile_id);
}
/**
@@ -2030,32 +2003,31 @@ gs_plugin_loader_get_category_apps_thread_cb (GTask *task,
GsPlugin *plugin;
GsPluginCategoryFunc plugin_func = NULL;
guint i;
- g_autofree gchar *profile_id = NULL;
/* run each plugin */
for (i = 0; i < priv->plugins->len; i++) {
+ g_autoptr(AsProfileTask) ptask = NULL;
plugin = g_ptr_array_index (priv->plugins, i);
if (!plugin->enabled)
continue;
ret = g_task_return_error_if_cancelled (task);
if (ret)
- goto out;
+ return;
ret = g_module_symbol (plugin->module,
function_name,
(gpointer *) &plugin_func);
if (!ret)
continue;
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
ret = plugin_func (plugin, state->category, &state->list, cancellable, &error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
- g_clear_pointer (&profile_id, g_free);
}
/* dedupe applications we already know about */
@@ -2070,7 +2042,7 @@ gs_plugin_loader_get_category_apps_thread_cb (GTask *task,
&error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
/* filter package list */
@@ -2084,7 +2056,7 @@ gs_plugin_loader_get_category_apps_thread_cb (GTask *task,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"no get_category_apps results to show");
- goto out;
+ return;
}
/* sort, just in case the UI doesn't do this */
@@ -2092,9 +2064,6 @@ gs_plugin_loader_get_category_apps_thread_cb (GTask *task,
/* success */
g_task_return_pointer (task, gs_plugin_list_copy (state->list), (GDestroyNotify) gs_plugin_list_free);
-out:
- if (profile_id != NULL)
- gs_profile_stop (priv->profile, profile_id);
}
/**
@@ -2642,19 +2611,19 @@ gs_plugin_loader_run (GsPluginLoader *plugin_loader, const gchar *function_name)
/* run each plugin */
for (i = 0; i < priv->plugins->len; i++) {
- g_autofree gchar *profile_id = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
plugin = g_ptr_array_index (priv->plugins, i);
ret = g_module_symbol (plugin->module,
function_name,
(gpointer *) &plugin_func);
if (!ret)
continue;
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
plugin_func (plugin);
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
}
}
@@ -2907,23 +2876,21 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader, GError **error)
const gchar *filename_tmp;
const gdouble dep_increment = 1.f;
gboolean changes;
- gboolean ret = TRUE;
GsPlugin *dep;
GsPlugin *plugin;
guint dep_loop_check = 0;
guint i;
guint j;
g_autoptr(GDir) dir = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
g_return_val_if_fail (priv->location != NULL, FALSE);
/* search in the plugin directory for plugins */
- gs_profile_start (priv->profile, "GsPlugin::setup");
+ ptask = as_profile_start_literal (priv->profile, "GsPlugin::setup");
dir = g_dir_open (priv->location, 0, error);
- if (dir == NULL) {
- ret = FALSE;
- goto out;
- }
+ if (dir == NULL)
+ return FALSE;
/* try to open each plugin */
g_debug ("searching for plugins in %s", priv->location);
@@ -2971,12 +2938,11 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader, GError **error)
/* check we're not stuck */
if (dep_loop_check++ > 100) {
- ret = FALSE;
g_set_error (error,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_FAILED,
"got stuck in dep loop");
- goto out;
+ return FALSE;
}
} while (changes);
@@ -2988,12 +2954,9 @@ gs_plugin_loader_setup (GsPluginLoader *plugin_loader, GError **error)
gs_plugin_loader_run (plugin_loader, "gs_plugin_initialize");
/* now we can load the install-queue */
- ret = load_install_queue (plugin_loader, error);
- if (!ret)
- goto out;
-out:
- gs_profile_stop (priv->profile, "GsPlugin::setup");
- return ret;
+ if (!load_install_queue (plugin_loader, error))
+ return FALSE;
+ return TRUE;
}
/**
@@ -3047,11 +3010,7 @@ gs_plugin_loader_dispose (GObject *object)
g_source_remove (priv->updates_changed_id);
priv->updates_changed_id = 0;
}
- if (priv->profile != NULL) {
- gs_profile_stop (priv->profile, "GsPluginLoader");
- g_clear_object (&priv->profile);
- }
-
+ g_clear_object (&priv->profile);
g_clear_object (&priv->settings);
g_clear_pointer (&priv->app_cache, g_hash_table_unref);
g_clear_pointer (&priv->pending_apps, g_ptr_array_unref);
@@ -3125,7 +3084,7 @@ gs_plugin_loader_init (GsPluginLoader *plugin_loader)
priv->plugins = g_ptr_array_new_with_free_func ((GDestroyNotify) gs_plugin_loader_plugin_free);
priv->status_last = GS_PLUGIN_STATUS_LAST;
priv->pending_apps = g_ptr_array_new_with_free_func ((GFreeFunc) g_object_unref);
- priv->profile = gs_profile_new ();
+ priv->profile = as_profile_new ();
priv->settings = g_settings_new ("org.gnome.software");
priv->app_cache = g_hash_table_new_full (g_str_hash,
g_str_equal,
@@ -3135,9 +3094,6 @@ gs_plugin_loader_init (GsPluginLoader *plugin_loader)
g_mutex_init (&priv->pending_apps_mutex);
g_mutex_init (&priv->app_cache_mutex);
- /* application start */
- gs_profile_start (priv->profile, "GsPluginLoader");
-
/* by default we only show project-less apps or compatible projects */
tmp = g_getenv ("GNOME_SOFTWARE_COMPATIBLE_PROJECTS");
if (tmp == NULL) {
@@ -3247,16 +3203,17 @@ gs_plugin_loader_run_refresh_plugin (GsPluginLoader *plugin_loader,
gboolean ret = TRUE;
GError *error_local = NULL;
GsPluginRefreshFunc plugin_func = NULL;
- g_autofree gchar *profile_id = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
exists = g_module_symbol (plugin->module,
function_name,
(gpointer *) &plugin_func);
if (!exists)
goto out;
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
ret = plugin_func (plugin, cache_age, flags, cancellable, &error_local);
if (!ret) {
if (g_error_matches (error_local,
@@ -3273,10 +3230,7 @@ gs_plugin_loader_run_refresh_plugin (GsPluginLoader *plugin_loader,
}
}
out:
- if (profile_id != NULL) {
- gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
- }
+ gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
return ret;
}
@@ -3423,32 +3377,31 @@ gs_plugin_loader_filename_to_app_thread_cb (GTask *task,
GsPlugin *plugin;
GsPluginFilenameToAppFunc plugin_func = NULL;
guint i;
- g_autofree gchar *profile_id = NULL;
/* run each plugin */
for (i = 0; i < priv->plugins->len; i++) {
+ g_autoptr(AsProfileTask) ptask = NULL;
plugin = g_ptr_array_index (priv->plugins, i);
if (!plugin->enabled)
continue;
ret = g_task_return_error_if_cancelled (task);
if (ret)
- goto out;
+ return;
ret = g_module_symbol (plugin->module,
function_name,
(gpointer *) &plugin_func);
if (!ret)
continue;
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
ret = plugin_func (plugin, &state->list, state->filename, cancellable, &error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
- g_clear_pointer (&profile_id, g_free);
}
/* dedupe applications we already know about */
@@ -3463,7 +3416,7 @@ gs_plugin_loader_filename_to_app_thread_cb (GTask *task,
&error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
/* filter package list */
@@ -3473,7 +3426,7 @@ gs_plugin_loader_filename_to_app_thread_cb (GTask *task,
GS_PLUGIN_LOADER_ERROR,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"no filename_to_app results to show");
- goto out;
+ return;
}
/* success */
@@ -3483,12 +3436,9 @@ gs_plugin_loader_filename_to_app_thread_cb (GTask *task,
GS_PLUGIN_LOADER_ERROR_NO_RESULTS,
"no application was created for %s",
state->filename);
- goto out;
+ return;
}
g_task_return_pointer (task, g_object_ref (state->list->data), (GDestroyNotify) g_object_unref);
-out:
- if (profile_id != NULL)
- gs_profile_stop (priv->profile, profile_id);
}
/**
@@ -3567,38 +3517,34 @@ gs_plugin_loader_offline_update_thread_cb (GTask *task,
GsPlugin *plugin;
GsPluginOfflineUpdateFunc plugin_func = NULL;
guint i;
- g_autofree gchar *profile_id = NULL;
/* run each plugin */
for (i = 0; i < priv->plugins->len; i++) {
+ g_autoptr(AsProfileTask) ptask = NULL;
plugin = g_ptr_array_index (priv->plugins, i);
if (!plugin->enabled)
continue;
ret = g_task_return_error_if_cancelled (task);
if (ret)
- goto out;
+ return;
ret = g_module_symbol (plugin->module,
function_name,
(gpointer *) &plugin_func);
if (!ret)
continue;
- profile_id = g_strdup_printf ("GsPlugin::%s(%s)",
- plugin->name, function_name);
- gs_profile_start (priv->profile, profile_id);
+ ptask = as_profile_start (priv->profile,
+ "GsPlugin::%s(%s)",
+ plugin->name,
+ function_name);
ret = plugin_func (plugin, state->list, cancellable, &error);
if (!ret) {
g_task_return_error (task, error);
- goto out;
+ return;
}
gs_plugin_status_update (plugin, NULL, GS_PLUGIN_STATUS_FINISHED);
- gs_profile_stop (priv->profile, profile_id);
- g_clear_pointer (&profile_id, g_free);
}
g_task_return_boolean (task, TRUE);
-out:
- if (profile_id != NULL)
- gs_profile_stop (priv->profile, profile_id);
}
/**
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index 0b31e83..2d7f215 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -22,6 +22,7 @@
#ifndef __GS_PLUGIN_H
#define __GS_PLUGIN_H
+#include <appstream-glib.h>
#include <glib-object.h>
#include <gmodule.h>
#include <gio/gio.h>
@@ -29,7 +30,6 @@
#include "gs-app.h"
#include "gs-category.h"
-#include "gs-profile.h"
G_BEGIN_DECLS
@@ -74,7 +74,7 @@ struct GsPlugin {
gpointer status_update_user_data;
GsPluginUpdatesChanged updates_changed_fn;
gpointer updates_changed_user_data;
- GsProfile *profile;
+ AsProfile *profile;
};
typedef enum {
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 3b2b79a..095e2e7 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -188,8 +188,9 @@ gs_plugin_startup (GsPlugin *plugin, GError **error)
guint *perc;
guint i;
g_autoptr(GHashTable) origins = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
- gs_profile_start (plugin->profile, "appstream::startup");
+ ptask = as_profile_start_literal (plugin->profile, "appstream::startup");
g_mutex_lock (&plugin->priv->store_mutex);
/* clear all existing applications if the store was invalidated */
@@ -252,7 +253,6 @@ gs_plugin_startup (GsPlugin *plugin, GError **error)
}
out:
g_mutex_unlock (&plugin->priv->store_mutex);
- gs_profile_stop (plugin->profile, "appstream::startup");
return ret;
}
@@ -750,6 +750,7 @@ gs_plugin_refine (GsPlugin *plugin,
gboolean found;
GList *l;
GsApp *app;
+ g_autoptr(AsProfileTask) ptask = NULL;
/* load XML files */
if (g_once_init_enter (&plugin->priv->done_init)) {
@@ -759,24 +760,19 @@ gs_plugin_refine (GsPlugin *plugin,
return FALSE;
}
- gs_profile_start (plugin->profile, "appstream::refine");
+ ptask = as_profile_start_literal (plugin->profile, "appstream::refine");
for (l = *list; l != NULL; l = l->next) {
app = GS_APP (l->data);
- ret = gs_plugin_refine_from_id (plugin, app, &found, error);
- if (!ret)
- goto out;
+ if (!gs_plugin_refine_from_id (plugin, app, &found, error))
+ return FALSE;
if (!found) {
- ret = gs_plugin_refine_from_pkgname (plugin, app, error);
- if (!ret)
- goto out;
+ if (!gs_plugin_refine_from_pkgname (plugin, app, error))
+ return FALSE;
}
}
/* sucess */
- ret = TRUE;
-out:
- gs_profile_stop (plugin->profile, "appstream::refine");
- return ret;
+ return TRUE;
}
/**
@@ -796,6 +792,7 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
GsCategory *parent;
GPtrArray *array;
guint i;
+ g_autoptr(AsProfileTask) ptask = NULL;
/* load XML files */
if (g_once_init_enter (&plugin->priv->done_init)) {
@@ -806,7 +803,7 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
}
/* get the two search terms */
- gs_profile_start (plugin->profile, "appstream::add-category-apps");
+ ptask = as_profile_start_literal (plugin->profile, "appstream::add-category-apps");
g_mutex_lock (&plugin->priv->store_mutex);
search_id1 = gs_category_get_id (category);
parent = gs_category_get_parent (category);
@@ -840,7 +837,6 @@ gs_plugin_add_category_apps (GsPlugin *plugin,
}
out:
g_mutex_unlock (&plugin->priv->store_mutex);
- gs_profile_stop (plugin->profile, "appstream::add-category-apps");
return ret;
}
@@ -932,6 +928,7 @@ gs_plugin_add_search (GsPlugin *plugin,
GPtrArray *array;
gboolean ret = TRUE;
guint i;
+ g_autoptr(AsProfileTask) ptask = NULL;
/* load XML files */
if (g_once_init_enter (&plugin->priv->done_init)) {
@@ -942,7 +939,7 @@ gs_plugin_add_search (GsPlugin *plugin,
}
/* search categories for the search term */
- gs_profile_start (plugin->profile, "appstream::search");
+ ptask = as_profile_start_literal (plugin->profile, "appstream::search");
g_mutex_lock (&plugin->priv->store_mutex);
array = as_store_get_apps (plugin->priv->store);
for (i = 0; i < array->len; i++) {
@@ -956,7 +953,6 @@ gs_plugin_add_search (GsPlugin *plugin,
}
out:
g_mutex_unlock (&plugin->priv->store_mutex);
- gs_profile_stop (plugin->profile, "appstream::search");
return ret;
}
@@ -973,6 +969,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
gboolean ret = TRUE;
GPtrArray *array;
guint i;
+ g_autoptr(AsProfileTask) ptask = NULL;
/* load XML files */
if (g_once_init_enter (&plugin->priv->done_init)) {
@@ -983,7 +980,7 @@ gs_plugin_add_installed (GsPlugin *plugin,
}
/* search categories for the search term */
- gs_profile_start (plugin->profile, "appstream::add_installed");
+ ptask = as_profile_start_literal (plugin->profile, "appstream::add_installed");
g_mutex_lock (&plugin->priv->store_mutex);
array = as_store_get_apps (plugin->priv->store);
for (i = 0; i < array->len; i++) {
@@ -999,7 +996,6 @@ gs_plugin_add_installed (GsPlugin *plugin,
}
out:
g_mutex_unlock (&plugin->priv->store_mutex);
- gs_profile_stop (plugin->profile, "appstream::add_installed");
return ret;
}
@@ -1062,6 +1058,7 @@ gs_plugin_add_categories (GsPlugin *plugin,
GPtrArray *array;
gboolean ret = TRUE;
guint i;
+ g_autoptr(AsProfileTask) ptask = NULL;
/* load XML files */
if (g_once_init_enter (&plugin->priv->done_init)) {
@@ -1072,7 +1069,7 @@ gs_plugin_add_categories (GsPlugin *plugin,
}
/* find out how many packages are in each category */
- gs_profile_start (plugin->profile, "appstream::add-categories");
+ ptask = as_profile_start_literal (plugin->profile, "appstream::add-categories");
g_mutex_lock (&plugin->priv->store_mutex);
array = as_store_get_apps (plugin->priv->store);
for (i = 0; i < array->len; i++) {
@@ -1084,6 +1081,5 @@ gs_plugin_add_categories (GsPlugin *plugin,
gs_plugin_add_categories_for_app (*list, app);
}
g_mutex_unlock (&plugin->priv->store_mutex);
- gs_profile_stop (plugin->profile, "appstream::add-categories");
return ret;
}
diff --git a/src/plugins/gs-plugin-limba.c b/src/plugins/gs-plugin-limba.c
index 1814ff6..472c345 100644
--- a/src/plugins/gs-plugin-limba.c
+++ b/src/plugins/gs-plugin-limba.c
@@ -114,24 +114,21 @@ gs_plugin_refine (GsPlugin *plugin,
gboolean ret;
GList *l;
GsApp *app;
+ g_autoptr(AsProfileTask) ptask = NULL;
- gs_profile_start (plugin->profile, "limba::refine");
+ ptask = as_profile_start_literal (plugin->profile, "limba::refine");
for (l = *list; l != NULL; l = l->next) {
app = GS_APP (l->data);
if (gs_app_get_bundle (app) == NULL)
continue;
- ret = gs_plugin_refine_app (plugin, app, error);
- if (!ret)
- goto out;
+ if (!gs_plugin_refine_app (plugin, app, error))
+ return FALSE;
}
/* sucess */
- ret = TRUE;
-out:
- gs_profile_stop (plugin->profile, "limba::refine");
- return ret;
+ return TRUE;
}
/**
diff --git a/src/plugins/gs-plugin-moduleset.c b/src/plugins/gs-plugin-moduleset.c
index ff3bbf9..2235f05 100644
--- a/src/plugins/gs-plugin-moduleset.c
+++ b/src/plugins/gs-plugin-moduleset.c
@@ -81,15 +81,13 @@ gs_plugin_destroy (GsPlugin *plugin)
static gboolean
gs_plugin_startup (GsPlugin *plugin, GError **error)
{
- gboolean ret;
+ g_autoptr(AsProfileTask) ptask = NULL;
/* Parse the XML */
- gs_profile_start (plugin->profile, "moduleset::startup");
- ret = gs_moduleset_parse_path (plugin->priv->moduleset,
- GS_MODULESETDIR,
- error);
- gs_profile_stop (plugin->profile, "moduleset::startup");
- return ret;
+ ptask = as_profile_start_literal (plugin->profile, "moduleset::startup");
+ return gs_moduleset_parse_path (plugin->priv->moduleset,
+ GS_MODULESETDIR,
+ error);
}
gboolean
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index 4f1ec3c..6344168 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -34,6 +34,7 @@ struct GsPluginPrivate {
PkControl *control;
PkClient *client;
GHashTable *sources;
+ AsProfileTask *ptask;
};
/**
@@ -120,11 +121,10 @@ gs_plugin_packagekit_progress_cb (PkProgress *progress,
/* profile */
if (status == PK_STATUS_ENUM_SETUP) {
- gs_profile_start (plugin->profile,
- "packagekit-refine::transaction");
+ plugin->priv->ptask = as_profile_start_literal (plugin->profile,
+ "packagekit-refine::transaction");
} else if (status == PK_STATUS_ENUM_FINISHED) {
- gs_profile_stop (plugin->profile,
- "packagekit-refine::transaction");
+ as_profile_task_free (plugin->priv->ptask);
}
plugin_status = packagekit_status_enum_to_plugin_status (status);
@@ -562,8 +562,9 @@ gs_plugin_refine_require_details (GsPlugin *plugin,
GsApp *app;
gboolean ret = TRUE;
g_autoptr(GList) list_tmp = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
- gs_profile_start (plugin->profile, "packagekit-refine[source->licence]");
+ ptask = as_profile_start_literal (plugin->profile, "packagekit-refine[source->licence]");
for (l = list; l != NULL; l = l->next) {
app = GS_APP (l->data);
if (gs_app_get_id_kind (app) == AS_ID_KIND_WEB_APP)
@@ -575,16 +576,14 @@ gs_plugin_refine_require_details (GsPlugin *plugin,
list_tmp = g_list_prepend (list_tmp, app);
}
if (list_tmp == NULL)
- goto out;
+ return TRUE;
ret = gs_plugin_packagekit_refine_details (plugin,
list_tmp,
cancellable,
error);
if (!ret)
- goto out;
-out:
- gs_profile_stop (plugin->profile, "packagekit-refine[source->licence]");
- return ret;
+ return FALSE;
+ return TRUE;
}
/**
@@ -699,11 +698,11 @@ gs_plugin_refine (GsPlugin *plugin,
GList *l;
GPtrArray *sources;
GsApp *app;
- const gchar *profile_id = NULL;
const gchar *tmp;
gboolean ret = TRUE;
g_autoptr(GList) resolve_all = NULL;
g_autoptr(GList) updatedetails_all = NULL;
+ AsProfileTask *ptask = NULL;
/* get the repo_id -> repo_name mapping set up */
if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN) > 0 &&
@@ -716,8 +715,7 @@ gs_plugin_refine (GsPlugin *plugin,
}
/* can we resolve in one go? */
- profile_id = "packagekit-refine[name->id]";
- gs_profile_start (plugin->profile, profile_id);
+ ptask = as_profile_start_literal (plugin->profile, "packagekit-refine[name->id]");
for (l = *list; l != NULL; l = l->next) {
app = GS_APP (l->data);
if (gs_app_get_id_kind (app) == AS_ID_KIND_WEB_APP)
@@ -740,12 +738,11 @@ gs_plugin_refine (GsPlugin *plugin,
if (!ret)
goto out;
}
- gs_profile_stop (plugin->profile, profile_id);
- profile_id = NULL;
+ as_profile_task_free (ptask);
/* set the package-id for an installed desktop file */
- profile_id = "packagekit-refine[desktop-filename->id]";
- gs_profile_start (plugin->profile, profile_id);
+ ptask = as_profile_start_literal (plugin->profile,
+ "packagekit-refine[desktop-filename->id]");
for (l = *list; l != NULL; l = l->next) {
if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION) == 0)
continue;
@@ -763,12 +760,11 @@ gs_plugin_refine (GsPlugin *plugin,
if (!ret)
goto out;
}
- gs_profile_stop (plugin->profile, profile_id);
- profile_id = NULL;
+ as_profile_task_free (ptask);
/* any update details missing? */
- profile_id = "packagekit-refine[id->update-details]";
- gs_profile_start (plugin->profile, profile_id);
+ ptask = as_profile_start_literal (plugin->profile,
+ "packagekit-refine[id->update-details]");
for (l = *list; l != NULL; l = l->next) {
app = GS_APP (l->data);
if (gs_app_get_state (app) != AS_APP_STATE_UPDATABLE)
@@ -784,8 +780,7 @@ gs_plugin_refine (GsPlugin *plugin,
if (!ret)
goto out;
}
- gs_profile_stop (plugin->profile, profile_id);
- profile_id = NULL;
+ as_profile_task_free (ptask);
/* any important details missing? */
if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENCE) > 0 ||
@@ -800,7 +795,5 @@ gs_plugin_refine (GsPlugin *plugin,
goto out;
}
out:
- if (profile_id != NULL)
- gs_profile_stop (plugin->profile, profile_id);
return ret;
}
diff --git a/src/plugins/gs-plugin-packagekit-refresh.c b/src/plugins/gs-plugin-packagekit-refresh.c
index cd558b7..b7aaf04 100644
--- a/src/plugins/gs-plugin-packagekit-refresh.c
+++ b/src/plugins/gs-plugin-packagekit-refresh.c
@@ -31,6 +31,7 @@
struct GsPluginPrivate {
PkTask *task;
+ AsProfileTask *ptask;
};
/**
@@ -84,11 +85,10 @@ gs_plugin_packagekit_progress_cb (PkProgress *progress,
/* profile */
if (status == PK_STATUS_ENUM_SETUP) {
- gs_profile_start (plugin->profile,
- "packagekit-refresh::transaction");
+ plugin->priv->ptask = as_profile_start_literal (plugin->profile,
+ "packagekit-refresh::transaction");
} else if (status == PK_STATUS_ENUM_FINISHED) {
- gs_profile_stop (plugin->profile,
- "packagekit-refresh::transaction");
+ as_profile_task_free (plugin->priv->ptask);
}
plugin_status = packagekit_status_enum_to_plugin_status (status);
diff --git a/src/plugins/gs-plugin-packagekit.c b/src/plugins/gs-plugin-packagekit.c
index 337e78d..efeeee7 100644
--- a/src/plugins/gs-plugin-packagekit.c
+++ b/src/plugins/gs-plugin-packagekit.c
@@ -68,6 +68,7 @@ gs_plugin_destroy (GsPlugin *plugin)
typedef struct {
GsApp *app;
GsPlugin *plugin;
+ AsProfileTask *ptask;
} ProgressData;
/**
@@ -90,11 +91,10 @@ gs_plugin_packagekit_progress_cb (PkProgress *progress,
/* profile */
if (status == PK_STATUS_ENUM_SETUP) {
- gs_profile_start (plugin->profile,
- "packagekit-refine::transaction");
+ data->ptask = as_profile_start_literal (plugin->profile,
+ "packagekit-refine::transaction");
} else if (status == PK_STATUS_ENUM_FINISHED) {
- gs_profile_stop (plugin->profile,
- "packagekit-refine::transaction");
+ as_profile_task_free (data->ptask);
}
plugin_status = packagekit_status_enum_to_plugin_status (status);
@@ -167,11 +167,12 @@ gs_plugin_add_sources_related (GsPlugin *plugin,
const gchar *id;
gboolean ret = TRUE;
g_autoptr(PkResults) results = NULL;
+ g_autoptr(AsProfileTask) ptask = NULL;
data.app = NULL;
data.plugin = plugin;
- gs_profile_start (plugin->profile, "packagekit::add-sources-related");
+ ptask = as_profile_start_literal (plugin->profile, "packagekit::add-sources-related");
filter = pk_bitfield_from_enums (PK_FILTER_ENUM_INSTALLED,
PK_FILTER_ENUM_NEWEST,
PK_FILTER_ENUM_ARCH,
@@ -207,7 +208,6 @@ gs_plugin_add_sources_related (GsPlugin *plugin,
}
}
out:
- gs_profile_stop (plugin->profile, "packagekit::add-sources-related");
gs_plugin_list_free (installed);
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]