Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Unified Diff: ipc/ipc_message_pipe_reader.cc

Issue 2163633003: Support early associated interface binding on ChannelMojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@explicit-channel-ipc-task-runner
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_message_pipe_reader.h ('k') | ipc/ipc_mojo_bootstrap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ipc/ipc_message_pipe_reader.h ('k') | ipc/ipc_mojo_bootstrap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698