blob: d674799a89fcf56df09c3b006a80b2864fd219ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* soup-message-queue-item.c: Message queue item
*
* Copyright (C) 2003 Novell, Inc.
* Copyright (C) 2008 Red Hat, Inc.
* Copyright (C) 2021 Igalia S.L.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "soup-message-queue-item.h"
#include "soup.h"
SoupMessageQueueItem *
soup_message_queue_item_new (SoupSession *session,
SoupMessage *msg,
gboolean async,
GCancellable *cancellable)
{
SoupMessageQueueItem *item;
item = g_atomic_rc_box_new0 (SoupMessageQueueItem);
item->session = g_object_ref (session);
item->msg = g_object_ref (msg);
item->async = async;
item->cancellable = cancellable ? g_object_ref (cancellable) : g_cancellable_new ();
return item;
}
SoupMessageQueueItem *
soup_message_queue_item_ref (SoupMessageQueueItem *item)
{
g_atomic_rc_box_acquire (item);
return item;
}
static void
soup_message_queue_item_destroy (SoupMessageQueueItem *item)
{
if (!g_error_matches (item->error, SOUP_SESSION_ERROR, SOUP_SESSION_ERROR_MESSAGE_ALREADY_IN_QUEUE))
g_warn_if_fail (soup_message_get_connection (item->msg) == NULL);
g_object_unref (item->session);
g_object_unref (item->msg);
g_object_unref (item->cancellable);
g_clear_error (&item->error);
g_clear_object (&item->task);
}
void
soup_message_queue_item_unref (SoupMessageQueueItem *item)
{
g_atomic_rc_box_release_full (item, (GDestroyNotify)soup_message_queue_item_destroy);
}
void
soup_message_queue_item_cancel (SoupMessageQueueItem *item)
{
g_cancellable_cancel (item->cancellable);
}
|