Index: ipc/ipc_channel_mojo.cc |
diff --git a/ipc/ipc_channel_mojo.cc b/ipc/ipc_channel_mojo.cc |
index 9948e2dbf220348828c7aaf3f934c67e2ff3b372..80bbfb5627d562803885933a417241d70041ca1b 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)); |
} |