Title: [132740] trunk/Source/WebKit2
Revision
132740
Author
wei...@apple.com
Date
2012-10-27 13:48:52 -0700 (Sat, 27 Oct 2012)

Log Message

Yet more MessageReceivering
https://bugs.webkit.org/show_bug.cgi?id=100325

Reviewed by Anders Carlsson.

Make DownloadProxy, WebPageProxy, and WebPageGroupProxy MessageReceivers.

* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::DownloadProxy):
(WebKit::DownloadProxy::invalidate):
(WebKit::DownloadProxy::didReceiveMessage):
(WebKit::DownloadProxy::didReceiveSyncMessage):
* UIProcess/Downloads/DownloadProxy.h:
(DownloadProxy):
Make a MessageReceiver.

* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):
(WebKit::WebContext::addMessageReceiver):
(WebKit::WebContext::removeMessageReceiver):
(WebKit::WebContext::didReceiveMessage):
(WebKit::WebContext::didReceiveSyncMessage):
* UIProcess/WebContext.h:
Add additional MessageReceiverMap forwards, and stop dealing with DownloadProxy explicitly.
        
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::~WebPageProxy):
(WebKit::WebPageProxy::didReceiveMessage):
(WebKit::WebPageProxy::didReceiveSyncMessage):
* UIProcess/WebPageProxy.h:
Make a MessageReceiver, but keep sub objects using didReceiveMessage for now (like WebPage).
        
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::addMessageReceiver):
(WebKit::WebProcessProxy::removeMessageReceiver):
(WebKit::WebProcessProxy::didReceiveMessage):
(WebKit::WebProcessProxy::didReceiveSyncMessage):
* UIProcess/WebProcessProxy.h:
Give WebProcessProxy a MessageReceiverMap and all the appropriate forwarding methods.
        
* WebProcess/WebPage/WebPageGroupProxy.cpp:
(WebKit::WebPageGroupProxy::WebPageGroupProxy):
(WebKit::WebPageGroupProxy::~WebPageGroupProxy):
(WebKit::WebPageGroupProxy::didReceiveMessage):
* WebProcess/WebPage/WebPageGroupProxy.h:
(WebKit::WebPageGroupProxy::isVisibleToHistoryClient):
(WebPageGroupProxy):
Make a MessageReceiver and register/unregister with the WebProcess.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::didReceiveSyncMessage):
Remove extraneous return statement.
(WebKit::WebProcess::didReceiveMessage):
Stop handling WebPageGroupProxy special.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (132739 => 132740)


--- trunk/Source/WebKit2/ChangeLog	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/ChangeLog	2012-10-27 20:48:52 UTC (rev 132740)
@@ -1,5 +1,63 @@
 2012-10-27  Sam Weinig  <s...@webkit.org>
 
