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

Unified Diff: mojo/system/channel_endpoint.cc

Issue 577313002: Mojo: Give ChannelEndpoint the remote ID and ProxyMessagePipeEndpoint the 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/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 016e7f8bba4a671432940a39fbc1dea0244bdf72..7016a1ab20e6c33b51779a3cab52aa81524f2090 100644
--- a/mojo/system/channel_endpoint.cc
+++ b/mojo/system/channel_endpoint.cc
@@ -11,29 +11,53 @@
namespace mojo {
namespace system {
-ChannelEndpoint::ChannelEndpoint(MessagePipe* message_pipe,
- unsigned port,
- Channel* channel,
- MessageInTransit::EndpointId local_id)
+ChannelEndpoint::ChannelEndpoint(MessagePipe* message_pipe, unsigned port)
: state_(STATE_NORMAL),
message_pipe_(message_pipe),
port_(port),
- channel_(channel),
- local_id_(local_id) {
+ channel_(),
+ local_id_(MessageInTransit::kInvalidEndpointId),
+ remote_id_(MessageInTransit::kInvalidEndpointId) {
DCHECK(message_pipe_.get());
DCHECK(port_ == 0 || port_ == 1);
+}
+
+void ChannelEndpoint::AttachToChannel(Channel* channel,
+ MessageInTransit::EndpointId local_id) {
+ DCHECK(channel);
+ DCHECK_NE(local_id, MessageInTransit::kInvalidEndpointId);
+
+ base::AutoLock locker(lock_);
+ DCHECK(!channel_);
+ DCHECK_EQ(local_id_, MessageInTransit::kInvalidEndpointId);
+ channel_ = channel;
+ local_id_ = local_id;
+}
+
+void ChannelEndpoint::Run(MessageInTransit::EndpointId remote_id) {
+ DCHECK_NE(remote_id, MessageInTransit::kInvalidEndpointId);
+
+ base::AutoLock locker(lock_);
DCHECK(channel_);
- DCHECK_NE(local_id_, MessageInTransit::kInvalidEndpointId);
+ DCHECK_EQ(remote_id_, MessageInTransit::kInvalidEndpointId);
+ remote_id_ = remote_id;
}
void ChannelEndpoint::DetachFromChannel() {
base::AutoLock locker(lock_);
DCHECK(channel_);
+ DCHECK_NE(local_id_, MessageInTransit::kInvalidEndpointId);
+ // TODO(vtl): Once we combine "run" into "attach", |remote_id_| should valid
+ // here as well.
channel_ = NULL;
+ local_id_ = MessageInTransit::kInvalidEndpointId;
+ remote_id_ = MessageInTransit::kInvalidEndpointId;
}
ChannelEndpoint::~ChannelEndpoint() {
DCHECK(!channel_);
+ DCHECK_EQ(local_id_, MessageInTransit::kInvalidEndpointId);
+ DCHECK_EQ(remote_id_, MessageInTransit::kInvalidEndpointId);
}
} // namespace system
« 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