Give the ChildProcess a MessageReceiverMap
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Dec 2012 02:36:11 +0000 (02:36 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Dec 2012 02:36:11 +0000 (02:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105681

Reviewed by Dan Bernstein.

Moving the MessageReceiverMap to the ChildProcess will help shared code
between the WebProcess and NetworkProcess.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::NetworkProcess):
Pass 'this' instead of the MessageReceiverMap, now that ChildProcess
can be used to access the MessageReceiverMap.

* NetworkProcess/NetworkProcess.h:
(NetworkProcess):
Remove the now extraneous MessageReceiverMap.

* Shared/ChildProcess.cpp:
(WebKit::ChildProcess::ChildProcess):
(WebKit):
(WebKit::ChildProcess::~ChildProcess):
(WebKit::ChildProcess::addMessageReceiver):
(WebKit::ChildProcess::removeMessageReceiver):
* Shared/ChildProcess.h:
(ChildProcess):
Add a MessageReceiverMap and helper functions from WebProcess.

* WebProcess/Authentication/AuthenticationManager.cpp:
(WebKit::AuthenticationManager::AuthenticationManager):
* WebProcess/Authentication/AuthenticationManager.h:
(AuthenticationManager):
Fix the FIXME, passing the ChildProcess rather than the MessageReceiverMap.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
* WebProcess/WebProcess.h:
(WebProcess):
Remove the MessageReceiverMap and helper functions.

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

Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkProcess.cpp
Source/WebKit2/NetworkProcess/NetworkProcess.h
Source/WebKit2/Shared/ChildProcess.cpp
Source/WebKit2/Shared/ChildProcess.h
Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp
Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h

index 8f7fb0c..526f3a1 100644 (file)
@@ -1,3 +1,44 @@
+2012-12-22  Sam Weinig  <sam@webkit.org>
+
+        Give the ChildProcess a MessageReceiverMap
+        https://bugs.webkit.org/show_bug.cgi?id=105681
+
+        Reviewed by Dan Bernstein.
+
+        Moving the MessageReceiverMap to the ChildProcess will help shared code
+        between the WebProcess and NetworkProcess.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::NetworkProcess):
+        Pass 'this' instead of the MessageReceiverMap, now that ChildProcess
+        can be used to access the MessageReceiverMap.
+
+        * NetworkProcess/NetworkProcess.h:
+        (NetworkProcess):
+        Remove the now extraneous MessageReceiverMap.
+
+        * Shared/ChildProcess.cpp:
+        (WebKit::ChildProcess::ChildProcess):
+        (WebKit):
+        (WebKit::ChildProcess::~ChildProcess):
+        (WebKit::ChildProcess::addMessageReceiver):
+        (WebKit::ChildProcess::removeMessageReceiver):
+        * Shared/ChildProcess.h:
+        (ChildProcess):
+        Add a MessageReceiverMap and helper functions from WebProcess.
+
+        * WebProcess/Authentication/AuthenticationManager.cpp:
+        (WebKit::AuthenticationManager::AuthenticationManager):
+        * WebProcess/Authentication/AuthenticationManager.h:
+        (AuthenticationManager):
+        Fix the FIXME, passing the ChildProcess rather than the MessageReceiverMap.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess):
+        * WebProcess/WebProcess.h:
+        (WebProcess):
+        Remove the MessageReceiverMap and helper functions.
+
 2012-12-22  Alexey Proskuryakov  <ap@apple.com>
 
         Windows build fix.
index b0ee19b..d941253 100644 (file)
@@ -54,7 +54,7 @@ NetworkProcess& NetworkProcess::shared()
 NetworkProcess::NetworkProcess()
     : m_hasSetCacheModel(false)
     , m_cacheModel(CacheModelDocumentViewer)
-    , m_downloadsAuthenticationManager(m_messageReceiverMap)
+    , m_downloadsAuthenticationManager(this)
 {
 }
 
index 69d9d00..6f5df35 100644 (file)
@@ -101,8 +101,6 @@ private:
     // The connection to the UI process.
     RefPtr<CoreIPC::Connection> m_uiConnection;
 
-    CoreIPC::MessageReceiverMap m_messageReceiverMap;
-
     // Connections to WebProcesses.
     Vector<RefPtr<NetworkConnectionToWebProcess> > m_webProcessConnections;
 
index 9b99a37..86d6b3d 100644 (file)
@@ -34,6 +34,36 @@ using namespace WebCore;
 
 namespace WebKit {
 
+ChildProcess::ChildProcess()
+    : m_terminationTimeout(0)
+    , m_terminationCounter(0)
+    , m_terminationTimer(RunLoop::main(), this, &ChildProcess::terminationTimerFired)
+{
+    // FIXME: The termination timer should not be scheduled on the main run loop.
+    // It won't work with the threaded mode, but it's not really useful anyway as is.
+    
+    platformInitialize();
+}
+
+ChildProcess::~ChildProcess()
+{
+}
+
+void ChildProcess::addMessageReceiver(CoreIPC::StringReference messageReceiverName, CoreIPC::MessageReceiver* messageReceiver)
+{
+    m_messageReceiverMap.addMessageReceiver(messageReceiverName, messageReceiver);
+}
+
+void ChildProcess::addMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID, CoreIPC::MessageReceiver* messageReceiver)
+{
+    m_messageReceiverMap.addMessageReceiver(messageReceiverName, destinationID, messageReceiver);
+}
+
+void ChildProcess::removeMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID)
+{
+    m_messageReceiverMap.removeMessageReceiver(messageReceiverName, destinationID);
+}
+
 void ChildProcess::disableTermination()
 {
     m_terminationCounter++;
@@ -56,21 +86,6 @@ void ChildProcess::enableTermination()
     m_terminationTimer.startOneShot(m_terminationTimeout);
 }
 