+        Yet more MessageReceivering
+        https://bugs.webkit.org/show_bug.cgi?id=100325
+
+        Reviewed by Anders Carlsson.
+
+        Make DownloadProxy, WebPageProxy, and WebPageGroupProxy MessageReceivers.
+
+        * UIProcess/Downloads/DownloadProxy.cpp:
+        (WebKit::DownloadProxy::DownloadProxy):
+        (WebKit::DownloadProxy::invalidate):
+        (WebKit::DownloadProxy::didReceiveMessage):
+        (WebKit::DownloadProxy::didReceiveSyncMessage):
+        * UIProcess/Downloads/DownloadProxy.h:
+        (DownloadProxy):
+        Make a MessageReceiver.
+
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::WebContext):
+        (WebKit::WebContext::addMessageReceiver):
+        (WebKit::WebContext::removeMessageReceiver):
+        (WebKit::WebContext::didReceiveMessage):
+        (WebKit::WebContext::didReceiveSyncMessage):
+        * UIProcess/WebContext.h:
+        Add additional MessageReceiverMap forwards, and stop dealing with DownloadProxy explicitly.
+        
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::~WebPageProxy):
+        (WebKit::WebPageProxy::didReceiveMessage):
+        (WebKit::WebPageProxy::didReceiveSyncMessage):
+        * UIProcess/WebPageProxy.h:
+        Make a MessageReceiver, but keep sub objects using didReceiveMessage for now (like WebPage).
+        
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::addMessageReceiver):
+        (WebKit::WebProcessProxy::removeMessageReceiver):
+        (WebKit::WebProcessProxy::didReceiveMessage):
+        (WebKit::WebProcessProxy::didReceiveSyncMessage):
+        * UIProcess/WebProcessProxy.h:
+        Give WebProcessProxy a MessageReceiverMap and all the appropriate forwarding methods.
+        
+        * WebProcess/WebPage/WebPageGroupProxy.cpp:
+        (WebKit::WebPageGroupProxy::WebPageGroupProxy):
+        (WebKit::WebPageGroupProxy::~WebPageGroupProxy):
+        (WebKit::WebPageGroupProxy::didReceiveMessage):
+        * WebProcess/WebPage/WebPageGroupProxy.h:
+        (WebKit::WebPageGroupProxy::isVisibleToHistoryClient):
+        (WebPageGroupProxy):
+        Make a MessageReceiver and register/unregister with the WebProcess.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::didReceiveSyncMessage):
+        Remove extraneous return statement.
+        (WebKit::WebProcess::didReceiveMessage):
+        Stop handling WebPageGroupProxy special.
+
+2012-10-27  Sam Weinig  <s...@webkit.org>
+
         Completely roll out https://bugs.webkit.org/show_bug.cgi?id=99251 (r131686)
 
         It has caused too many crashes.

Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp (132739 => 132740)


--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp	2012-10-27 20:48:52 UTC (rev 132740)
@@ -28,6 +28,7 @@
 
 #include "AuthenticationChallengeProxy.h"
 #include "DataReference.h"
+#include "DownloadProxyMessages.h"
 #include "WebContext.h"
 #include "WebData.h"
 #include "WebProcessMessages.h"
@@ -53,6 +54,7 @@
     : m_webContext(webContext)
     , m_downloadID(generateDownloadID())
 {
+    m_webContext->addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), m_downloadID, this);
 }
 
 DownloadProxy::~DownloadProxy()
@@ -72,6 +74,8 @@
 void DownloadProxy::invalidate()
 {
     ASSERT(m_webContext);
+
+    m_webContext->removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), m_downloadID);
     m_webContext = 0;
 }
 
@@ -200,5 +204,15 @@
 }
 #endif
 
+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);
+}
+
 } // namespace WebKit
 

Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h (132739 => 132740)


--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h	2012-10-27 20:48:52 UTC (rev 132740)
@@ -45,7 +45,7 @@
 class WebData;
 class WebPageProxy;
 
-class DownloadProxy : public APIObject {
+class DownloadProxy : public APIObject, private CoreIPC::MessageReceiver {
 public:
     static const Type APIType = TypeDownload;
 
@@ -61,9 +61,6 @@
     void invalidate();
     void processDidClose();
 
-    void didReceiveDownloadProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
-    void didReceiveSyncDownloadProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
-
 #if PLATFORM(QT)
     void startTransfer(const String& filename);
 #endif
@@ -73,6 +70,14 @@
 
     virtual Type type() const { return APIType; }
 
+    // CoreIPC::MessageReceiver
+    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
+    void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&) OVERRIDE;
+
+    // Implemented in generated DownloadProxyMessageReceiver.cpp
+    void didReceiveDownloadProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
+    void didReceiveSyncDownloadProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
+
     // Message handlers.
     void didStart(const WebCore::ResourceRequest&);
     void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&, uint64_t challengeID);

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (132739 => 132740)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2012-10-27 20:48:52 UTC (rev 132740)
@@ -761,7 +761,6 @@
 {
     RefPtr<DownloadProxy> downloadProxy = DownloadProxy::create(this);
     m_downloads.set(downloadProxy->downloadID(), downloadProxy);
-    addMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID(), this);
     return downloadProxy.get();
 }
 
@@ -770,7 +769,6 @@
     ASSERT(m_downloads.contains(downloadProxy->downloadID()));
 
     downloadProxy->invalidate();
