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

Unified Diff: mojo/system/channel_endpoint.cc

Issue 580123004: Mojo: Remove knowledge of Channel, etc. from ProxyMessagePipeEndpoint. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « mojo/system/channel_endpoint.h ('k') | mojo/system/message_pipe.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/channel_endpoint.cc
diff --git a/mojo/system/channel_endpoint.cc b/mojo/system/channel_endpoint.cc
index 7016a1ab20e6c33b51779a3cab52aa81524f2090..98cc3c01de1ed0dc9e4fe687bb810c6cf3fd7434 100644
--- a/mojo/system/channel_endpoint.cc
+++ b/mojo/system/channel_endpoint.cc
@@ -22,6 +22,45 @@ ChannelEndpoint::ChannelEndpoint(MessagePipe* message_pipe, unsigned port)
DCHECK(port_ == 0 || port_ == 1);
}
+bool ChannelEndpoint::EnqueueMessage(scoped_ptr<MessageInTransit> message) {
+ DCHECK(message);
+
+ base::AutoLock locker(lock_);
+ if (!channel_) {
+ // Generally, this should only happen if the channel is shut down for some
+ // reason (with live message pipes on it).
+ return false;
+ }
+ DCHECK_NE(local_id_, MessageInTransit::kInvalidEndpointId);
+ // TODO(vtl): Currently, we only support enqueueing messages when we're
+ // "running".
+ DCHECK_NE(remote_id_, MessageInTransit::kInvalidEndpointId);
+
+ message->SerializeAndCloseDispatchers(channel_);
+ message->set_source_id(local_id_);
+ message->set_destination_id(remote_id_);
+ return channel_->WriteMessage(message.Pass());
+}
+
+void ChannelEndpoint::DetachFromMessagePipe() {
+ // TODO(vtl): Once |message_pipe_| is under |lock_|, we should null it out
+ // here. For now, get the channel to do so for us.
+
+ scoped_refptr<Channel> channel;
+ {
+ base::AutoLock locker(lock_);
+ if (!channel_)
+ return;
+ DCHECK_NE(local_id_, MessageInTransit::kInvalidEndpointId);
+ // TODO(vtl): Once we combine "run" into "attach", |remote_id_| should valid
+ // here as well.
+ channel = channel_;
+ }
+ // Don't call this under |lock_|, since it'll call us back.
+ // TODO(vtl): This seems pretty suboptimal.
+ channel->DetachMessagePipeEndpoint(local_id_, remote_id_);
+}
+
void ChannelEndpoint::AttachToChannel(Channel* channel,
MessageInTransit::EndpointId local_id) {
DCHECK(channel);
« no previous file with comments | « mojo/system/channel_endpoint.h ('k') | mojo/system/message_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698