Chromium Code Reviews| Index: mojo/edk/system/node_controller.h |
| diff --git a/mojo/edk/system/node_controller.h b/mojo/edk/system/node_controller.h |
| index 815690cd420e8cdfd81f406c449f3de052767a5a..da87f466c3b24e368a8048612fce191edb2eddf9 100644 |
| --- a/mojo/edk/system/node_controller.h |
| +++ b/mojo/edk/system/node_controller.h |
| @@ -9,6 +9,7 @@ |
| #include <queue> |
| #include <unordered_map> |
| #include <unordered_set> |
| +#include <utility> |
| #include <vector> |
| #include "base/callback.h" |
| @@ -72,7 +73,12 @@ class NodeController : public ports::NodeDelegate, |
| // Connects this node to a child node. This node will initiate a handshake. |
| void ConnectToChild(base::ProcessHandle process_handle, |
| - ScopedPlatformHandle platform_handle); |
| + ScopedPlatformHandle platform_handle, |
| + const std::string& child_token); |
| + |
| + // Closes all reserved ports which associated with the child process |
| + // |child_token|. |
| + void CloseChildPorts(const std::string& child_token); |
| // Connects this node to a parent node. The parent node will initiate a |
| // handshake. |
| @@ -93,7 +99,8 @@ class NodeController : public ports::NodeDelegate, |
| // Reserves a local port |port| associated with |token|. A peer holding a copy |
| // of |token| can merge one of its own ports into this one. |
| - void ReservePort(const std::string& token, const ports::PortRef& port); |
| + void ReservePort(const std::string& token, const ports::PortRef& port, |
| + const std::string& child_token); |
| // Merges a local port |port| into a port reserved by |token| in the parent. |
| void MergePortIntoParent(const std::string& token, |
| @@ -122,7 +129,8 @@ class NodeController : public ports::NodeDelegate, |
| using OutgoingMessageQueue = std::queue<Channel::MessagePtr>; |
| void ConnectToChildOnIOThread(base::ProcessHandle process_handle, |
| - ScopedPlatformHandle platform_handle); |
| + ScopedPlatformHandle platform_handle, |
| + ports::NodeName token); |
| void ConnectToParentOnIOThread(ScopedPlatformHandle platform_handle); |
| scoped_refptr<NodeChannel> GetPeerChannel(const ports::NodeName& name); |
| @@ -209,11 +217,15 @@ class NodeController : public ports::NodeDelegate, |
| std::unordered_map<ports::NodeName, OutgoingMessageQueue> |
| pending_peer_messages_; |
| - // Guards |reserved_ports_|. |
| + // Guards |reserved_ports_| and |pending_child_tokens_|. |
| base::Lock reserved_ports_lock_; |
| // Ports reserved by token. |
|
ncarter (slow)
2016/06/02 17:43:28
Seems like there are two flavors of token in this
Anand Mistry (off Chromium)
2016/06/03 04:39:41
Done.
|
| - base::hash_map<std::string, ports::PortRef> reserved_ports_; |
| + base::hash_map<std::string, std::pair<ports::PortRef, std::string>> |
|
ncarter (slow)
2016/06/02 17:43:28
With c++11 uniform inititalization syntax, it's re
Anand Mistry (off Chromium)
2016/06/03 04:39:40
Done.
|
| + reserved_ports_; |
| + // TODO(amistry): This _really_ needs to be a bimap. Unfortunately, we don't |
| + // have one yet :( |
| + std::unordered_map<ports::NodeName, std::string> pending_child_tokens_; |
| // Guards |pending_port_merges_|. |
| base::Lock pending_port_merges_lock_; |