-    removeMessageReceiver(Messages::DownloadProxy::messageReceiverName(), downloadProxy->downloadID());
     m_downloads.remove(downloadProxy->downloadID());
 }
 
@@ -818,13 +816,6 @@
         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;
@@ -852,12 +843,6 @@
         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.

Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (132739 => 132740)


--- trunk/Source/WebKit2/UIProcess/WebContext.h	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h	2012-10-27 20:48:52 UTC (rev 132740)
@@ -50,30 +50,31 @@
 
 class DownloadProxy;
 class WebApplicationCacheManagerProxy;
-#if ENABLE(BATTERY_STATUS)
-class WebBatteryManagerProxy;
-#endif
 class WebCookieManagerProxy;
 class WebDatabaseManagerProxy;
 class WebGeolocationManagerProxy;
 class WebIconDatabase;
 class WebKeyValueStorageManagerProxy;
 class WebMediaCacheManagerProxy;
-#if ENABLE(NETWORK_INFO)
-class WebNetworkInfoManagerProxy;
-#endif
 class WebNotificationManagerProxy;
 class WebPageGroup;
 class WebPageProxy;
 class WebResourceCacheManagerProxy;
+struct StatisticsData;
+struct WebProcessCreationParameters;
+
+#if ENABLE(BATTERY_STATUS)
+class WebBatteryManagerProxy;
+#endif
+#if ENABLE(NETWORK_INFO)
+class WebNetworkInfoManagerProxy;
+#endif
 #if USE(SOUP)
 class WebSoupRequestManagerProxy;
 #endif
 #if ENABLE(VIBRATION)
 class WebVibrationProxy;
 #endif
-struct StatisticsData;
-struct WebProcessCreationParameters;
     
 typedef GenericCallback<WKDictionaryRef> DictionaryCallback;
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (132739 => 132740)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2012-10-27 20:48:52 UTC (rev 132740)
@@ -32,6 +32,7 @@
 #include "DataReference.h"
 #include "DownloadProxy.h"
 #include "DrawingAreaProxy.h"
+#include "DrawingAreaProxyMessages.h"
 #include "EventDispatcherMessages.h"
 #include "FindIndicator.h"
 #include "Logging.h"
@@ -69,6 +70,7 @@
 #include "WebPageGroup.h"
 #include "WebPageGroupData.h"
 #include "WebPageMessages.h"
+#include "WebPageProxyMessages.h"
 #include "WebPopupItem.h"
 #include "WebPopupMenuProxy.h"
 #include "WebPreferences.h"
@@ -88,6 +90,14 @@
 #include <WebCore/WindowFeatures.h>
 #include <stdio.h>
 
+#if ENABLE(INSPECTOR)
+#include "WebInspectorProxyMessages.h"
+#endif
+
+#if ENABLE(FULLSCREEN_API)
+#include "WebFullScreenManagerProxyMessages.h"
+#endif
+
 #if ENABLE(WEB_INTENTS)
 #include "IntentData.h"
 #include "IntentServiceInfo.h"
@@ -244,6 +254,20 @@
 
     WebContext::statistics().wkPageCount++;
 
+    m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, this);
+
+    // FIXME: This should be done in the object constructors, and the objects themselves should be message receivers.
+    m_process->addMessageReceiver(Messages::DrawingAreaProxy::messageReceiverName(), m_pageID, this);
+#if USE(COORDINATED_GRAPHICS)
+    m_process->addMessageReceiver(Messages::LayerTreeCoordinatorProxy::messageReceiverName(), m_pageID, this);
+#endif
+#if ENABLE(INSPECTOR)
+    m_process->addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_pageID, this);
+#endif
+#if ENABLE(FULLSCREEN_API)
+    m_process->addMessageReceiver(Messages::WebFullScreenManagerProxy::messageReceiverName(), m_pageID, this);
+#endif
+
     m_pageGroup->addPage(this);
 }
 
@@ -259,6 +283,20 @@
 
     m_pageGroup->removePage(this);
 
