Commit 72c2a9ec authored by viettrungluu's avatar viettrungluu Committed by Commit bot

Mojo: Remove MessagePipe::Attach().

R=darin@chromium.org

Review URL: https://codereview.chromium.org/600523002

Cr-Commit-Position: refs/heads/master@{#296793}
parent 54193f59
...@@ -118,32 +118,7 @@ MessageInTransit::EndpointId Channel::AttachEndpoint( ...@@ -118,32 +118,7 @@ MessageInTransit::EndpointId Channel::AttachEndpoint(
} }
endpoint->AttachToChannel(this, local_id); endpoint->AttachToChannel(this, local_id);
// This might fail if that port got an |OnPeerClose()| before attaching. return local_id;
if (endpoint->message_pipe_->Attach(endpoint->port_, endpoint.get()))
return local_id;
// Note: If it failed, quite possibly the endpoint info was removed from that
// map (there's a race between us adding it to the map above and calling
// |Attach()|). And even if an entry exists for |local_id|, we need to check
// that it's the one we added (and not some other one that was added since).
{
base::AutoLock locker(lock_);
IdToEndpointMap::iterator it = local_id_to_endpoint_map_.find(local_id);
if (it != local_id_to_endpoint_map_.end() &&
it->second->message_pipe_.get() == endpoint->message_pipe_.get() &&
it->second->port_ == endpoint->port_) {
DCHECK_EQ(it->second->state_, ChannelEndpoint::STATE_NORMAL);
// TODO(vtl): FIXME -- This is wrong. We need to specify (to
// |AttachEndpoint()| who's going to be responsible for calling
// |RunMessagePipeEndpoint()| ("us", or the remote by sending us a
// |kSubtypeChannelRunMessagePipeEndpoint|). If the remote is going to
// run, then we'll get messages to an "invalid" local ID (for running, for
// removal).
local_id_to_endpoint_map_.erase(it);
}
}
endpoint->DetachFromChannel();
return MessageInTransit::kInvalidEndpointId;
} }
bool Channel::RunMessagePipeEndpoint(MessageInTransit::EndpointId local_id, bool Channel::RunMessagePipeEndpoint(MessageInTransit::EndpointId local_id,
......
...@@ -187,18 +187,6 @@ MojoResult MessagePipe::EnqueueMessage(unsigned port, ...@@ -187,18 +187,6 @@ MojoResult MessagePipe::EnqueueMessage(unsigned port,
return EnqueueMessageInternal(port, message.Pass(), nullptr); return EnqueueMessageInternal(port, message.Pass(), nullptr);
} }
bool MessagePipe::Attach(unsigned port, ChannelEndpoint* channel_endpoint) {
DCHECK(port == 0 || port == 1);
DCHECK(channel_endpoint);
base::AutoLock locker(lock_);
if (!endpoints_[port])
return false;
DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeProxy);
return true;
}
void MessagePipe::Run(unsigned port) { void MessagePipe::Run(unsigned port) {
DCHECK(port == 0 || port == 1); DCHECK(port == 0 || port == 1);
......
...@@ -96,8 +96,6 @@ class MOJO_SYSTEM_IMPL_EXPORT MessagePipe ...@@ -96,8 +96,6 @@ class MOJO_SYSTEM_IMPL_EXPORT MessagePipe
scoped_ptr<MessageInTransit> message); scoped_ptr<MessageInTransit> message);
// These are used by |Channel|. // These are used by |Channel|.
// TODO(vtl): Remove |Attach()|.
bool Attach(unsigned port, ChannelEndpoint* channel_endpoint);
void Run(unsigned port); void Run(unsigned port);
void OnRemove(unsigned port); void OnRemove(unsigned port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment