Title: [119108] trunk/Source/WebKit2
Revision
119108
Author
carlo...@webkit.org
Date
2012-05-31 08:31:54 -0700 (Thu, 31 May 2012)

Log Message

[GTK] Add webkit_download_get_request to WebKit2 GTK+ API
https://bugs.webkit.org/show_bug.cgi?id=87957

Reviewed by Martin Robinson.

* UIProcess/API/gtk/WebKitDownload.cpp:
(webkit_download_get_request): Return the WebKitURIRequest
representing the request that originated the download.
* UIProcess/API/gtk/WebKitDownload.h:
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbol.
* UIProcess/API/gtk/tests/TestDownloads.cpp:
(testDownloadLocalFile):
(testDownloadRemoteFile):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (119107 => 119108)


--- trunk/Source/WebKit2/ChangeLog	2012-05-31 15:29:48 UTC (rev 119107)
+++ trunk/Source/WebKit2/ChangeLog	2012-05-31 15:31:54 UTC (rev 119108)
@@ -1,5 +1,21 @@
 2012-05-31  Carlos Garcia Campos  <cgar...@igalia.com>
 
+        [GTK] Add webkit_download_get_request to WebKit2 GTK+ API
+        https://bugs.webkit.org/show_bug.cgi?id=87957
+
+        Reviewed by Martin Robinson.
+
+        * UIProcess/API/gtk/WebKitDownload.cpp:
+        (webkit_download_get_request): Return the WebKitURIRequest
+        representing the request that originated the download.
+        * UIProcess/API/gtk/WebKitDownload.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbol.
+        * UIProcess/API/gtk/tests/TestDownloads.cpp:
+        (testDownloadLocalFile):
+        (testDownloadRemoteFile):
+
+2012-05-31  Carlos Garcia Campos  <cgar...@igalia.com>
+
         [SOUP] WebProcess crashes when a download is started from an existing ResourceHandle
         https://bugs.webkit.org/show_bug.cgi?id=87953
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp (119107 => 119108)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp	2012-05-31 15:29:48 UTC (rev 119107)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.cpp	2012-05-31 15:31:54 UTC (rev 119108)
@@ -20,8 +20,10 @@
 #include "config.h"
 #include "WebKitDownload.h"
 
+#include "DownloadProxy.h"
 #include "WebKitDownloadPrivate.h"
 #include "WebKitMarshal.h"
+#include "WebKitURIRequestPrivate.h"
 #include "WebKitURIResponsePrivate.h"
 #include <WebCore/ErrorsGtk.h>
 #include <WebCore/ResourceResponse.h>
@@ -53,6 +55,7 @@
 struct _WebKitDownloadPrivate {
     WKRetainPtr<WKDownloadRef> wkDownload;
 
+    GRefPtr<WebKitURIRequest> request;
     GRefPtr<WebKitURIResponse> response;
     CString destinationURI;
     guint64 currentSize;
@@ -360,6 +363,25 @@
 }
 
 /**
+ * webkit_download_get_request:
+ * @download: a #WebKitDownload
+ *
+ * Retrieves the #WebKitURIRequest object that backs the download
+ * process.
+ *
+ * Returns: (transfer none): the #WebKitURIRequest of @download
+ */
+WebKitURIRequest* webkit_download_get_request(WebKitDownload* download)
+{
+    g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0);
+
+    WebKitDownloadPrivate* priv = download->priv;
+    if (!priv->request)
+        priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(toImpl(priv->wkDownload.get())->request()));
+    return download->priv->request.get();
+}
+
+/**
  * webkit_download_get_destination:
  * @download: a #WebKitDownload
  *

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h (119107 => 119108)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h	2012-05-31 15:29:48 UTC (rev 119107)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitDownload.h	2012-05-31 15:31:54 UTC (rev 119108)
@@ -26,6 +26,7 @@
 
 #include <glib-object.h>
 #include <webkit2/WebKitDefines.h>
+#include <webkit2/WebKitURIRequest.h>
 #include <webkit2/WebKitURIResponse.h>
 
 G_BEGIN_DECLS
@@ -57,6 +58,9 @@
 WEBKIT_API GType
 webkit_download_get_type               (void);
 
+WEBKIT_API WebKitURIRequest *
+webkit_download_get_request            (WebKitDownload *download);
+
 WEBKIT_API const gchar *
 webkit_download_get_destination        (WebKitDownload *download);
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (119107 => 119108)


--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2012-05-31 15:29:48 UTC (rev 119107)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2012-05-31 15:31:54 UTC (rev 119108)
@@ -348,6 +348,7 @@
 <SECTION>
 <FILE>WebKitDownload</FILE>
 WebKitDownload
+webkit_download_get_request
 webkit_download_get_destination
 webkit_download_set_destination
 webkit_download_get_response

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp (119107 => 119108)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp	2012-05-31 15:29:48 UTC (rev 119107)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestDownloads.cpp	2012-05-31 15:31:54 UTC (rev 119108)
@@ -88,6 +88,7 @@
 
     static void downloadStartedCallback(WebKitWebContext* context, WebKitDownload* download, DownloadTest* test)
     {
+        g_assert(webkit_download_get_request(download));
         test->started(download);
         g_signal_connect(download, "notify::response", G_CALLBACK(receivedResponseCallback), test);
         g_signal_connect(download, "created-destination", G_CALLBACK(createdDestinationCallback), test);
@@ -191,6 +192,10 @@
     g_assert_cmpint(events[3], ==, DownloadTest::ReceivedData);
     g_assert_cmpint(events[4], ==, DownloadTest::Finished);
 
+    WebKitURIRequest* request = webkit_download_get_request(download.get());
+    g_assert(request);
+    g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, sourceURI.get());
+
     g_assert_cmpint(test->m_downloadSize, ==, g_file_info_get_size(sourceInfo.get()));
     g_assert(webkit_download_get_destination(download.get()));
     g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), ==, 1);
@@ -328,6 +333,11 @@
     g_assert_cmpint(events[4], ==, DownloadTest::Finished);
     events.clear();
 
+    WebKitURIRequest* request = webkit_download_get_request(download.get());
+    g_assert(request);
+    CString requestURI = kServer->getURIForPath("/test.pdf");
+    g_assert_cmpstr(webkit_uri_request_get_uri(request), ==, requestURI.data());
+
     g_assert(webkit_download_get_destination(download.get()));
     g_assert_cmpfloat(webkit_download_get_estimated_progress(download.get()), ==, 1);
     test->checkDestinationAndDeleteFile(download.get(), kServerSuggestedFilename);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to