diff options
author | Patrick Griffis <pgriffis@igalia.com> | 2020-12-16 15:39:38 -0600 |
---|---|---|
committer | Patrick Griffis <pgriffis@igalia.com> | 2020-12-16 15:39:38 -0600 |
commit | 19f85ec171d1d37e04135284ecef8e7155a89d02 (patch) | |
tree | 24114bbd6d9ff871c22ad80536336b564d4cb250 | |
parent | 5d12f5ca6702c157977f2aa9b5629dfdac83a6e6 (diff) | |
download | libsoup-19f85ec171d1d37e04135284ecef8e7155a89d02.tar.gz |
Make SoupContentSniffer final type
-rw-r--r-- | libsoup/content-sniffer/soup-content-sniffer.c | 91 | ||||
-rw-r--r-- | libsoup/content-sniffer/soup-content-sniffer.h | 14 |
2 files changed, 37 insertions, 68 deletions
diff --git a/libsoup/content-sniffer/soup-content-sniffer.c b/libsoup/content-sniffer/soup-content-sniffer.c index d3bd6405..cb4255ad 100644 --- a/libsoup/content-sniffer/soup-content-sniffer.c +++ b/libsoup/content-sniffer/soup-content-sniffer.c @@ -47,6 +47,9 @@ static void soup_content_sniffer_session_feature_init (SoupSessionFeatureInterfa static SoupContentProcessorInterface *soup_content_sniffer_default_content_processor_interface; static void soup_content_sniffer_content_processor_init (SoupContentProcessorInterface *interface, gpointer interface_data); +struct _SoupContentSniffer { + GObject parent_instance; +}; G_DEFINE_TYPE_WITH_CODE (SoupContentSniffer, soup_content_sniffer, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (SOUP_TYPE_SESSION_FEATURE, @@ -773,9 +776,26 @@ sniff_feed_or_html (SoupContentSniffer *sniffer, GBytes *buffer) return g_strdup ("text/html"); } -static char * -soup_content_sniffer_real_sniff (SoupContentSniffer *sniffer, SoupMessage *msg, - GBytes *buffer, GHashTable **params) +/** + * soup_content_sniffer_sniff: + * @sniffer: a #SoupContentSniffer + * @msg: the message to sniff + * @buffer: a buffer containing the start of @msg's response body + * @params: (element-type utf8 utf8) (out) (transfer full) (allow-none): return + * location for Content-Type parameters (eg, "charset"), or %NULL + * + * Sniffs @buffer to determine its Content-Type. The result may also + * be influenced by the Content-Type declared in @msg's response + * headers. + * + * Return value: the sniffed Content-Type of @buffer; this will never be %NULL, + * but may be "application/octet-stream". + * + * Since: 2.28 + */ +char * +soup_content_sniffer_sniff (SoupContentSniffer *sniffer, SoupMessage *msg, + GBytes *buffer, GHashTable **params) { const char *content_type; const char *x_content_type_options; @@ -846,8 +866,19 @@ soup_content_sniffer_real_sniff (SoupContentSniffer *sniffer, SoupMessage *msg, return g_strdup (content_type); } -static gsize -soup_content_sniffer_real_get_buffer_size (SoupContentSniffer *sniffer) +/** + * soup_content_sniffer_get_buffer_size: + * @sniffer: a #SoupContentSniffer + * + * Gets the number of bytes @sniffer needs in order to properly sniff + * a buffer. + * + * Return value: the number of bytes to sniff + * + * Since: 2.28 + */ +gsize +soup_content_sniffer_get_buffer_size (SoupContentSniffer *sniffer) { return 512; } @@ -880,8 +911,6 @@ soup_content_sniffer_request_unqueued (SoupSessionFeature *feature, static void soup_content_sniffer_class_init (SoupContentSnifferClass *content_sniffer_class) { - content_sniffer_class->sniff = soup_content_sniffer_real_sniff; - content_sniffer_class->get_buffer_size = soup_content_sniffer_real_get_buffer_size; } static void @@ -906,51 +935,3 @@ soup_content_sniffer_new (void) { return g_object_new (SOUP_TYPE_CONTENT_SNIFFER, NULL); } - -/** - * soup_content_sniffer_sniff: - * @sniffer: a #SoupContentSniffer - * @msg: the message to sniff - * @buffer: a buffer containing the start of @msg's response body - * @params: (element-type utf8 utf8) (out) (transfer full) (allow-none): return - * location for Content-Type parameters (eg, "charset"), or %NULL - * - * Sniffs @buffer to determine its Content-Type. The result may also - * be influenced by the Content-Type declared in @msg's response - * headers. - * - * Return value: the sniffed Content-Type of @buffer; this will never be %NULL, - * but may be "application/octet-stream". - * - * Since: 2.28 - */ -char * -soup_content_sniffer_sniff (SoupContentSniffer *sniffer, - SoupMessage *msg, GBytes *buffer, - GHashTable **params) -{ - g_return_val_if_fail (SOUP_IS_CONTENT_SNIFFER (sniffer), NULL); - g_return_val_if_fail (SOUP_IS_MESSAGE (msg), NULL); - g_return_val_if_fail (buffer != NULL, NULL); - - return SOUP_CONTENT_SNIFFER_GET_CLASS (sniffer)->sniff (sniffer, msg, buffer, params); -} - -/** - * soup_content_sniffer_get_buffer_size: - * @sniffer: a #SoupContentSniffer - * - * Gets the number of bytes @sniffer needs in order to properly sniff - * a buffer. - * - * Return value: the number of bytes to sniff - * - * Since: 2.28 - */ -gsize -soup_content_sniffer_get_buffer_size (SoupContentSniffer *sniffer) -{ - g_return_val_if_fail (SOUP_IS_CONTENT_SNIFFER (sniffer), 0); - - return SOUP_CONTENT_SNIFFER_GET_CLASS (sniffer)->get_buffer_size (sniffer); -} diff --git a/libsoup/content-sniffer/soup-content-sniffer.h b/libsoup/content-sniffer/soup-content-sniffer.h index 3dfa2ddc..2da8a60e 100644 --- a/libsoup/content-sniffer/soup-content-sniffer.h +++ b/libsoup/content-sniffer/soup-content-sniffer.h @@ -12,19 +12,7 @@ G_BEGIN_DECLS #define SOUP_TYPE_CONTENT_SNIFFER (soup_content_sniffer_get_type ()) SOUP_AVAILABLE_IN_ALL -G_DECLARE_DERIVABLE_TYPE (SoupContentSniffer, soup_content_sniffer, SOUP, CONTENT_SNIFFER, GObject) - -struct _SoupContentSnifferClass { - GObjectClass parent_class; - - char* (*sniff) (SoupContentSniffer *sniffer, - SoupMessage *msg, - GBytes *buffer, - GHashTable **params); - gsize (*get_buffer_size) (SoupContentSniffer *sniffer); - - gpointer padding[6]; -}; +G_DECLARE_FINAL_TYPE (SoupContentSniffer, soup_content_sniffer, SOUP, CONTENT_SNIFFER, GObject) SOUP_AVAILABLE_IN_ALL SoupContentSniffer *soup_content_sniffer_new (void); |