libsysprof/instruments: add set_connection() vfunc

This is used to tell the instruments what GDBusConnection they should use
to query sysprofd. Lack of a connection means they should try to do things
in process without querying sysprofd.
This commit is contained in:
Christian Hergert
2025-03-21 12:00:55 -07:00
parent 2971f34541
commit 637dfceb85
2 changed files with 20 additions and 0 deletions

View File

@ -39,6 +39,8 @@ struct _SysprofInstrumentClass
GObjectClass parent_class;
char **(*list_required_policy) (SysprofInstrument *self);
void (*set_connection) (SysprofInstrument *self,
GDBusConnection *connection);
DexFuture *(*prepare) (SysprofInstrument *self,
SysprofRecording *recording);
DexFuture *(*record) (SysprofInstrument *self,
@ -52,6 +54,8 @@ struct _SysprofInstrumentClass
const char *comm);
};
void _sysprof_instruments_set_connection (GPtrArray *instruments,
GDBusConnection *connection);
DexFuture *_sysprof_instruments_acquire_policy (GPtrArray *instruments,
SysprofRecording *recording);
DexFuture *_sysprof_instruments_prepare (GPtrArray *instruments,

View File

@ -310,3 +310,19 @@ _sysprof_instruments_process_started (GPtrArray *instruments,
return dex_future_allv ((DexFuture **)futures->pdata, futures->len);
}
void
_sysprof_instruments_set_connection (GPtrArray *instruments,
GDBusConnection *connection)
{
g_return_if_fail (instruments != NULL);
g_return_if_fail (!connection || G_IS_DBUS_CONNECTION (connection));
for (guint i = 0; i < instruments->len; i++)
{
SysprofInstrument *instrument = g_ptr_array_index (instruments, i);
if (SYSPROF_INSTRUMENT_GET_CLASS (instrument)->set_connection)
SYSPROF_INSTRUMENT_GET_CLASS (instrument)->set_connection (instrument, connection);
}
}