Index: ipc/ipc_channel_mojo.cc |
diff --git a/ipc/ipc_channel_mojo.cc b/ipc/ipc_channel_mojo.cc |
index 627efc1dc54f1b7abd9aba0add6247bcce0cce88..96a99c0be71e3853faf4869c08c100a9cbdf3792 100644 |
--- a/ipc/ipc_channel_mojo.cc |
+++ b/ipc/ipc_channel_mojo.cc |
@@ -282,6 +282,14 @@ ChannelMojo::~ChannelMojo() { |
} |
bool ChannelMojo::Connect() { |
+ if (!ConnectPaused()) |
+ return false; |
+ |
+ Unpause(true); |
+ return true; |
+} |
+ |
+bool ChannelMojo::ConnectPaused() { |
WillConnect(); |
DCHECK(!task_runner_); |
@@ -292,6 +300,22 @@ bool ChannelMojo::Connect() { |
return true; |
} |
+void ChannelMojo::Unpause(bool flush) { |
+ bootstrap_->Start(); |
+ |
+ // Ensure that no matter what messages have been queued so far, the first |
+ // message we send is always the peer PID. |
+ DCHECK(message_reader_); |
+ message_reader_->sender()->SetPeerPid(GetSelfPID()); |
+ |
+ if (flush) |
+ Flush(); |
+} |
+ |
+void ChannelMojo::Flush() { |
+ bootstrap_->Flush(); |
+} |
+ |
void ChannelMojo::Close() { |
// NOTE: The MessagePipeReader's destructor may re-enter this function. Use |
// caution when changing this method. |
@@ -306,7 +330,6 @@ void ChannelMojo::Close() { |
// MojoBootstrap::Delegate implementation |
void ChannelMojo::OnPipesAvailable(mojom::ChannelAssociatedPtr sender, |
mojom::ChannelAssociatedRequest receiver) { |
- sender->SetPeerPid(GetSelfPID()); |
message_reader_.reset(new internal::MessagePipeReader( |
pipe_, std::move(sender), std::move(receiver), this)); |
} |