+    m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID);
+
+    // FIXME: This should be done in the object destructors, and the objects themselves should be message receivers.
+    m_process->removeMessageReceiver(Messages::DrawingAreaProxy::messageReceiverName(), m_pageID);
+#if USE(COORDINATED_GRAPHICS)
+    m_process->removeMessageReceiver(Messages::LayerTreeCoordinatorProxy::messageReceiverName(), m_pageID);
+#endif
+#if ENABLE(INSPECTOR)
+    m_process->removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_pageID);
+#endif
+#if ENABLE(FULLSCREEN_API)
+    m_process->removeMessageReceiver(Messages::WebFullScreenManagerProxy::messageReceiverName(), m_pageID);
+#endif
+
 #ifndef NDEBUG
     webPageProxyCounter.decrement();
 #endif
@@ -1865,6 +1903,7 @@
     }
 #endif
 
+    ASSERT(messageID.is<CoreIPC::MessageClassWebPageProxy>());
     didReceiveWebPageProxyMessage(connection, messageID, decoder);
 }
 
@@ -1886,6 +1925,7 @@
 #endif
 
     // FIXME: Do something with reply.
+    ASSERT(messageID.is<CoreIPC::MessageClassWebPageProxy>());
     didReceiveSyncWebPageProxyMessage(connection, messageID, decoder, replyEncoder);
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (132739 => 132740)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-10-27 20:48:52 UTC (rev 132740)
@@ -32,14 +32,9 @@
 #include "DrawingAreaProxy.h"
 #include "EditorState.h"
 #include "GeolocationPermissionRequestManagerProxy.h"
-#if ENABLE(TOUCH_EVENTS)
-#include "NativeWebTouchEvent.h"
-#endif
-#if PLATFORM(QT)
-#include "QtNetworkRequestData.h"
-#endif
 #include "LayerTreeContext.h"
 #include "NotificationPermissionRequestManagerProxy.h"
+#include "MessageReceiver.h"
 #include "PlatformProcessIdentifier.h"
 #include "SandboxExtension.h"
 #include "ShareableBitmap.h"
@@ -82,16 +77,17 @@
 #include <WebCore/DragSession.h>
 #endif
 
+#if ENABLE(TOUCH_EVENTS)
+#include "NativeWebTouchEvent.h"
+#endif
+#if PLATFORM(QT)
+#include "QtNetworkRequestData.h"
+#endif
+
 #if PLATFORM(EFL)
 #include <Evas.h>
 #endif
 
-namespace CoreIPC {
-    class ArgumentDecoder;
-    class Connection;
-    class MessageID;
-}
-
 namespace WebCore {
     class AuthenticationChallenge;
     class Cursor;
@@ -244,7 +240,7 @@
 #if ENABLE(INPUT_TYPE_COLOR)
     , public WebColorChooserProxy::Client
 #endif
-    , public WebPopupMenuProxy::Client {
+    , public WebPopupMenuProxy::Client, private CoreIPC::MessageReceiver {
 public:
     static const Type APIType = TypePage;
 
@@ -599,9 +595,6 @@
 #endif
 #endif
 
-    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
-    void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
-
     void processDidBecomeUnresponsive();
     void interactionOccurredWhileProcessUnresponsive();
     void processDidBecomeResponsive();
@@ -748,6 +741,10 @@
 
     virtual Type type() const { return APIType; }
 
+    // CoreIPC::MessageReceiver
+    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
+    void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&) OVERRIDE;
+
     // WebPopupMenuProxy::Client
     virtual void valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex);
     virtual void setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index);

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (132739 => 132740)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2012-10-27 20:48:52 UTC (rev 132740)
@@ -121,6 +121,21 @@
     return webProcessProxy;
 }
 
