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

Unified Diff: mojo/edk/system/message_pipe.cc

Issue 738453003: Add a ChannelEndpointClient abstraction. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
Index: mojo/edk/system/message_pipe.cc
diff --git a/mojo/edk/system/message_pipe.cc b/mojo/edk/system/message_pipe.cc
index 731fd904e4fe861fc3c48ae1b552ab995b759f97..4efc1b0d6a98075de52cf857590d6c2d4f3e8ecc 100644
--- a/mojo/edk/system/message_pipe.cc
+++ b/mojo/edk/system/message_pipe.cc
@@ -139,7 +139,7 @@ MojoResult MessagePipe::WriteMessage(
std::vector<DispatcherTransport>* transports,
MojoWriteMessageFlags flags) {
DCHECK(port == 0 || port == 1);
- return EnqueueMessageInternal(
+ return EnqueueMessage(
GetPeerPort(port),
make_scoped_ptr(new MessageInTransit(
MessageInTransit::kTypeMessagePipeEndpoint,
@@ -257,9 +257,17 @@ scoped_refptr<ChannelEndpoint> MessagePipe::ConvertLocalToProxy(unsigned port) {
return channel_endpoint;
}
-MojoResult MessagePipe::EnqueueMessage(unsigned port,
- scoped_ptr<MessageInTransit> message) {
- return EnqueueMessageInternal(port, message.Pass(), nullptr);
+bool MessagePipe::OnReadMessage(unsigned port,
+ scoped_ptr<MessageInTransit> message) {
+ // This is called |ChannelEndpoint| for the |ProxyMessagePipeEndpoint| on
yzshen1 2014/11/18 00:28:17 nit: called -> called by
viettrungluu 2014/11/18 00:47:30 "called when"
+ // |port| receives a message (from the |Channel|). We need to pass this
+ // message on to its peer port (typically a |LocalMessagePipeEndpoint|).
+ return EnqueueMessage(GetPeerPort(port), message.Pass(), nullptr) ==
+ MOJO_RESULT_OK;
+}
+
+void MessagePipe::OnDetachFromChannel(unsigned port) {
+ Close(port);
}
MessagePipe::MessagePipe() {
@@ -273,7 +281,7 @@ MessagePipe::~MessagePipe() {
DCHECK(!endpoints_[1]);
}
-MojoResult MessagePipe::EnqueueMessageInternal(
+MojoResult MessagePipe::EnqueueMessage(
unsigned port,
scoped_ptr<MessageInTransit> message,
std::vector<DispatcherTransport>* transports) {

Powered by Google App Engine
This is Rietveld 408576698