DownloadProxy objects should be message receivers
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Dec 2012 00:48:13 +0000 (00:48 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Dec 2012 00:48:13 +0000 (00:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105068

Reviewed by Andreas Kling.

This simplifies the WebContext message dispatch code somewhat.

* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::didReceiveMessage):
(WebKit::DownloadProxy::didReceiveSyncMessage):
* UIProcess/Downloads/DownloadProxy.h:
(DownloadProxy):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::createDownloadProxy):
(WebKit::WebContext::didReceiveMessage):
(WebKit::WebContext::didReceiveSyncMessage):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137790 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp
Source/WebKit2/UIProcess/Downloads/DownloadProxy.h
Source/WebKit2/UIProcess/WebContext.cpp

index f45964f..4aa0613 100644 (file)
@@ -1,3 +1,22 @@
+2012-12-14  Anders Carlsson  <andersca@apple.com>
+
+        DownloadProxy objects should be message receivers
+        https://bugs.webkit.org/show_bug.cgi?id=105068
+
+        Reviewed by Andreas Kling.
+
+        This simplifies the WebContext message dispatch code somewhat.
+
+        * UIProcess/Downloads/DownloadProxy.cpp:
+        (WebKit::DownloadProxy::didReceiveMessage):
+        (WebKit::DownloadProxy::didReceiveSyncMessage):
+        * UIProcess/Downloads/DownloadProxy.h:
+        (DownloadProxy):
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::createDownloadProxy):
+        (WebKit::WebContext::didReceiveMessage):
+        (WebKit::WebContext::didReceiveSyncMessage):
+
 2012-12-14  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r137767.
index c1eee5a..6739852 100644 (file)
@@ -84,6 +84,16 @@ void DownloadProxy::processDidClose()
     m_webContext->downloadClient().processDidCrash(m_webContext, this);
 }
 
+void DownloadProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
+{
+    didReceiveDownloadProxyMessage(connection, messageID, decoder);
+}
+
+void DownloadProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder)
+{
+    didReceiveSyncDownloadProxyMessage(connection, messageID, decoder, replyEncoder);
+}
+
 void DownloadProxy::didStart(const ResourceRequest& request)
 {
     m_request = request;
index 7108e27..43ccbfa 100644 (file)
@@ -45,7 +45,7 @@ class WebContext;
 class WebData;
 class WebPageProxy;
 
-class DownloadProxy : public APIObject {
+class DownloadProxy : public APIObject, public CoreIPC::MessageReceiver {
 public:
     static const Type APIType = TypeDownload;
 
@@ -73,6 +73,10 @@ private:
 
     virtual Type type() const { return APIType; }
 
+    // CoreIPC::MessageReceiver
+    virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
+    virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&) OVERRIDE;
+
     // Message handlers.
     void didStart(const WebCore::ResourceRequest&);
     void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&, uint64_t challengeID);
index 894bc0d..9ea2a30 100644 (file)
@@ -838,7 +838,7 @@ DownloadProxy* WebContext::createDownloadProxy()
 {
     DownloadProxy* downloadProxy = DownloadProxyMap::shared().createDownloadProxy(this);
     m_downloads.set(downloadProxy->downloadID(), downloadProxy);
-    addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID(), this);
+    addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID(), downloadProxy);
     return downloadProxy;
 }
 
@@ -895,13 +895,6 @@ void WebContext::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes
         return;
     }
 
-    if (messageID.is<CoreIPC::MessageClassDownloadProxy>()) {
-        if (DownloadProxy* downloadProxy = m_downloads.get(decoder.destinationID()).get())
-            downloadProxy->didReceiveDownloadProxyMessage(connection, messageID, decoder);
-        
-        return;
-    }
-
     switch (messageID.get<WebContextLegacyMessage::Kind>()) {
         case WebContextLegacyMessage::PostMessage: {
             String messageName;
@@ -929,12 +922,6 @@ void WebContext::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC:
         return;
     }
 
-    if (messageID.is<CoreIPC::MessageClassDownloadProxy>()) {
-        if (DownloadProxy* downloadProxy = m_downloads.get(decoder.destinationID()).get())
-            downloadProxy->didReceiveSyncDownloadProxyMessage(connection, messageID, decoder, replyEncoder);
-        return;
-    }
-
     switch (messageID.get<WebContextLegacyMessage::Kind>()) {
         case WebContextLegacyMessage::PostSynchronousMessage: {
             // FIXME: We should probably encode something in the case that the arguments do not decode correctly.