+void WebProcessProxy::addMessageReceiver(CoreIPC::StringReference messageReceiverName, CoreIPC::MessageReceiver* messageReceiver)
+{
+    m_messageReceiverMap.addMessageReceiver(messageReceiverName, messageReceiver);
+}
+
+void WebProcessProxy::addMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID, CoreIPC::MessageReceiver* messageReceiver)
+{
+    m_messageReceiverMap.addMessageReceiver(messageReceiverName, destinationID, messageReceiver);
+}
+
+void WebProcessProxy::removeMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID)
+{
+    m_messageReceiverMap.removeMessageReceiver(messageReceiverName, destinationID);
+}
+
 void WebProcessProxy::connect()
 {
     ASSERT(!m_processLauncher);
@@ -416,44 +431,27 @@
 
 void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
 {
-    if (m_context->dispatchMessage(connection, messageID, decoder))
+    if (m_messageReceiverMap.dispatchMessage(connection, messageID, decoder))
         return;
 
-    if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) {
-        didReceiveWebProcessProxyMessage(connection, messageID, decoder);
+    if (m_context->dispatchMessage(connection, messageID, decoder))
         return;
-    }
 
-    uint64_t pageID = decoder.destinationID();
-    if (!pageID)
-        return;
-
-    WebPageProxy* pageProxy = webPage(pageID);
-    if (!pageProxy)
-        return;
-    
-    pageProxy->didReceiveMessage(connection, messageID, decoder);
+    ASSERT(messageID.is<CoreIPC::MessageClassWebProcessProxy>());
+    didReceiveWebProcessProxyMessage(connection, messageID, decoder);
 }
 
 void WebProcessProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder)
 {
-    if (m_context->dispatchSyncMessage(connection, messageID, decoder, replyEncoder))
+    if (m_messageReceiverMap.dispatchSyncMessage(connection, messageID, decoder, replyEncoder))
         return;
 
-    if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) {
-        didReceiveSyncWebProcessProxyMessage(connection, messageID, decoder, replyEncoder);
+    if (m_context->dispatchSyncMessage(connection, messageID, decoder, replyEncoder))
         return;
-    }
 
-    uint64_t pageID = decoder.destinationID();
-    if (!pageID)
-        return;
     
-    WebPageProxy* pageProxy = webPage(pageID);
-    if (!pageProxy)
-        return;
-    
-    pageProxy->didReceiveSyncMessage(connection, messageID, decoder, replyEncoder);
+    ASSERT(messageID.is<CoreIPC::MessageClassWebProcessProxy>());
+    didReceiveSyncWebProcessProxyMessage(connection, messageID, decoder, replyEncoder);
 }
 
 void WebProcessProxy::didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, bool& didHandleMessage)

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (132739 => 132740)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2012-10-27 20:48:52 UTC (rev 132740)
@@ -26,6 +26,7 @@
 #ifndef WebProcessProxy_h
 #define WebProcessProxy_h
 
+#include "MessageReceiverMap.h"
 #include "PlatformProcessIdentifier.h"
 #include "PluginInfoStore.h"
 #include "ProcessLauncher.h"
@@ -63,6 +64,10 @@
     static PassRefPtr<WebProcessProxy> create(PassRefPtr<WebContext>);
     ~WebProcessProxy();
 
+    void addMessageReceiver(CoreIPC::StringReference messageReceiverName, CoreIPC::MessageReceiver*);
+    void addMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID, CoreIPC::MessageReceiver*);
+    void removeMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID);
+
     static WebProcessProxy* fromConnection(CoreIPC::Connection*);
 
     void terminate();
@@ -201,6 +206,7 @@
     // This is not a CoreIPC::Connection so that we can wrap the CoreIPC::Connection in
     // an API object.
     RefPtr<WebConnectionToWebProcess> m_connection;
+    CoreIPC::MessageReceiverMap m_messageReceiverMap;
 
     Vector<std::pair<CoreIPC::Connection::OutgoingMessage, unsigned> > m_pendingMessages;
     RefPtr<ProcessLauncher> m_processLauncher;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.cpp (132739 => 132740)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.cpp	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.cpp	2012-10-27 20:48:52 UTC (rev 132740)
@@ -26,8 +26,9 @@
 #include "config.h"
 #include "WebPageGroupProxy.h"
 
+#include "InjectedBundle.h"
+#include "WebPageGroupProxyMessages.h"
 #include "WebProcess.h"
-#include "InjectedBundle.h"
 #include <WebCore/DOMWrapperWorld.h>
 #include <WebCore/PageGroup.h>
 
@@ -43,25 +44,28 @@
     return pageGroup.release();
 }
 
