Index: ipc/ipc_message_pipe_reader.cc |
diff --git a/ipc/ipc_message_pipe_reader.cc b/ipc/ipc_message_pipe_reader.cc |
index 74c72858fcd179b8389583a85619b3eccb7dab19..8e1b35565bfec09fbabb25835542fbd3e403f627 100644 |
--- a/ipc/ipc_message_pipe_reader.cc |
+++ b/ipc/ipc_message_pipe_reader.cc |
@@ -55,10 +55,8 @@ MessagePipeReader::MessagePipeReader( |
mojo::MessagePipeHandle pipe, |
mojom::ChannelAssociatedPtr sender, |
mojo::AssociatedInterfaceRequest<mojom::Channel> receiver, |
- base::ProcessId peer_pid, |
MessagePipeReader::Delegate* delegate) |
: delegate_(delegate), |
- peer_pid_(peer_pid), |
sender_(std::move(sender)), |
binding_(this, std::move(receiver)), |
sender_interface_id_(sender_.interface_id()), |
@@ -123,9 +121,15 @@ void MessagePipeReader::GetRemoteInterface( |
sender_->GetAssociatedInterface(name, std::move(request)); |
} |
+void MessagePipeReader::SetPeerPid(int32_t peer_pid) { |
+ peer_pid_ = peer_pid; |
+ delegate_->OnPeerPidReceived(); |
+} |
+ |
void MessagePipeReader::Receive( |
mojo::Array<uint8_t> data, |
mojo::Array<mojom::SerializedHandlePtr> handles) { |
+ DCHECK_NE(peer_pid_, base::kNullProcessId); |
Message message( |
data.size() == 0 ? "" : reinterpret_cast<const char*>(&data[0]), |
static_cast<uint32_t>(data.size())); |
@@ -156,16 +160,12 @@ void MessagePipeReader::GetAssociatedInterface( |
void MessagePipeReader::OnPipeError(MojoResult error) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- if (delegate_) |
- delegate_->OnPipeError(); |
+ |
Close(); |
-} |
-void MessagePipeReader::DelayedDeleter::operator()( |
- MessagePipeReader* ptr) const { |
- ptr->Close(); |
- base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
- base::Bind(&DeleteNow, ptr)); |
+ // NOTE: The delegate call below may delete |this|. |
+ if (delegate_) |
+ delegate_->OnPipeError(); |
} |
} // namespace internal |