diff options
author | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 01:06:46 +0000 |
---|---|---|
committer | kkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-16 01:06:46 +0000 |
commit | 952394afc0a0dc5e3e6a1f3c2e1c0fa99b7b681f (patch) | |
tree | 85d8246efdada076c5dda1b0a561d6c3322f37d1 /ipc/ipc_channel_proxy.h | |
parent | 8bbba87862f0ce45234380cebf60e3ded5d88147 (diff) | |
download | chromium_src-952394afc0a0dc5e3e6a1f3c2e1c0fa99b7b681f.zip chromium_src-952394afc0a0dc5e3e6a1f3c2e1c0fa99b7b681f.tar.gz chromium_src-952394afc0a0dc5e3e6a1f3c2e1c0fa99b7b681f.tar.bz2 |
Allow proxy channels to be created without initializing the underlying channel.
This fixes a bug where a client needed to guarantee a message filter was in
place before any messages were received.
It also follows the style of not having constructors that do complex
initialization.
BUG=102894
TEST=none
Review URL: http://codereview.chromium.org/8417054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110229 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_proxy.h')
-rw-r--r-- | ipc/ipc_channel_proxy.h | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h index 4e2ebbf..521389f 100644 --- a/ipc/ipc_channel_proxy.h +++ b/ipc/ipc_channel_proxy.h @@ -120,8 +120,21 @@ class IPC_EXPORT ChannelProxy : public Message::Sender { Channel::Listener* listener, base::MessageLoopProxy* ipc_thread_loop); + // Creates an uninitialized channel proxy. Init must be called to receive + // or send any messages. This two-step setup allows message filters to be + // added before any messages are sent or received. + ChannelProxy(Channel::Listener* listener, + base::MessageLoopProxy* ipc_thread_loop); + virtual ~ChannelProxy(); + // Initializes the channel proxy. Only call this once to initialize a channel + // proxy that was not initialized in its constructor. If create_pipe_now is + // true, the pipe is created synchronously. Otherwise it's created on the IO + // thread. + void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, + bool create_pipe_now); + // Close the IPC::Channel. This operation completes asynchronously, once the // background thread processes the command to close the channel. It is ok to // call this method multiple times. Redundant calls are ignored. @@ -165,13 +178,8 @@ class IPC_EXPORT ChannelProxy : public Message::Sender { protected: class Context; // A subclass uses this constructor if it needs to add more information - // to the internal state. If create_pipe_now is true, the pipe is created - // immediately. Otherwise it's created on the IO thread. - ChannelProxy(const IPC::ChannelHandle& channel_handle, - Channel::Mode mode, - base::MessageLoopProxy* ipc_thread_loop, - Context* context, - bool create_pipe_now); + // to the internal state. + ChannelProxy(Context* context); // Used internally to hold state that is referenced on the IPC thread. class Context : public base::RefCountedThreadSafe<Context>, @@ -257,15 +265,15 @@ class IPC_EXPORT ChannelProxy : public Message::Sender { private: friend class SendTask; - void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, - base::MessageLoopProxy* ipc_thread_loop, bool create_pipe_now); - // By maintaining this indirection (ref-counted) to our internal state, we // can safely be destroyed while the background thread continues to do stuff // that involves this data. scoped_refptr<Context> context_; OutgoingMessageFilter* outgoing_message_filter_; + + // Whether the channel has been initialized. + bool did_init_; }; } // namespace IPC |