Title: [141102] trunk/Source/WebKit2
Revision
141102
Author
[email protected]
Date
2013-01-29 05:22:10 -0800 (Tue, 29 Jan 2013)

Log Message

[GTK] Add API to prefetch DNS of a given hostname to WebKit2 GTK+ API
https://bugs.webkit.org/show_bug.cgi?id=99695

Reviewed by Anders Carlsson.

* UIProcess/API/gtk/WebKitWebContext.cpp:
(webkit_web_context_prefetch_dns): Public method to resolve the
domain name in advance for the given hostname.
* UIProcess/API/gtk/WebKitWebContext.h:
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add
webkit_web_context_prefetch_dns.
* WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:
(webkitWebExtensionDidReceiveMessage): Parse PrefetchDNS message
and call WebCore::prefetchDNS() with the given hostname.
(didReceiveMessage): Call webkitWebExtensionDidReceiveMessage().
(webkitWebExtensionCreate): Add implementation for
didReceiveMessage callback.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (141101 => 141102)


--- trunk/Source/WebKit2/ChangeLog	2013-01-29 12:59:46 UTC (rev 141101)
+++ trunk/Source/WebKit2/ChangeLog	2013-01-29 13:22:10 UTC (rev 141102)
@@ -1,5 +1,25 @@
 2013-01-29  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Add API to prefetch DNS of a given hostname to WebKit2 GTK+ API
+        https://bugs.webkit.org/show_bug.cgi?id=99695
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/gtk/WebKitWebContext.cpp:
+        (webkit_web_context_prefetch_dns): Public method to resolve the
+        domain name in advance for the given hostname.
+        * UIProcess/API/gtk/WebKitWebContext.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add
+        webkit_web_context_prefetch_dns.
+        * WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp:
+        (webkitWebExtensionDidReceiveMessage): Parse PrefetchDNS message
+        and call WebCore::prefetchDNS() with the given hostname.
+        (didReceiveMessage): Call webkitWebExtensionDidReceiveMessage().
+        (webkitWebExtensionCreate): Add implementation for
+        didReceiveMessage callback.
+
+2013-01-29  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Implement resources API using injected bundle
         https://bugs.webkit.org/show_bug.cgi?id=107457
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (141101 => 141102)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2013-01-29 12:59:46 UTC (rev 141101)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2013-01-29 13:22:10 UTC (rev 141102)
@@ -771,6 +771,24 @@
     context->priv->context->setInjectedBundleInitializationUserData(WebString::create(WebCore::filenameToString(directory)));
 }
 
+/**
+ * webkit_web_context_prefetch_dns:
+ * @context: a #WebKitWebContext
+ * @hostname: a hostname to be resolved
+ *
+ * Resolve the domain name of the given @hostname in advance, so that if a URI
+ * of @hostname is requested the load will be performed more quickly.
+ */
+void webkit_web_context_prefetch_dns(WebKitWebContext* context, const char* hostname)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+    g_return_if_fail(hostname);
+
+    ImmutableDictionary::MapType message;
+    message.set(String::fromUTF8("Hostname"), WebString::create(String::fromUTF8(hostname)));
+    context->priv->context->postMessageToInjectedBundle(String::fromUTF8("PrefetchDNS"), ImmutableDictionary::adopt(message).get());
+}
+
 WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy)
 {
     GRefPtr<WebKitDownload> download = downloadsMap().get(downloadProxy);

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h (141101 => 141102)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h	2013-01-29 12:59:46 UTC (rev 141101)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h	2013-01-29 13:22:10 UTC (rev 141102)
@@ -187,6 +187,11 @@
 WEBKIT_API void
 webkit_web_context_set_web_extensions_directory     (WebKitWebContext              *context,
                                                      const gchar                   *directory);
+
+WEBKIT_API void
+webkit_web_context_prefetch_dns                     (WebKitWebContext              *context,
+                                                     const gchar                   *hostname);
+
 G_END_DECLS
 
 #endif

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


--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2013-01-29 12:59:46 UTC (rev 141101)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2013-01-29 13:22:10 UTC (rev 141102)
@@ -46,6 +46,7 @@
 webkit_web_context_set_tls_errors_policy
 webkit_web_context_get_tls_errors_policy
 webkit_web_context_set_web_extensions_directory
+webkit_web_context_prefetch_dns
 
 <SUBSECTION URI Scheme>
 WebKitURISchemeRequestCallback

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp (141101 => 141102)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp	2013-01-29 12:59:46 UTC (rev 141101)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebExtension.cpp	2013-01-29 13:22:10 UTC (rev 141102)
@@ -20,11 +20,13 @@
 #include "config.h"
 #include "WebKitWebExtension.h"
 
+#include "ImmutableDictionary.h"
 #include "WKBundleAPICast.h"
 #include "WKBundlePage.h"
 #include "WebKitPrivate.h"
 #include "WebKitWebExtensionPrivate.h"
 #include "WebKitWebPagePrivate.h"
+#include <WebCore/DNS.h>
 #include <wtf/HashMap.h>
 #include <wtf/gobject/GRefPtr.h>
 
@@ -78,6 +80,15 @@
     extension->priv->pages.remove(page);
 }
 
+static void webkitWebExtensionDidReceiveMessage(WebKitWebExtension* extension, const String& messageName, ImmutableDictionary& message)
+{
+    if (messageName == String::fromUTF8("PrefetchDNS")) {
+        WebString* hostname = static_cast<WebString*>(message.get(String::fromUTF8("Hostname")));
+        WebCore::prefetchDNS(hostname->string());
+    } else
+        ASSERT_NOT_REACHED();
+}
+
 static void didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
 {
     webkitWebExtensionPageCreated(WEBKIT_WEB_EXTENSION(clientInfo), toImpl(page));
@@ -88,6 +99,12 @@
     webkitWebExtensionPageDestroy(WEBKIT_WEB_EXTENSION(clientInfo), toImpl(page));
 }
 
+static void didReceiveMessage(WKBundleRef bundle, WKStringRef name, WKTypeRef messageBody, const void* clientInfo)
+{
+    ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
+    webkitWebExtensionDidReceiveMessage(WEBKIT_WEB_EXTENSION(clientInfo), toImpl(name)->string(), *toImpl(static_cast<WKDictionaryRef>(messageBody)));
+}
+
 WebKitWebExtension* webkitWebExtensionCreate(InjectedBundle* bundle)
 {
     WebKitWebExtension* extension = WEBKIT_WEB_EXTENSION(g_object_new(WEBKIT_TYPE_WEB_EXTENSION, NULL));
@@ -98,7 +115,7 @@
         didCreatePage,
         willDestroyPage,
         0, // didInitializePageGroup
-        0, // didReceiveMessage
+        didReceiveMessage,
         0 // didReceiveMessageToPage
     };
     WKBundleSetClient(toAPI(bundle), &wkBundleClient);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to