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

Unified Diff: mojo/system/channel_endpoint.cc

Issue 584723002: Mojo: Add Channel::AttachEndpoint(), which takes a ChannelEndpoint. (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/proxy_message_pipe_endpoint.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 98cc3c01de1ed0dc9e4fe687bb810c6cf3fd7434..dd0deb2a522bea71be3022b26dceecff1100a66f 100644
--- a/mojo/system/channel_endpoint.cc
+++ b/mojo/system/channel_endpoint.cc
@@ -26,20 +26,17 @@ 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".
+
+ // TODO(vtl): Currently, this only works in the "running" case.
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());
+ return WriteMessageNoLock(message.Pass());
}
void ChannelEndpoint::DetachFromMessagePipe() {
@@ -99,5 +96,20 @@ ChannelEndpoint::~ChannelEndpoint() {
DCHECK_EQ(remote_id_, MessageInTransit::kInvalidEndpointId);
}
+bool ChannelEndpoint::WriteMessageNoLock(scoped_ptr<MessageInTransit> message) {
+ DCHECK(message);
+
+ lock_.AssertAcquired();
+
+ DCHECK(channel_);
+ DCHECK_NE(local_id_, MessageInTransit::kInvalidEndpointId);
+ 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());
+}
+
} // namespace system
} // namespace mojo
« no previous file with comments | « mojo/system/channel_endpoint.h ('k') | mojo/system/proxy_message_pipe_endpoint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698