aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-06-22 16:28:09 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2012-06-25 23:44:27 +0800
commit5e3aa77ad8a6293f31f548366c87a7cd50c861fb (patch)
tree7af50d9e7839b41f3e6d102aec50110dfb5fc29b /embed
parent188de2119d0375ac7c27252917778038200210b8 (diff)
downloadgsoc2013-epiphany-5e3aa77ad8a6293f31f548366c87a7cd50c861fb.tar.gz
gsoc2013-epiphany-5e3aa77ad8a6293f31f548366c87a7cd50c861fb.tar.zst
gsoc2013-epiphany-5e3aa77ad8a6293f31f548366c87a7cd50c861fb.zip
ephy-download: remove _ephy_download_new() internal function
It makes the code a bit more complex. Since we always need a WebKitDownload we can just create a WebKitDownload in ephy_download_new_for_uri() can then use ephy_download_new_for_download() to create the EphyDownload.
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-download.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/embed/ephy-download.c b/embed/ephy-download.c
index 756a1e590..dcea8edda 100644
--- a/embed/ephy-download.c
+++ b/embed/ephy-download.c
@@ -968,8 +968,16 @@ ephy_download_new (void)
return g_object_new (EPHY_TYPE_DOWNLOAD, NULL);
}
-static EphyDownload *
-_ephy_download_new (WebKitDownload *webkit_download, const char *uri)
+/**
+ * ephy_download_new_for_download:
+ * @download: a #WebKitDownload to wrap
+ *
+ * Wraps @download in an #EphyDownload.
+ *
+ * Returns: an #EphyDownload.
+ **/
+EphyDownload *
+ephy_download_new_for_download (WebKitDownload *download)
{
EphyDownload *ephy_download;
ephy_download = ephy_download_new ();
@@ -977,47 +985,21 @@ _ephy_download_new (WebKitDownload *webkit_download, const char *uri)
#ifdef HAVE_WEBKIT2
/* TODO: Downloads */
#else
- if (webkit_download == NULL) {
- WebKitNetworkRequest *request;
-
- request = webkit_network_request_new (uri);
- webkit_download = webkit_download_new (request);
-
- g_return_val_if_fail (webkit_download != NULL, NULL);
- g_object_unref (request);
- }
-
- g_signal_connect (webkit_download, "notify::status",
+ g_signal_connect (download, "notify::status",
G_CALLBACK (download_status_changed_cb),
ephy_download);
- g_signal_connect (webkit_download, "error",
+ g_signal_connect (download, "error",
G_CALLBACK (download_error_cb),
ephy_download);
- ephy_download->priv->download = g_object_ref (webkit_download);
- ephy_download->priv->source = g_strdup (webkit_download_get_uri (webkit_download));
+ ephy_download->priv->download = g_object_ref (download);
+ ephy_download->priv->source = g_strdup (webkit_download_get_uri (download));
#endif
return ephy_download;
}
/**
- * ephy_download_new_for_download:
- * @download: a #WebKitDownload to wrap
- *
- * Wraps @download in an #EphyDownload.
- *
- * Returns: an #EphyDownload.
- **/
-EphyDownload *
-ephy_download_new_for_download (WebKitDownload *download)
-{
- g_return_val_if_fail (WEBKIT_IS_DOWNLOAD (download), NULL);
-
- return _ephy_download_new (download, NULL);
-}
-
-/**
* ephy_download_new_for_uri:
* @uri: a source URI from where to download
*
@@ -1028,7 +1010,25 @@ ephy_download_new_for_download (WebKitDownload *download)
EphyDownload *
ephy_download_new_for_uri (const char *uri)
{
+ EphyDownload *ephy_download;
+ WebKitDownload *download;
+#ifdef HAVE_WEBKIT2
+ /* TODO: Downloads */
+ download = NULL;
+#else
+ WebKitNetworkRequest *request;
+
g_return_val_if_fail (uri != NULL, NULL);
- return _ephy_download_new (NULL, uri);
+ request = webkit_network_request_new (uri);
+ download = webkit_download_new (request);
+
+ g_return_val_if_fail (download != NULL, NULL);
+ g_object_unref (request);
+#endif
+
+ ephy_download = ephy_download_new_for_download (download);
+ g_object_unref (download);
+
+ return ephy_download;
}