Index: third_party/mojo/src/mojo/edk/system/message_pipe.cc |
diff --git a/third_party/mojo/src/mojo/edk/system/message_pipe.cc b/third_party/mojo/src/mojo/edk/system/message_pipe.cc |
index 554401e875bd2ab8103ae07931406abe6b823928..34053c82d4e3a90f2a38d92152fc2b66bf935e97 100644 |
--- a/third_party/mojo/src/mojo/edk/system/message_pipe.cc |
+++ b/third_party/mojo/src/mojo/edk/system/message_pipe.cc |
@@ -206,6 +206,14 @@ void MessagePipe::RemoveAwakable(unsigned port, |
endpoints_[port]->RemoveAwakable(awakable, signals_state); |
} |
+MojoResult MessagePipe::SetAsyncMessageCallback( |
+ unsigned port, |
+ const AsyncMessageCallback& callback) { |
+ base::AutoLock locker(lock_); |
+ DCHECK(endpoints_[port]); |
+ return endpoints_[port]->SetAsyncMessageCallback(callback); |
+} |
+ |
void MessagePipe::StartSerialize(unsigned /*port*/, |
Channel* channel, |
size_t* max_size, |
@@ -273,7 +281,9 @@ bool MessagePipe::EndSerialize( |
return true; |
} |
-bool MessagePipe::OnReadMessage(unsigned port, MessageInTransit* message) { |
+bool MessagePipe::OnReadMessage( |
+ unsigned port, |
+ MessageInTransit::ReadContext& reading_message) { |
base::AutoLock locker(lock_); |
if (!endpoints_[port]) { |
@@ -289,10 +299,10 @@ bool MessagePipe::OnReadMessage(unsigned port, MessageInTransit* message) { |
// |ProxyMessagePipeEndpoint| |port| receives a message (from the |Channel|). |
// We need to pass this message on to its peer port (typically a |
// |LocalMessagePipeEndpoint|). |
- MojoResult result = EnqueueMessageNoLock(GetPeerPort(port), |
- make_scoped_ptr(message), nullptr); |
+ MojoResult result = |
+ DispatchOnReadMessageNoLock(GetPeerPort(port), reading_message); |
DLOG_IF(WARNING, result != MOJO_RESULT_OK) |
- << "EnqueueMessageNoLock() failed (result = " << result << ")"; |
+ << "DispatchOnReadMessageNoLock() failed (result = " << result << ")"; |
return true; |
} |
@@ -311,6 +321,23 @@ MessagePipe::~MessagePipe() { |
DCHECK(!endpoints_[1]); |
} |
+MojoResult MessagePipe::DispatchOnReadMessageNoLock( |
+ unsigned port, |
+ MessageInTransit::ReadContext& reading_message) { |
+ DCHECK(port == 0 || port == 1); |
+ |
+ DCHECK_EQ(reading_message.view().type(), MessageInTransit::kTypeEndpoint); |
+ DCHECK(endpoints_[GetPeerPort(port)]); |
+ |
+ // The destination port need not be open, unlike the source port. |
+ if (!endpoints_[port]) |
+ return MOJO_RESULT_FAILED_PRECONDITION; |
+ |
+ // The endpoint's |EnqueueMessage()| may not report failure. |
+ endpoints_[port]->OnReadMessage(reading_message); |
+ return MOJO_RESULT_OK; |
+} |
+ |
MojoResult MessagePipe::EnqueueMessageNoLock( |
unsigned port, |
scoped_ptr<MessageInTransit> message, |