profiler: dont authorize during profiler startup

This should be done by sources, as there are configurations that will not
require polkit communication and that can be frustrating when it happens.
This commit is contained in:
Christian Hergert
2020-08-21 13:02:43 -07:00
parent e968518083
commit 2850858d24

View File

@ -535,27 +535,26 @@ sysprof_local_profiler_wait_cb (GObject *object,
}
static void
sysprof_local_profiler_authorize_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
sysprof_local_profiler_start (SysprofProfiler *profiler)
{
SysprofHelpers *helpers = (SysprofHelpers *)object;
g_autoptr(SysprofLocalProfiler) self = user_data;
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
g_autoptr(SysprofControlSource) control_source = NULL;
g_autofree gchar *keydata = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GKeyFile) keyfile = NULL;
gsize keylen = 0;
g_assert (SYSPROF_IS_HELPERS (helpers));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (SYSPROF_IS_LOCAL_PROFILER (self));
g_return_if_fail (SYSPROF_IS_LOCAL_PROFILER (self));
g_return_if_fail (priv->is_running == FALSE);
g_return_if_fail (priv->is_stopping == FALSE);
g_return_if_fail (priv->is_starting == FALSE);
if (!sysprof_helpers_authorize_finish (helpers, result, &error))
{
sysprof_profiler_emit_failed (SYSPROF_PROFILER (self), error);
return;
}
g_clear_pointer (&priv->timer, g_timer_destroy);
g_object_notify (G_OBJECT (self), "elapsed");
control_source = sysprof_control_source_new ();
sysprof_profiler_add_source (SYSPROF_PROFILER (self), SYSPROF_SOURCE (control_source));
keyfile = g_key_file_new ();
@ -709,31 +708,6 @@ sysprof_local_profiler_authorize_cb (GObject *object,
sysprof_local_profiler_finish_startup (self);
}
static void
sysprof_local_profiler_start (SysprofProfiler *profiler)
{
SysprofLocalProfiler *self = (SysprofLocalProfiler *)profiler;
SysprofLocalProfilerPrivate *priv = sysprof_local_profiler_get_instance_private (self);
SysprofHelpers *helpers = sysprof_helpers_get_default ();
g_autoptr(SysprofControlSource) control_source = NULL;
g_return_if_fail (SYSPROF_IS_LOCAL_PROFILER (self));
g_return_if_fail (priv->is_running == FALSE);
g_return_if_fail (priv->is_stopping == FALSE);
g_return_if_fail (priv->is_starting == FALSE);
g_clear_pointer (&priv->timer, g_timer_destroy);
g_object_notify (G_OBJECT (self), "elapsed");
control_source = sysprof_control_source_new ();
sysprof_profiler_add_source (SYSPROF_PROFILER (self), SYSPROF_SOURCE (control_source));
sysprof_helpers_authorize_async (helpers,
NULL,
sysprof_local_profiler_authorize_cb,
g_object_ref (self));
}
static void
sysprof_local_profiler_set_writer (SysprofProfiler *profiler,
SysprofCaptureWriter *writer)