Index: chrome/test/automation/automation_proxy.cc |
diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc |
index ddcc267bd20da5f284d2f7be311fbc9406399e34..9788c29bc07a73c841b6cd70b5185c6828acbae9 100644 |
--- a/chrome/test/automation/automation_proxy.cc |
+++ b/chrome/test/automation/automation_proxy.cc |
@@ -161,22 +161,21 @@ void AutomationProxy::InitializeChannel(const std::string& channel_id, |
// The shutdown event could be global on the same lines as the automation |
// provider, where we use the shutdown event provided by the chrome browser |
// process. |
- IPC::Channel::Mode mode = |
- use_named_interface ? IPC::Channel::MODE_NAMED_CLIENT |
- : IPC::Channel::MODE_SERVER; |
- // Create the pipe immediately if we are serving, so that Chrome doesn't try |
- // to connect an unready server. Create it asynchronously if we are the |
- // client, otherwise the filter may not be in place before Chrome sends |
- // the first automation Hello message. |
- bool create_pipe_now = mode & IPC::Channel::MODE_SERVER_FLAG; |
channel_.reset(new IPC::SyncChannel( |
- channel_id, |
- mode, |
- this, // we are the listener |
- thread_->message_loop_proxy(), |
- create_pipe_now, |
- shutdown_event_.get())); |
+ this, // we are the listener |
+ thread_->message_loop_proxy(), |
+ shutdown_event_.get())); |
channel_->AddFilter(new AutomationMessageFilter(this)); |
+ |
+ // Create the pipe synchronously so that Chrome doesn't try to connect to an |
+ // unready server. Note this is done after adding a message filter to |
+ // guarantee that it doesn't miss any messages when we are the client. |
+ // See crbug.com/102894. |
+ channel_->Init( |
+ channel_id, |
+ use_named_interface ? IPC::Channel::MODE_NAMED_CLIENT |
+ : IPC::Channel::MODE_SERVER, |
+ true /* create_pipe_now */); |
} |
void AutomationProxy::InitializeHandleTracker() { |