-WebPageGroupProxy::~WebPageGroupProxy()
-{
-}
-    
-void WebPageGroupProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
-{
-    didReceiveWebPageGroupProxyMessage(connection, messageID, decoder);
-}
-    
 WebPageGroupProxy::WebPageGroupProxy(const WebPageGroupData& data)
     : m_data(data)
     , m_pageGroup(WebCore::PageGroup::pageGroup(m_data.identifer))
 {
+    WebProcess::shared().addMessageReceiver(Messages::WebPageGroupProxy::messageReceiverName(), m_data.pageGroupID, this);
+
     for (size_t i = 0; i < data.userStyleSheets.size(); ++i)
         addUserStyleSheet(data.userStyleSheets[i]);
     for (size_t i = 0; i < data.userScripts.size(); ++i)
         addUserScript(data.userScripts[i]);
 }
 
+WebPageGroupProxy::~WebPageGroupProxy()
+{
+    WebProcess::shared().removeMessageReceiver(Messages::WebPageGroupProxy::messageReceiverName(), m_data.pageGroupID);
+}
+
+void WebPageGroupProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
+{
+    didReceiveWebPageGroupProxyMessage(connection, messageID, decoder);
+}
+
 void WebPageGroupProxy::addUserStyleSheet(const WebCore::UserStyleSheet& userStyleSheet)
 {
     m_pageGroup->addUserStyleSheetToWorld(WebCore::mainThreadNormalWorld(), userStyleSheet.source(), userStyleSheet.url(), userStyleSheet.whitelist(), userStyleSheet.blacklist(), userStyleSheet.injectedFrames(), userStyleSheet.level());

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h (132739 => 132740)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPageGroupProxy.h	2012-10-27 20:48:52 UTC (rev 132740)
@@ -27,22 +27,17 @@
 #define WebPageGroupProxy_h
 
 #include "APIObject.h"
+#include "MessageReceiver.h"
 #include "WebPageGroupData.h"
 #include <wtf/PassRefPtr.h>
 
-namespace CoreIPC {
-class Connection;
-class MessageDecoder;
-class MessageID;
-}
-
 namespace WebCore {
 class PageGroup;
 }
 
 namespace WebKit {
 
-class WebPageGroupProxy : public APIObject {
+class WebPageGroupProxy : public APIObject, private CoreIPC::MessageReceiver {
 public:
     static const Type APIType = TypeBundlePageGroup;
 
@@ -53,14 +48,16 @@
     uint64_t pageGroupID() const { return m_data.pageGroupID; }
     bool isVisibleToInjectedBundle() const { return m_data.visibleToInjectedBundle; }
     bool isVisibleToHistoryClient() const { return m_data.visibleToHistoryClient; }
-    
-    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
 
 private:
     WebPageGroupProxy(const WebPageGroupData&);
 
     virtual Type type() const { return APIType; }
     
+    // CoreIPC::MessageReceiver
+    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
+
+    // Implemented in generated WebPageGroupProxyMessageReceiver.cpp
     void didReceiveWebPageGroupProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
     
     void addUserStyleSheet(const WebCore::UserStyleSheet&);

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (132739 => 132740)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2012-10-27 20:33:17 UTC (rev 132739)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2012-10-27 20:48:52 UTC (rev 132740)
@@ -661,7 +661,6 @@
 void WebProcess::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder)
 {
     m_messageReceiverMap.dispatchSyncMessage(connection, messageID, decoder, replyEncoder);
-        return;
 }
 
 void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
@@ -705,18 +704,6 @@
         WebResourceCacheManager::shared().didReceiveMessage(connection, messageID, decoder);
         return;
     }
-    
-    if (messageID.is<CoreIPC::MessageClassWebPageGroupProxy>()) {
-        uint64_t pageGroupID = decoder.destinationID();
-        if (!pageGroupID)
-            return;
-        
-        WebPageGroupProxy* pageGroupProxy = webPageGroup(pageGroupID);
-        if (!pageGroupProxy)
-            return;
-        
-        pageGroupProxy->didReceiveMessage(connection, messageID, decoder);
-    }
 }
 
 void WebProcess::didClose(CoreIPC::Connection*)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to