[libsoup] SoupContentSnifferStream: added can_poll() implementation



commit 6d370df18ac14a167a677ea66bfd02883b571b18
Author: Sergio Villar Senin <svillar igalia com>
Date:   Mon Aug 20 10:43:56 2012 +0200

    SoupContentSnifferStream: added can_poll() implementation
    
    Done in terms of the base_stream can_poll() interface. It was not needed to
    read resources from network as the underlying streams were all pollable.
    This will be used later to sniff locally cached resources. The file streams are
    not pollable so we must implement the can_poll() in order to use "normal"
    read() calls instead of the read_nonblocking().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682112

 libsoup/soup-content-sniffer-stream.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/libsoup/soup-content-sniffer-stream.c b/libsoup/soup-content-sniffer-stream.c
index 42e9247..173f902 100644
--- a/libsoup/soup-content-sniffer-stream.c
+++ b/libsoup/soup-content-sniffer-stream.c
@@ -233,6 +233,16 @@ soup_content_sniffer_stream_skip (GInputStream  *stream,
 }
 
 static gboolean
+soup_content_sniffer_stream_can_poll (GPollableInputStream *pollable)
+{
+	GInputStream *base_stream = G_FILTER_INPUT_STREAM (pollable)->base_stream;
+
+	return G_IS_POLLABLE_INPUT_STREAM (base_stream) &&
+		g_pollable_input_stream_can_poll (G_POLLABLE_INPUT_STREAM (base_stream));
+}
+
+
+static gboolean
 soup_content_sniffer_stream_is_readable (GPollableInputStream *stream)
 {
 	SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (stream);
@@ -320,6 +330,7 @@ static void
 soup_content_sniffer_stream_pollable_init (GPollableInputStreamInterface *pollable_interface,
 					   gpointer                       interface_data)
 {
+	pollable_interface->can_poll = soup_content_sniffer_stream_can_poll;
 	pollable_interface->is_readable = soup_content_sniffer_stream_is_readable;
 	pollable_interface->read_nonblocking = soup_content_sniffer_stream_read_nonblocking;
 	pollable_interface->create_source = soup_content_sniffer_stream_create_source;



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