Index: ipc/ipc_channel_proxy.cc |
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc |
index 50431d575604c43045d174fa0800613bba17d463..de9f0230a03c875057e256a2f90098c45219629a 100644 |
--- a/ipc/ipc_channel_proxy.cc |
+++ b/ipc/ipc_channel_proxy.cc |
@@ -143,7 +143,8 @@ ChannelProxy::Context::Context(Listener* listener, |
ipc_task_runner_(ipc_task_runner), |
channel_connected_called_(false), |
message_filter_router_(new MessageFilterRouter()), |
- peer_pid_(base::kNullProcessId) { |
+ peer_pid_(base::kNullProcessId), |
+ channel_is_connected_(false) { |
DCHECK(ipc_task_runner_.get()); |
} |
@@ -200,6 +201,7 @@ void ChannelProxy::Context::OnChannelConnected(int32 peer_pid) { |
// creates a ChannelProxy, calls AddFilter, and then right after starts the |
// peer process. The IO thread could receive a message before the task to add |
// the filter is run on the IO thread. |
+ channel_is_connected_ = true; |
OnAddFilter(); |
// We cache off the peer_pid so it can be safely accessed from both threads. |
@@ -278,6 +280,9 @@ void ChannelProxy::Context::OnSendMessage(scoped_ptr<Message> message) { |
// Called on the IPC::Channel thread |
void ChannelProxy::Context::OnAddFilter() { |
+ if (!channel_is_connected_) |
+ return; |
+ |
std::vector<scoped_refptr<MessageFilter> > new_filters; |
{ |
base::AutoLock auto_lock(pending_filters_lock_); |