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

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: review comments 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
« no previous file with comments | « mojo/edk/system/message_pipe.h ('k') | mojo/edk/system/proxy_message_pipe_endpoint.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..af007a2f6cda3e13cb56956226b75502995ad38b 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,18 @@ 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 when the |ChannelEndpoint| for the
+ // |ProxyMessagePipeEndpoint| |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 +282,7 @@ MessagePipe::~MessagePipe() {
DCHECK(!endpoints_[1]);
}
-MojoResult MessagePipe::EnqueueMessageInternal(
+MojoResult MessagePipe::EnqueueMessage(
unsigned port,
scoped_ptr<MessageInTransit> message,
std::vector<DispatcherTransport>* transports) {
« no previous file with comments | « mojo/edk/system/message_pipe.h ('k') | mojo/edk/system/proxy_message_pipe_endpoint.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698