[epiphany] ephy-download: remove _ephy_download_new() internal function



commit 5e3aa77ad8a6293f31f548366c87a7cd50c861fb
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Fri Jun 22 10:28:09 2012 +0200

    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.

 embed/ephy-download.c |   66 ++++++++++++++++++++++++------------------------
 1 files changed, 33 insertions(+), 33 deletions(-)
---
diff --git a/embed/ephy-download.c b/embed/ephy-download.c
index 756a1e5..dcea8ed 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;
 }



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