Chromium Code Reviews| Index: chrome/common/child_process_host.h |
| =================================================================== |
| --- chrome/common/child_process_host.h (revision 69229) |
| +++ chrome/common/child_process_host.h (working copy) |
| @@ -7,6 +7,7 @@ |
| #pragma once |
| #include <string> |
| +#include <vector> |
| #include "build/build_config.h" |
| @@ -17,7 +18,7 @@ |
| #include "base/basictypes.h" |
| #include "base/scoped_ptr.h" |
| #include "chrome/common/notification_type.h" |
| -#include "ipc/ipc_channel.h" |
| +#include "ipc/ipc_channel_proxy.h" |
| class CommandLine; |
| class FilePath; |
| @@ -29,8 +30,8 @@ |
| // Provides common functionality for hosting a child process and processing IPC |
| // messages between the host and the child process. Subclasses are responsible |
| // for the actual launching and terminating of the child processes. |
| -// |
| -class ChildProcessHost : public IPC::Channel::Listener { |
| +class ChildProcessHost : public IPC::Channel::Listener, |
| + public IPC::Message::Sender { |
| public: |
| virtual ~ChildProcessHost(); |
| @@ -56,16 +57,14 @@ |
| static void PreCacheFont(LOGFONT font); |
| #endif // defined(OS_WIN) |
| + // IPC::Message::Sender implementation. |
| + bool Send(IPC::Message* message); |
| + |
| protected: |
| ChildProcessHost(); |
| - // A helper method to send an IPC message to the child on the channel. |
| - // It behavies just like IPC::Message::Sender::Send. The implementor takes |
| - // ownership of the given Message regardless of whether or not this method |
| - // succeeds. This class does not implement IPC::Message::Sender to prevent |
| - // conflicts with subclasses which indirectly could inherit from |
| - // IPC::Message::Sender. |
| - bool SendOnChannel(IPC::Message* msg); |
| + // Adds an IPC message filter. |
| + void AddFilter(IPC::ChannelProxy::MessageFilter* filter); |
|
brettw
2010/12/15 21:31:10
Can you make explicit that this takes a reference
jam
2010/12/15 21:41:04
Done.
|
| // Derived classes return true if it's ok to shut down the child process. |
| virtual bool CanShutdown() = 0; |
| @@ -91,9 +90,8 @@ |
| // Called when the child process goes away. |
| virtual void OnChildDied(); |
| - // Allows the derived implementation to intercept a message before it is |
| - // handed to the IPC::Channel::Listener::OnMessageReceived implementation. |
| - virtual bool InterceptMessageFromChild(const IPC::Message& msg); |
| + // Notifies the derived class that we told the child process to kill itself. |
| + virtual void ShutdownStarted() { } |
| // Subclasses can implement specific notification methods. |
| virtual void Notify(NotificationType type) { } |
| @@ -117,6 +115,11 @@ |
| scoped_ptr<IPC::Channel> channel_; |
| std::string channel_id_; |
| + // Holds all the IPC message filters. Since this object lives on the IO |
| + // thread, we don't have a IPC::ChannelProxy and so we manage filters |
| + // manually. |
| + std::vector<scoped_refptr<IPC::ChannelProxy::MessageFilter> > filters_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ChildProcessHost); |
| }; |