Index: mojo/edk/system/channel.h |
diff --git a/mojo/edk/system/channel.h b/mojo/edk/system/channel.h |
index 57bd9ce661eb966809675d782528b7a6aed26441..c09f4c0117270cc37eb3780af8a9f14269dde1c2 100644 |
--- a/mojo/edk/system/channel.h |
+++ b/mojo/edk/system/channel.h |
@@ -80,24 +80,22 @@ class MOJO_SYSTEM_IMPL_EXPORT Channel |
// Attaches the given endpoint to this channel and runs it. |is_bootstrap| |
// should be set if and only if it is the first endpoint on the channel. This |
// assigns the endpoint both local and remote IDs. If |is_bootstrap| is set, |
- // both are the bootstrap ID (given by |ChannelEndpointId::GetBootstrap()|). |
+ // both are the bootstrap ID (given by |ChannelEndpointId::GetBootstrap()|); |
+ // if not, it will also send a |kSubtypeChannelAttachAndRunEndpoint| message |
+ // to the remote side to tell it to create an endpoint as well. |
// |
// (Bootstrapping is symmetric: Both sides attach and run endpoints with |
// |is_bootstrap| set, which establishes the first message pipe across a |
// channel.) |
// |
+ // This returns the *remote* ID (which will be the bootstrap ID in the |
+ // bootstrap case, and a "remote ID", i.e., one for which |is_remote()| |
+ // returns true, otherwise). |
+ // |
// TODO(vtl): Maybe limit the number of attached message pipes. |
- void AttachAndRunEndpoint(scoped_refptr<ChannelEndpoint> endpoint, |
- bool is_bootstrap); |
- |
- // Tells the other side of the channel to run a message pipe endpoint (which |
- // must already be attached); |local_id| and |remote_id| are relative to this |
- // channel (i.e., |local_id| is the other side's remote ID and |remote_id| is |
- // its local ID). |
- // TODO(vtl): Maybe we should just have a flag argument to |
- // |RunMessagePipeEndpoint()| that tells it to do this. |
- void RunRemoteMessagePipeEndpoint(ChannelEndpointId local_id, |
- ChannelEndpointId remote_id); |
+ ChannelEndpointId AttachAndRunEndpoint( |
+ scoped_refptr<ChannelEndpoint> endpoint, |
+ bool is_bootstrap); |
// This forwards |message| verbatim to |raw_channel_|. |
bool WriteMessage(scoped_ptr<MessageInTransit> message); |
@@ -107,15 +105,20 @@ class MOJO_SYSTEM_IMPL_EXPORT Channel |
// |FlushWriteBufferAndShutdown()| or something like that. |
bool IsWriteBufferEmpty(); |
- // This removes the given endpoint from this channel (|local_id| and |
- // |remote_id| are specified as an optimization; the latter should be an |
- // invalid |ChannelEndpointId| if the endpoint is not yet running). Note: If |
- // this is called, the |Channel| will *not* call |
+ // Removes the given endpoint from this channel (|local_id| and |remote_id| |
+ // are specified as an optimization; the latter should be an invalid |
+ // |ChannelEndpointId| if the endpoint is not yet running). Note: If this is |
+ // called, the |Channel| will *not* call |
// |ChannelEndpoint::DetachFromChannel()|. |
void DetachEndpoint(ChannelEndpoint* endpoint, |
ChannelEndpointId local_id, |
ChannelEndpointId remote_id); |
+ // Takes ownership of an incoming message pipe (i.e., one that was created via |
+ // a |kSubtypeChannelAttachAndRunEndpoint| message). |
+ scoped_refptr<MessagePipe> PassIncomingMessagePipe( |
+ ChannelEndpointId local_id); |
+ |
// See |RawChannel::GetSerializedPlatformHandleSize()|. |
size_t GetSerializedPlatformHandleSize() const; |
@@ -141,9 +144,9 @@ class MOJO_SYSTEM_IMPL_EXPORT Channel |
const MessageInTransit::View& message_view, |
embedder::ScopedPlatformHandleVectorPtr platform_handles); |
- // Handles "run message pipe endpoint" messages. |
- bool OnRunMessagePipeEndpoint(ChannelEndpointId local_id, |
- ChannelEndpointId remote_id); |
+ // Handles "attach and run endpoint" messages. |
+ bool OnAttachAndRunEndpoint(ChannelEndpointId local_id, |
+ ChannelEndpointId remote_id); |
// Handles "remove message pipe endpoint" messages. |
bool OnRemoveMessagePipeEndpoint(ChannelEndpointId local_id, |
ChannelEndpointId remote_id); |
@@ -186,6 +189,11 @@ class MOJO_SYSTEM_IMPL_EXPORT Channel |
// Note: The IDs generated by this should be checked for existence before use. |
LocalChannelEndpointIdGenerator local_id_generator_; |
+ typedef base::hash_map<ChannelEndpointId, scoped_refptr<MessagePipe>> |
+ IdToMessagePipeMap; |
+ // Map from local IDs to pending/incoming endpoints (i.e., those which do not |
+ // yet have a dispatcher attached). |
+ IdToMessagePipeMap incoming_message_pipes_; |
// TODO(vtl): We need to keep track of remote IDs (so that we don't collide |
// if/when we wrap). |
RemoteChannelEndpointIdGenerator remote_id_generator_; |