[libsoup/http2] move some bits out of SoupMessageQueue



commit 97e2cd3e566501d1b35fc1a21bad88a041c22012
Author: Dan Winship <danw gnome org>
Date:   Tue Dec 10 13:57:23 2013 +0100

    move some bits out of SoupMessageQueue

 libsoup/soup-message-queue.c |   18 +++---------------
 libsoup/soup-message-queue.h |    6 ++----
 libsoup/soup-session.c       |   10 ++++++++--
 3 files changed, 13 insertions(+), 21 deletions(-)
---
diff --git a/libsoup/soup-message-queue.c b/libsoup/soup-message-queue.c
index 4bc3726..889a86d 100644
--- a/libsoup/soup-message-queue.c
+++ b/libsoup/soup-message-queue.c
@@ -27,19 +27,16 @@
  **/
 
 struct _SoupMessageQueue {
-       SoupSession *session;
-
        GMutex mutex;
        SoupMessageQueueItem *head, *tail;
 };
 
 SoupMessageQueue *
-soup_message_queue_new (SoupSession *session)
+soup_message_queue_new (void)
 {
        SoupMessageQueue *queue;
 
        queue = g_slice_new0 (SoupMessageQueue);
-       queue->session = session;
        g_mutex_init (&queue->mutex);
        return queue;
 }
@@ -65,8 +62,6 @@ queue_message_restarted (SoupMessage *msg, gpointer user_data)
  * soup_message_queue_append:
  * @queue: a #SoupMessageQueue
  * @msg: a #SoupMessage
- * @callback: the callback for @msg
- * @user_data: the data to pass to @callback
  *
  * Creates a new #SoupMessageQueueItem and appends it to @queue.
  *
@@ -74,20 +69,13 @@ queue_message_restarted (SoupMessage *msg, gpointer user_data)
  * soup_message_queue_unref_item() when you are done with.
  **/
 SoupMessageQueueItem *
-soup_message_queue_append (SoupMessageQueue *queue, SoupMessage *msg,
-                          SoupSessionCallback callback, gpointer user_data)
+soup_message_queue_append (SoupMessageQueue *queue, SoupMessage *msg)
 {
        SoupMessageQueueItem *item;
 
        item = g_slice_new0 (SoupMessageQueueItem);
-       item->session = g_object_ref (queue->session);
-       item->async_context = soup_session_get_async_context (item->session);
-       if (item->async_context)
-               g_main_context_ref (item->async_context);
        item->queue = queue;
        item->msg = g_object_ref (msg);
-       item->callback = callback;
-       item->callback_data = user_data;
        item->cancellable = g_cancellable_new ();
        item->priority = soup_message_get_priority (msg);
 
@@ -180,7 +168,7 @@ soup_message_queue_item_unref (SoupMessageQueueItem *item)
        /* And free it */
        g_signal_handlers_disconnect_by_func (item->msg,
                                              queue_message_restarted, item);
-       g_object_unref (item->session);
+       g_clear_object (&item->session);
        g_object_unref (item->msg);
        g_object_unref (item->cancellable);
        g_clear_error (&item->error);
diff --git a/libsoup/soup-message-queue.h b/libsoup/soup-message-queue.h
index f86a129..8a3f718 100644
--- a/libsoup/soup-message-queue.h
+++ b/libsoup/soup-message-queue.h
@@ -60,11 +60,9 @@ struct _SoupMessageQueueItem {
        SoupMessageQueueItem *related;
 };
 
-SoupMessageQueue     *soup_message_queue_new        (SoupSession          *session);
+SoupMessageQueue     *soup_message_queue_new        (void);
 SoupMessageQueueItem *soup_message_queue_append     (SoupMessageQueue     *queue,
-                                                    SoupMessage          *msg,
-                                                    SoupSessionCallback   callback,
-                                                    gpointer              user_data);
+                                                    SoupMessage          *msg);
 
 SoupMessageQueueItem *soup_message_queue_lookup     (SoupMessageQueue     *queue,
                                                     SoupMessage          *msg);
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 5c38222..6502a14 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -194,7 +194,7 @@ soup_session_init (SoupSession *session)
 
        priv->session = session;
 
-       priv->queue = soup_message_queue_new (session);
+       priv->queue = soup_message_queue_new ();
 
        g_mutex_init (&priv->conn_lock);
        g_cond_init (&priv->conn_cond);
@@ -1177,9 +1177,15 @@ soup_session_append_queue_item (SoupSession *session, SoupMessage *msg,
 
        soup_message_cleanup_response (msg);
 
-       item = soup_message_queue_append (priv->queue, msg, callback, user_data);
+       item = soup_message_queue_append (priv->queue, msg);
+       item->session = g_object_ref (session);
+       item->async_context = soup_session_get_async_context (session);
+       if (item->async_context)
+               g_main_context_ref (item->async_context);
        item->async = async;
        item->new_api = new_api;
+       item->callback = callback;
+       item->callback_data = user_data;
 
        g_mutex_lock (&priv->conn_lock);
        host = get_host_for_message (session, item->msg);


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