| 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
|
|
|