[sysprof] profiler: dont authorize during profiler startup



commit 2850858d24668ca589bc2617c561215dc8636c1f
Author: Christian Hergert <chergert redhat com>
Date:   Fri Aug 21 13:02:43 2020 -0700

    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.

 src/libsysprof/sysprof-local-profiler.c | 50 ++++++++-------------------------
 1 file changed, 12 insertions(+), 38 deletions(-)
---
diff --git a/src/libsysprof/sysprof-local-profiler.c b/src/libsysprof/sysprof-local-profiler.c
index 62fdea1b..2c126e37 100644
--- a/src/libsysprof/sysprof-local-profiler.c
+++ b/src/libsysprof/sysprof-local-profiler.c
@@ -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)


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