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

Unified Diff: mojo/edk/system/node_controller.h

Issue 2019973002: [mojo-edk] Bind a child token to child launches and port reservations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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/edk/system/core.cc ('k') | mojo/edk/system/node_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ef10d711875e079b941207832023d860f9659228 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,
@@ -121,8 +128,14 @@ class NodeController : public ports::NodeDelegate,
scoped_refptr<NodeChannel>>;
using OutgoingMessageQueue = std::queue<Channel::MessagePtr>;
+ struct ReservedPort {
+ ports::PortRef port;
+ const std::string child_token;
+ };
+
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 +222,14 @@ 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.
- base::hash_map<std::string, ports::PortRef> reserved_ports_;
+ // Ports reserved by token. Key is the port token.
+ base::hash_map<std::string, ReservedPort> 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_;
« no previous file with comments | « mojo/edk/system/core.cc ('k') | mojo/edk/system/node_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698