summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViet-Trung Luu <viettrungluu@chromium.org>2014-09-25 17:09:35 -0700
committerViet-Trung Luu <viettrungluu@chromium.org>2014-09-26 00:10:11 +0000
commit422b434274e09a95ca778dd29890d51ab2c15ae5 (patch)
treed6200dbddeca7a7b9702fe25d26a13df2f7bb8fb
parent87b206f94c49a8205fdc2975d02bd574b0e3cd3d (diff)
downloadchromium_src-422b434274e09a95ca778dd29890d51ab2c15ae5.zip
chromium_src-422b434274e09a95ca778dd29890d51ab2c15ae5.tar.gz
chromium_src-422b434274e09a95ca778dd29890d51ab2c15ae5.tar.bz2
Mojo: Remove ProxyMessagePipeEndpoint::Run(), etc.
R=darin@chromium.org Review URL: https://codereview.chromium.org/596363003 Cr-Commit-Position: refs/heads/master@{#296837}
-rw-r--r--mojo/system/channel.cc6
-rw-r--r--mojo/system/message_pipe.cc16
-rw-r--r--mojo/system/message_pipe.h3
-rw-r--r--mojo/system/message_pipe_endpoint.cc5
-rw-r--r--mojo/system/message_pipe_endpoint.h2
-rw-r--r--mojo/system/proxy_message_pipe_endpoint.cc42
-rw-r--r--mojo/system/proxy_message_pipe_endpoint.h15
7 files changed, 6 insertions, 83 deletions
diff --git a/mojo/system/channel.cc b/mojo/system/channel.cc
index 3114a59..a23a3b3 100644
--- a/mojo/system/channel.cc
+++ b/mojo/system/channel.cc
@@ -125,8 +125,6 @@ bool Channel::RunMessagePipeEndpoint(MessageInTransit::EndpointId local_id,
MessageInTransit::EndpointId remote_id) {
scoped_refptr<ChannelEndpoint> endpoint;
ChannelEndpoint::State state;
- scoped_refptr<MessagePipe> message_pipe;
- unsigned port;
{
base::AutoLock locker(lock_);
@@ -139,8 +137,6 @@ bool Channel::RunMessagePipeEndpoint(MessageInTransit::EndpointId local_id,
return false;
endpoint = it->second;
state = it->second->state_;
- message_pipe = it->second->message_pipe_;
- port = it->second->port_;
}
// Assume that this was in response to |kSubtypeChannelRunMessagePipeEndpoint|
@@ -154,8 +150,6 @@ bool Channel::RunMessagePipeEndpoint(MessageInTransit::EndpointId local_id,
// TODO(vtl): FIXME -- We need to handle the case that message pipe is already
// running when we're here due to |kSubtypeChannelRunMessagePipeEndpoint|).
endpoint->Run(remote_id);
- // TODO(vtl): Get rid of this.
- message_pipe->Run(port);
return true;
}
diff --git a/mojo/system/message_pipe.cc b/mojo/system/message_pipe.cc
index c7acbe6..ed73c0c 100644
--- a/mojo/system/message_pipe.cc
+++ b/mojo/system/message_pipe.cc
@@ -158,13 +158,11 @@ scoped_refptr<ChannelEndpoint> MessagePipe::ConvertLocalToProxy(unsigned port) {
DCHECK(endpoints_[port]);
DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeLocal);
- bool is_peer_open = !!endpoints_[GetPeerPort(port)];
-
// TODO(vtl): Allowing this case is a temporary hack. It'll set up a
// |MessagePipe| with two proxy endpoints, which will then act as a proxy
// (rather than trying to connect the two ends directly).
DLOG_IF(WARNING,
- is_peer_open &&
+ !!endpoints_[GetPeerPort(port)] &&
endpoints_[GetPeerPort(port)]->GetType() !=
MessagePipeEndpoint::kTypeLocal)
<< "Direct message pipe passing across multiple channels not yet "
@@ -173,8 +171,7 @@ scoped_refptr<ChannelEndpoint> MessagePipe::ConvertLocalToProxy(unsigned port) {
scoped_ptr<MessagePipeEndpoint> old_endpoint(endpoints_[port].Pass());
scoped_refptr<ChannelEndpoint> channel_endpoint(
new ChannelEndpoint(this, port));
- endpoints_[port].reset(
- new ProxyMessagePipeEndpoint(channel_endpoint.get(), is_peer_open));
+ endpoints_[port].reset(new ProxyMessagePipeEndpoint(channel_endpoint.get()));
channel_endpoint->TakeMessages(static_cast<LocalMessagePipeEndpoint*>(
old_endpoint.get())->message_queue());
old_endpoint->Close();
@@ -187,15 +184,6 @@ MojoResult MessagePipe::EnqueueMessage(unsigned port,
return EnqueueMessageInternal(port, message.Pass(), nullptr);
}
-void MessagePipe::Run(unsigned port) {
- DCHECK(port == 0 || port == 1);
-
- base::AutoLock locker(lock_);
- DCHECK(endpoints_[port]);
- if (!endpoints_[port]->Run())
- endpoints_[port].reset();
-}
-
void MessagePipe::OnRemove(unsigned port) {
unsigned destination_port = GetPeerPort(port);
diff --git a/mojo/system/message_pipe.h b/mojo/system/message_pipe.h
index afada22..8865879 100644
--- a/mojo/system/message_pipe.h
+++ b/mojo/system/message_pipe.h
@@ -95,8 +95,7 @@ class MOJO_SYSTEM_IMPL_EXPORT MessagePipe
MojoResult EnqueueMessage(unsigned port,
scoped_ptr<MessageInTransit> message);
- // These are used by |Channel|.
- void Run(unsigned port);
+ // This is used by |Channel|. TODO(vtl): Remove it.
void OnRemove(unsigned port);
private:
diff --git a/mojo/system/message_pipe_endpoint.cc b/mojo/system/message_pipe_endpoint.cc
index 5c8153a..205e144 100644
--- a/mojo/system/message_pipe_endpoint.cc
+++ b/mojo/system/message_pipe_endpoint.cc
@@ -52,11 +52,6 @@ void MessagePipeEndpoint::Attach(ChannelEndpoint* /*channel_endpoint*/) {
NOTREACHED();
}
-bool MessagePipeEndpoint::Run() {
- NOTREACHED();
- return true;
-}
-
void MessagePipeEndpoint::OnRemove() {
NOTREACHED();
}
diff --git a/mojo/system/message_pipe_endpoint.h b/mojo/system/message_pipe_endpoint.h
index baf5d69..fdea39c 100644
--- a/mojo/system/message_pipe_endpoint.h
+++ b/mojo/system/message_pipe_endpoint.h
@@ -75,8 +75,6 @@ class MOJO_SYSTEM_IMPL_EXPORT MessagePipeEndpoint {
// implementation for a local endpoint needs not override these methods, since
// they should never be called.
virtual void Attach(ChannelEndpoint* channel_endpoint);
- // Returns false if the endpoint should be closed and destroyed, else true.
- virtual bool Run();
virtual void OnRemove();
protected:
diff --git a/mojo/system/proxy_message_pipe_endpoint.cc b/mojo/system/proxy_message_pipe_endpoint.cc
index 75ce34d..ff8beb8 100644
--- a/mojo/system/proxy_message_pipe_endpoint.cc
+++ b/mojo/system/proxy_message_pipe_endpoint.cc
@@ -16,21 +16,10 @@ namespace system {
ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint(
ChannelEndpoint* channel_endpoint)
- : channel_endpoint_(channel_endpoint),
- is_running_(false),
- is_peer_open_(true) {
-}
-
-ProxyMessagePipeEndpoint::ProxyMessagePipeEndpoint(
- ChannelEndpoint* channel_endpoint,
- bool is_peer_open)
- : channel_endpoint_(channel_endpoint),
- is_running_(false),
- is_peer_open_(is_peer_open) {
+ : channel_endpoint_(channel_endpoint) {
}
ProxyMessagePipeEndpoint::~ProxyMessagePipeEndpoint() {
- DCHECK(!is_running());
DCHECK(!is_attached());
}
@@ -39,19 +28,8 @@ MessagePipeEndpoint::Type ProxyMessagePipeEndpoint::GetType() const {
}
bool ProxyMessagePipeEndpoint::OnPeerClose() {
- DCHECK(is_peer_open_);
-
- is_peer_open_ = false;
-
- if (is_attached()) {
- if (!is_running()) {
- // If we're not running yet, we can't be destroyed yet, because we're
- // still waiting for the "run" message from the other side.
- return true;
- }
-
+ if (is_attached())
Detach();
- }
return false;
}
@@ -66,21 +44,6 @@ void ProxyMessagePipeEndpoint::EnqueueMessage(
<< "Failed to write enqueue message to channel";
}
-bool ProxyMessagePipeEndpoint::Run() {
- // Assertions about current state:
- DCHECK(is_attached());
- DCHECK(!is_running());
-
- is_running_ = true;
-
- if (is_peer_open_)
- return true; // Stay alive.
-
- // We were just waiting to die.
- Detach();
- return false;
-}
-
void ProxyMessagePipeEndpoint::OnRemove() {
Detach();
}
@@ -90,7 +53,6 @@ void ProxyMessagePipeEndpoint::Detach() {
channel_endpoint_->DetachFromMessagePipe();
channel_endpoint_ = nullptr;
- is_running_ = false;
}
} // namespace system
diff --git a/mojo/system/proxy_message_pipe_endpoint.h b/mojo/system/proxy_message_pipe_endpoint.h
index 04723a2..d015054 100644
--- a/mojo/system/proxy_message_pipe_endpoint.h
+++ b/mojo/system/proxy_message_pipe_endpoint.h
@@ -37,36 +37,23 @@ class MOJO_SYSTEM_IMPL_EXPORT ProxyMessagePipeEndpoint
: public MessagePipeEndpoint {
public:
explicit ProxyMessagePipeEndpoint(ChannelEndpoint* channel_endpoint);
- // Constructs a |ProxyMessagePipeEndpoint|, whose peer may already be closed.
- // This is used to construct one to replace a |LocalMessagePipeEndpoint|, when
- // transferring a message pipe handle over a remote message pipe.
- ProxyMessagePipeEndpoint(
- ChannelEndpoint* channel_endpoint,
- bool is_peer_open);
virtual ~ProxyMessagePipeEndpoint();
// |MessagePipeEndpoint| implementation:
virtual Type GetType() const OVERRIDE;
virtual bool OnPeerClose() OVERRIDE;
virtual void EnqueueMessage(scoped_ptr<MessageInTransit> message) OVERRIDE;
- virtual bool Run() OVERRIDE;
virtual void OnRemove() OVERRIDE;
private:
void Detach();
- // TODO(vtl): Get rid of these.
+ // TODO(vtl): Get rid of this.
bool is_attached() const { return !!channel_endpoint_.get(); }
- bool is_running() const { return is_running_; }
// This should only be set if we're attached.
scoped_refptr<ChannelEndpoint> channel_endpoint_;
- // TODO(vtl): Get rid of this.
- bool is_running_;
-
- bool is_peer_open_;
-
DISALLOW_COPY_AND_ASSIGN(ProxyMessagePipeEndpoint);
};