[gnome-software: 8/25] gs-plugin-job-refine: Inline a helper function




commit 1d5a1e2d4d5d4f9c60da99e255ede2e5cf20b622
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Feb 23 16:19:15 2022 +0000

    gs-plugin-job-refine: Inline a helper function
    
    `run_refine()` needs to be made asynchronous to fix #1658, and having
    this helper function separate will only complicate that.
    
    This commit introduces no functional changes.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Hels: #1658

 lib/gs-plugin-job-refine.c | 66 ++++++++++++++++++----------------------------
 1 file changed, 25 insertions(+), 41 deletions(-)
---
diff --git a/lib/gs-plugin-job-refine.c b/lib/gs-plugin-job-refine.c
index f47abf8df..4e4f3e97e 100644
--- a/lib/gs-plugin-job-refine.c
+++ b/lib/gs-plugin-job-refine.c
@@ -173,18 +173,33 @@ static void plugin_refine_cb (GObject      *source_object,
                               GAsyncResult *result,
                               gpointer      user_data);
 
+static void
+plugin_refine_cb (GObject      *source_object,
+                  GAsyncResult *result,
+                  gpointer      user_data)
+{
+       GAsyncResult **result_out = user_data;
+
+       g_assert (*result_out == NULL);
+       *result_out = g_object_ref (result);
+       g_main_context_wakeup (g_main_context_get_thread_default ());
+}
+
 static gboolean
-run_refine_filter (GsPluginJobRefine    *self,
-                   GsPluginLoader       *plugin_loader,
-                   GsAppList            *list,
-                   GsPluginRefineFlags   refine_flags,
-                   GCancellable         *cancellable,
-                   GError              **error)
+run_refine_internal (GsPluginJobRefine    *self,
+                     GsPluginLoader       *plugin_loader,
+                     GsAppList            *list,
+                     GsPluginRefineFlags   flags,
+                     GCancellable         *cancellable,
+                     GError              **error)
 {
        GsOdrsProvider *odrs_provider;
        GsOdrsProviderRefineFlags odrs_refine_flags = 0;
        GPtrArray *plugins;  /* (element-type GsPlugin) */
 
+       /* try to adopt each application with a plugin */
+       gs_plugin_loader_run_adopt (plugin_loader, list);
+
        /* run each plugin */
        plugins = gs_plugin_loader_get_plugins (plugin_loader);
 
@@ -199,7 +214,7 @@ run_refine_filter (GsPluginJobRefine    *self,
                        continue;
 
                /* run the batched plugin symbol */
-               plugin_class->refine_async (plugin, list, refine_flags,
+               plugin_class->refine_async (plugin, list, flags,
                                            cancellable, plugin_refine_cb, &refine_result);
 
                /* FIXME: Make this sync until the calling function is rearranged
@@ -216,10 +231,10 @@ run_refine_filter (GsPluginJobRefine    *self,
        /* Add ODRS data if needed */
        odrs_provider = gs_plugin_loader_get_odrs_provider (plugin_loader);
 
-       if (refine_flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS)
+       if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS)
                odrs_refine_flags |= GS_ODRS_PROVIDER_REFINE_FLAGS_GET_REVIEWS;
-       if (refine_flags & (GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS |
-                           GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING))
+       if (flags & (GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS |
+                    GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING))
                odrs_refine_flags |= GS_ODRS_PROVIDER_REFINE_FLAGS_GET_RATINGS;
 
        if (odrs_provider != NULL && odrs_refine_flags != 0) {
@@ -239,37 +254,6 @@ run_refine_filter (GsPluginJobRefine    *self,
 
        /* filter any wildcard apps left in the list */
        gs_app_list_filter (list, app_is_non_wildcard, NULL);
-       return TRUE;
-}
-
-static void
-plugin_refine_cb (GObject      *source_object,
-                  GAsyncResult *result,
-                  gpointer      user_data)
-{
-       GAsyncResult **result_out = user_data;
-
-       g_assert (*result_out == NULL);
-       *result_out = g_object_ref (result);
-       g_main_context_wakeup (g_main_context_get_thread_default ());
-}
-
-static gboolean
-run_refine_internal (GsPluginJobRefine    *self,
-                     GsPluginLoader       *plugin_loader,
-                     GsAppList            *list,
-                     GsPluginRefineFlags   flags,
-                     GCancellable         *cancellable,
-                     GError              **error)
-{
-       /* try to adopt each application with a plugin */
-       gs_plugin_loader_run_adopt (plugin_loader, list);
-
-       /* run each plugin */
-       if (!run_refine_filter (self, plugin_loader, list, flags,
-                               cancellable, error)) {
-               return FALSE;
-       }
 
        /* ensure these are sorted by score */
        if (flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS) {


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