[gnome-online-accounts/wip/rishi/gtask2: 9/13] httpclient: Split the idle handler into two parts



commit e4aef2570d700ec73b854b3cc421492f9f027dc8
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Jan 9 18:04:01 2017 +0100

    httpclient: Split the idle handler into two parts
    
    Instead of completing the GSimpleAsyncResult and freeing CheckData in
    one block of code, let's split the latter into a separate function.
    
    This will make the subsequent commit easier to read.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764157

 src/goabackend/goahttpclient.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/goabackend/goahttpclient.c b/src/goabackend/goahttpclient.c
index 4f19f65..32eb1c0 100644
--- a/src/goabackend/goahttpclient.c
+++ b/src/goabackend/goahttpclient.c
@@ -91,7 +91,7 @@ typedef struct
   gchar *username;
 } CheckAuthData;
 
-static gboolean
+static void
 http_client_check_data_free (gpointer user_data)
 {
   CheckData *data = user_data;
@@ -108,8 +108,6 @@ http_client_check_data_free (gpointer user_data)
   g_object_unref (data->res);
   g_object_unref (data->session);
   g_slice_free (CheckData, data);
-
-  return G_SOURCE_REMOVE;
 }
 
 static void
@@ -163,6 +161,17 @@ http_client_check_cancelled_cb (GCancellable *cancellable, gpointer user_data)
   soup_session_abort (data->session);
 }
 
+static gboolean
+http_client_check_complete_and_free_in_idle (gpointer user_data)
+{
+  CheckData *data = user_data;
+
+  g_simple_async_result_complete_in_idle (data->res);
+  http_client_check_data_free (data);
+
+  return G_SOURCE_REMOVE;
+}
+
 static void
 http_client_check_response_cb (SoupSession *session, SoupMessage *msg, gpointer user_data)
 {
@@ -199,8 +208,8 @@ http_client_check_response_cb (SoupSession *session, SoupMessage *msg, gpointer
 
   source = g_idle_source_new ();
   g_source_set_priority (source, G_PRIORITY_DEFAULT_IDLE);
-  g_source_set_callback (source, http_client_check_data_free, data, NULL);
-  g_source_set_name (source, "[goa] http_client_check_data_free");
+  g_source_set_callback (source, http_client_check_complete_and_free_in_idle, data, NULL);
+  g_source_set_name (source, "[goa] http_client_check_complete_and_free_in_idle");
 
   context = g_main_context_get_thread_default ();
   g_source_attach (source, context);


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