[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

kov at webkit.org kov at webkit.org
Thu Oct 29 20:52:03 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 5540c14a536f8de2e195bd982cbd527ae903615a
Author: kov at webkit.org <kov at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Oct 26 13:49:48 2009 +0000

    Reviewed by Xan Lopez.
    
    https://bugs.webkit.org/show_bug.cgi?id=30759
    [GTK] Should use WebKitNetworkResponse, and expose it
    
    WebKitDownload now uses our WebKitNetworkResponse instead of using
    ResourceResponse directly. By exposing the response, like we do
    with the request, we give our users the ability to look at the
    response headers, status code, and so on, through the SoupMessage
    object.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50060 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 0d24484..5e4f821 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,29 @@
+2009-10-26  Gustavo Noronha Silva  <gustavo.noronha at collabora.co.uk>
+
+        Reviewed by Xan Lopez.
+
+        https://bugs.webkit.org/show_bug.cgi?id=30759
+        [GTK] Should use WebKitNetworkResponse, and expose it
+
+        WebKitDownload now uses our WebKitNetworkResponse instead of using
+        ResourceResponse directly. By exposing the response, like we do
+        with the request, we give our users the ability to look at the
+        response headers, status code, and so on, through the SoupMessage
+        object.
+
+        * webkit/webkitdownload.cpp:
+        (webkit_download_dispose):
+        (webkit_download_finalize):
+        (webkit_download_get_property):
+        (webkit_download_set_property):
+        (webkit_download_class_init):
+        (webkit_download_get_network_response):
+        (webkit_download_set_response):
+        (webkit_download_get_total_size):
+        (webkit_download_get_progress):
+        (webkit_download_received_data):
+        * webkit/webkitdownload.h:
+
 2009-10-26  Xan Lopez  <xlopez at igalia.com>
 
         Reviewed by Gustavo Noronha.
diff --git a/WebKit/gtk/webkit/webkitdownload.cpp b/WebKit/gtk/webkit/webkitdownload.cpp
index 568378c..dd6629b 100644
--- a/WebKit/gtk/webkit/webkitdownload.cpp
+++ b/WebKit/gtk/webkit/webkitdownload.cpp
@@ -31,6 +31,7 @@
 #include "webkitdownload.h"
 #include "webkitenumtypes.h"
 #include "webkitmarshal.h"
+#include "webkitnetworkresponse.h"
 #include "webkitprivate.h"
 
 #include <glib/gstdio.h>
@@ -74,7 +75,7 @@ struct _WebKitDownloadPrivate {
     GFileOutputStream* outputStream;
     DownloadClient* downloadClient;
     WebKitNetworkRequest* networkRequest;
-    ResourceResponse* networkResponse;
+    WebKitNetworkResponse* networkResponse;
     RefPtr<ResourceHandle> resourceHandle;
 };
 
@@ -95,7 +96,8 @@ enum {
     PROP_PROGRESS,
     PROP_STATUS,
     PROP_CURRENT_SIZE,
-    PROP_TOTAL_SIZE
+    PROP_TOTAL_SIZE,
+    PROP_NETWORK_RESPONSE
 };
 
 G_DEFINE_TYPE(WebKitDownload, webkit_download, G_TYPE_OBJECT);
@@ -119,6 +121,11 @@ static void webkit_download_dispose(GObject* object)
         priv->networkRequest = NULL;
     }
 
+    if (priv->networkResponse) {
+        g_object_unref(priv->networkResponse);
+        priv->networkResponse = NULL;
+    }
+
     G_OBJECT_CLASS(webkit_download_parent_class)->dispose(object);
 }
 
@@ -138,7 +145,6 @@ static void webkit_download_finalize(GObject* object)
     }
 
     delete priv->downloadClient;
-    delete priv->networkResponse;
 
     // The download object may never have _start called on it, so we
     // need to make sure timer is non-NULL.
