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

Unified Diff: mojo/system/message_pipe.cc

Issue 588193004: Mojo: Have |ProxyMessagePipeEndpoint|s constructed with 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/message_pipe.h ('k') | mojo/system/message_pipe_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/message_pipe.cc
diff --git a/mojo/system/message_pipe.cc b/mojo/system/message_pipe.cc
index 872ed30211814250feb44878eab60bdae9329138..4a75a297bad0d936c28c732f9341d00c77945ed6 100644
--- a/mojo/system/message_pipe.cc
+++ b/mojo/system/message_pipe.cc
@@ -15,31 +15,36 @@
namespace mojo {
namespace system {
-MessagePipe::MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0,
- scoped_ptr<MessagePipeEndpoint> endpoint1) {
- endpoints_[0].reset(endpoint0.release());
- endpoints_[1].reset(endpoint1.release());
-}
-
// static
MessagePipe* MessagePipe::CreateLocalLocal() {
- return new MessagePipe(
- scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint),
- scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint));
+ MessagePipe* message_pipe = new MessagePipe();
+ message_pipe->endpoints_[0].reset(new LocalMessagePipeEndpoint());
+ message_pipe->endpoints_[1].reset(new LocalMessagePipeEndpoint());
+ return message_pipe;
}
// static
-MessagePipe* MessagePipe::CreateLocalProxy() {
- return new MessagePipe(
- scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint),
- scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint));
+MessagePipe* MessagePipe::CreateLocalProxy(
+ scoped_refptr<ChannelEndpoint>* channel_endpoint) {
+ DCHECK(!channel_endpoint->get()); // Not technically wrong, but unlikely.
+ MessagePipe* message_pipe = new MessagePipe();
+ message_pipe->endpoints_[0].reset(new LocalMessagePipeEndpoint());
+ *channel_endpoint = new ChannelEndpoint(message_pipe, 1);
+ message_pipe->endpoints_[1].reset(
+ new ProxyMessagePipeEndpoint(channel_endpoint->get()));
+ return message_pipe;
}
// static
-MessagePipe* MessagePipe::CreateProxyLocal() {
- return new MessagePipe(
- scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint),
- scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint));
+MessagePipe* MessagePipe::CreateProxyLocal(
+ scoped_refptr<ChannelEndpoint>* channel_endpoint) {
+ DCHECK(!channel_endpoint->get()); // Not technically wrong, but unlikely.
+ MessagePipe* message_pipe = new MessagePipe();
+ *channel_endpoint = new ChannelEndpoint(message_pipe, 0);
+ message_pipe->endpoints_[0].reset(
+ new ProxyMessagePipeEndpoint(channel_endpoint->get()));
+ message_pipe->endpoints_[1].reset(new LocalMessagePipeEndpoint());
+ return message_pipe;
}
// static
@@ -165,13 +170,16 @@ scoped_refptr<ChannelEndpoint> MessagePipe::ConvertLocalToProxy(unsigned port) {
<< "Direct message pipe passing across multiple channels not yet "
"implemented; will proxy";
+ scoped_refptr<ChannelEndpoint> channel_endpoint(
+ new ChannelEndpoint(this, port));
scoped_ptr<MessagePipeEndpoint> replacement_endpoint(
new ProxyMessagePipeEndpoint(
+ channel_endpoint.get(),
static_cast<LocalMessagePipeEndpoint*>(endpoints_[port].get()),
is_peer_open));
endpoints_[port].swap(replacement_endpoint);
- return make_scoped_refptr(new ChannelEndpoint(this, port));
+ return channel_endpoint;
}
MojoResult MessagePipe::EnqueueMessage(unsigned port,
@@ -188,7 +196,6 @@ bool MessagePipe::Attach(unsigned port, ChannelEndpoint* channel_endpoint) {
return false;
DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeProxy);
- endpoints_[port]->Attach(channel_endpoint);
return true;
}
@@ -217,6 +224,9 @@ void MessagePipe::OnRemove(unsigned port) {
endpoints_[port].reset();
}
+MessagePipe::MessagePipe() {
+}
+
MessagePipe::~MessagePipe() {
// Owned by the dispatchers. The owning dispatchers should only release us via
// their |Close()| method, which should inform us of being closed via our
« no previous file with comments | « mojo/system/message_pipe.h ('k') | mojo/system/message_pipe_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698