-ChildProcess::ChildProcess()
-    : m_terminationTimeout(0)
-    , m_terminationCounter(0)
-    , m_terminationTimer(RunLoop::main(), this, &ChildProcess::terminationTimerFired)
-{
-    // FIXME: The termination timer should not be scheduled on the main run loop.
-    // It won't work with the threaded mode, but it's not really useful anyway as is.
-    
-    platformInitialize();
-}
-
-ChildProcess::~ChildProcess()
-{
-}
-
 void ChildProcess::terminationTimerFired()
 {
     if (!shouldTerminate())
index 815b9f0..78f95b0 100644 (file)
@@ -27,6 +27,7 @@
 #define ChildProcess_h
 
 #include "Connection.h"
+#include "MessageReceiverMap.h"
 #include <WebCore/RunLoop.h>
 #include <wtf/RetainPtr.h>
 
@@ -62,6 +63,10 @@ public:
         ChildProcess& m_childProcess;
     };
 
+    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);
+
 #if PLATFORM(MAC)
     bool applicationIsOccluded() const { return !m_processVisibleAssertion; }
     void setApplicationIsOccluded(bool);
@@ -71,10 +76,12 @@ public:
 
 protected:
     explicit ChildProcess();
-    ~ChildProcess();
+    virtual ~ChildProcess();
 
     void setTerminationTimeout(double seconds) { m_terminationTimeout = seconds; }
 
+    CoreIPC::MessageReceiverMap m_messageReceiverMap;
+
 private:
     void terminationTimerFired();
 
index 0187c69..4ca2b59 100644 (file)
 #include "AuthenticationManager.h"
 
 #include "AuthenticationManagerMessages.h"
+#include "ChildProcess.h"
 #include "Download.h"
 #include "DownloadProxyMessages.h"
 #include "MessageID.h"
-#include "MessageReceiverMap.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebFrame.h"
 #include "WebPage.h"
@@ -48,9 +48,9 @@ static uint64_t generateAuthenticationChallengeID()
     return uniqueAuthenticationChallengeID++;
 }
 
-AuthenticationManager::AuthenticationManager(CoreIPC::MessageReceiverMap& messageReceiverMap)
+AuthenticationManager::AuthenticationManager(ChildProcess* childProcess)
 {
-    messageReceiverMap.addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), this);
+    childProcess->addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), this);
 }
 
 void AuthenticationManager::setConnection(CoreIPC::Connection* connection)
index d2cb8f8..5559450 100644 (file)
@@ -43,6 +43,7 @@ namespace WebCore {
 
 namespace WebKit {
 
+class ChildProcess;
 class Download;
 class PlatformCertificateInfo;
 class WebFrame;
@@ -51,8 +52,7 @@ class AuthenticationManager : private CoreIPC::MessageReceiver {
     WTF_MAKE_NONCOPYABLE(AuthenticationManager);
 
 public:
-    // FIXME: ChildProcess should just have a MessageReceiverMap, and this should take a ChildProcess.
-    explicit AuthenticationManager(CoreIPC::MessageReceiverMap&);
+    explicit AuthenticationManager(ChildProcess*);
 
     void setConnection(CoreIPC::Connection*);
 
@@ -64,7 +64,6 @@ public:
     void cancelChallenge(uint64_t challengeID);
 
 private:
-
     // CoreIPC::MessageReceiver
     virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
     void didReceiveAuthenticationManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
index 58ecc24..0f9418e 100644 (file)
@@ -149,7 +149,7 @@ WebProcess::WebProcess()
 #if USE(SOUP)
     , m_soupRequestManager(this)
 #endif
-    , m_authenticationManager(m_messageReceiverMap)
+    , m_authenticationManager(this)
 {
 #if USE(PLATFORM_STRATEGIES)
     // Initialize our platform strategies.
@@ -180,21 +180,6 @@ void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, Ru
     m_authenticationManager.setConnection(m_connection.get());
 }
 
-void WebProcess::addMessageReceiver(CoreIPC::StringReference messageReceiverName, CoreIPC::MessageReceiver* messageReceiver)
-{
-    m_messageReceiverMap.addMessageReceiver(messageReceiverName, messageReceiver);
-}
-
-void WebProcess::addMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID, CoreIPC::MessageReceiver* messageReceiver)
-{
-    m_messageReceiverMap.addMessageReceiver(messageReceiverName, destinationID, messageReceiver);
-}
-
-void WebProcess::removeMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID)
-{
-    m_messageReceiverMap.removeMessageReceiver(messageReceiverName, destinationID);
-}
-
 void WebProcess::didCreateDownload()
 {
     disableTermination();
index c596e77..c38392c 100644 (file)
@@ -118,11 +118,6 @@ public:
 
     CoreIPC::Connection* connection() const { return m_connection.get(); }
     WebCore::RunLoop* runLoop() const { return m_runLoop; }
-
-    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);
-
     WebConnectionToUIProcess* webConnectionToUIProcess() const { return m_webConnection.get(); }
 
     WebPage* webPage(uint64_t pageID) const;
@@ -327,8 +322,6 @@ private:
 #endif
 
     RefPtr<CoreIPC::Connection> m_connection;
-    CoreIPC::MessageReceiverMap m_messageReceiverMap;
-
     RefPtr<WebConnectionToUIProcess> m_webConnection;
 
     HashMap<uint64_t, RefPtr<WebPage> > m_pageMap;