@@ -159,6 +165,9 @@ static void webkit_download_get_property(GObject* object, guint prop_id, GValue*
     case PROP_NETWORK_REQUEST:
         g_value_set_object(value, webkit_download_get_network_request(download));
         break;
+    case PROP_NETWORK_RESPONSE:
+        g_value_set_object(value, webkit_download_get_network_response(download));
+        break;
     case PROP_DESTINATION_URI:
         g_value_set_string(value, webkit_download_get_destination_uri(download));
         break;
@@ -191,6 +200,9 @@ static void webkit_download_set_property(GObject* object, guint prop_id, const G
     case PROP_NETWORK_REQUEST:
         priv->networkRequest = WEBKIT_NETWORK_REQUEST(g_value_dup_object(value));
         break;
+    case PROP_NETWORK_RESPONSE:
+        priv->networkResponse = WEBKIT_NETWORK_RESPONSE(g_value_dup_object(value));
+        break;
     case PROP_DESTINATION_URI:
         webkit_download_set_destination_uri(download, g_value_get_string(value));
         break;
@@ -252,6 +264,21 @@ static void webkit_download_class_init(WebKitDownloadClass* downloadClass)
                                                         (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
 
     /**
+     * WebKitDownload:network-response
+     *
+     * The #WebKitNetworkResponse instance associated with the download.
+     *
+     * Since: 1.1.16
+     */
+    g_object_class_install_property(objectClass,
+                                    PROP_NETWORK_RESPONSE,
+                                    g_param_spec_object("network-response",
+                                                        _("Network Response"),
+                                                        _("The network response for the URI that should be downloaded"),
+                                                        WEBKIT_TYPE_NETWORK_RESPONSE,
+                                                        (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
+    /**
      * WebKitDownload:destination-uri
      *
      * The URI of the save location for this download.
@@ -530,11 +557,29 @@ WebKitNetworkRequest* webkit_download_get_network_request(WebKitDownload* downlo
     return priv->networkRequest;
 }
 
+/**
+ * webkit_download_get_network_response:
+ * @download: the #WebKitDownload
+ *
+ * Retrieves the #WebKitNetworkResponse object that backs the download
+ * process.
+ *
+ * Returns: the #WebKitNetworkResponse instance
+ *
+ * Since: 1.1.16
+ */
+WebKitNetworkResponse* webkit_download_get_network_response(WebKitDownload* download)
+{
+    g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), NULL);
+
+    WebKitDownloadPrivate* priv = download->priv;
+    return priv->networkResponse;
+}
+
 static void webkit_download_set_response(WebKitDownload* download, const ResourceResponse& response)
 {
-    // FIXME Use WebKitNetworkResponse when it's merged.
     WebKitDownloadPrivate* priv = download->priv;
-    priv->networkResponse = new ResourceResponse(response);
+    priv->networkResponse = webkit_network_response_new_with_core_response(response);
 
     if (!response.isNull() && !response.suggestedFilename().isEmpty())
         webkit_download_set_suggested_filename(download, response.suggestedFilename().utf8().data());
@@ -704,10 +749,12 @@ guint64 webkit_download_get_total_size(WebKitDownload* download)
     g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0);
 
     WebKitDownloadPrivate* priv = download->priv;
-    if (!priv->networkResponse)
+    SoupMessage* message = priv->networkResponse ? webkit_network_response_get_message(priv->networkResponse) : NULL;
+
+    if (!message)
         return 0;
 
-    return MAX(priv->currentSize, priv->networkResponse->expectedContentLength());
+    return MAX(priv->currentSize, soup_message_headers_get_content_length(message->response_headers));
 }
 
 /**
@@ -744,9 +791,9 @@ gdouble webkit_download_get_progress(WebKitDownload* download)
 
     WebKitDownloadPrivate* priv = download->priv;
     if (!priv->networkResponse)
-        return 0;
+        return 0.0;
 
-    gdouble total_size = (gdouble)priv->networkResponse->expectedContentLength();
+    gdouble total_size = static_cast<gdouble>(webkit_download_get_total_size(download));
 
     if (total_size == 0)
         return 1.0;
@@ -803,7 +850,7 @@ static void webkit_download_received_data(WebKitDownload* download, const gchar*
     g_object_notify(G_OBJECT(download), "current-size");
 
     ASSERT(priv->networkResponse);
-    if (priv->currentSize > priv->networkResponse->expectedContentLength())
+    if (priv->currentSize > webkit_download_get_total_size(download))
         g_object_notify(G_OBJECT(download), "total-size");
 
     gdouble lastProgress = webkit_download_get_progress(download);
diff --git a/WebKit/gtk/webkit/webkitdownload.h b/WebKit/gtk/webkit/webkitdownload.h
index 6e7f38b..a732a57 100644
--- a/WebKit/gtk/webkit/webkitdownload.h
+++ b/WebKit/gtk/webkit/webkitdownload.h
@@ -84,6 +84,9 @@ webkit_download_get_uri                     (WebKitDownload       *download);
 WEBKIT_API WebKitNetworkRequest*
 webkit_download_get_network_request         (WebKitDownload       *download);
 
+WEBKIT_API WebKitNetworkResponse*
+webkit_download_get_network_response         (WebKitDownload       *download);
+
 WEBKIT_API const gchar*
 webkit_download_get_suggested_filename      (WebKitDownload       *download);
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list