| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_ |
| 6 #define MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_ | 6 #define MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // Create the relay used to transfer mach ports between processes. | 66 // Create the relay used to transfer mach ports between processes. |
| 67 void CreateMachPortRelay(base::PortProvider* port_provider); | 67 void CreateMachPortRelay(base::PortProvider* port_provider); |
| 68 #endif | 68 #endif |
| 69 | 69 |
| 70 // Called exactly once, shortly after construction, and before any other | 70 // Called exactly once, shortly after construction, and before any other |
| 71 // methods are called on this object. | 71 // methods are called on this object. |
| 72 void SetIOTaskRunner(scoped_refptr<base::TaskRunner> io_task_runner); | 72 void SetIOTaskRunner(scoped_refptr<base::TaskRunner> io_task_runner); |
| 73 | 73 |
| 74 // Connects this node to a child node. This node will initiate a handshake. | 74 // Connects this node to a child node. This node will initiate a handshake. |
| 75 void ConnectToChild(base::ProcessHandle process_handle, | 75 void ConnectToChild(base::ProcessHandle process_handle, |
| 76 ScopedPlatformHandle platform_handle, | 76 ConnectionParam connection_param, |
| 77 const std::string& child_token, | 77 const std::string& child_token, |
| 78 const ProcessErrorCallback& process_error_callback); | 78 const ProcessErrorCallback& process_error_callback); |
| 79 | 79 |
| 80 // Closes all reserved ports which associated with the child process | 80 // Closes all reserved ports which associated with the child process |
| 81 // |child_token|. | 81 // |child_token|. |
| 82 void CloseChildPorts(const std::string& child_token); | 82 void CloseChildPorts(const std::string& child_token); |
| 83 | 83 |
| 84 // Close a connection to a peer associated with |peer_token|. | 84 // Close a connection to a peer associated with |peer_token|. |
| 85 void ClosePeerConnection(const std::string& peer_token); | 85 void ClosePeerConnection(const std::string& peer_token); |
| 86 | 86 |
| 87 // Connects this node to a parent node. The parent node will initiate a | 87 // Connects this node to a parent node. The parent node will initiate a |
| 88 // handshake. | 88 // handshake. |
| 89 void ConnectToParent(ScopedPlatformHandle platform_handle); | 89 void ConnectToParent(ConnectionParam connection_param); |
| 90 | 90 |
| 91 // Connects this node to a peer node. On success, |port| will be merged with | 91 // Connects this node to a peer node. On success, |port| will be merged with |
| 92 // the corresponding port in the peer node. | 92 // the corresponding port in the peer node. |
| 93 void ConnectToPeer(ScopedPlatformHandle handle, | 93 void ConnectToPeer(ConnectionParam connection_param, |
| 94 const ports::PortRef& port, | 94 const ports::PortRef& port, |
| 95 const std::string& peer_token); | 95 const std::string& peer_token); |
| 96 | 96 |
| 97 // Sets a port's observer. If |observer| is null the port's current observer | 97 // Sets a port's observer. If |observer| is null the port's current observer |
| 98 // is removed. | 98 // is removed. |
| 99 void SetPortObserver(const ports::PortRef& port, | 99 void SetPortObserver(const ports::PortRef& port, |
| 100 scoped_refptr<PortObserver> observer); | 100 scoped_refptr<PortObserver> observer); |
| 101 | 101 |
| 102 // Closes a port. Use this in lieu of calling Node::ClosePort() directly, as | 102 // Closes a port. Use this in lieu of calling Node::ClosePort() directly, as |
| 103 // it ensures the port's observer has also been removed. | 103 // it ensures the port's observer has also been removed. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 PeerConnection& operator=(PeerConnection&& other); | 161 PeerConnection& operator=(PeerConnection&& other); |
| 162 | 162 |
| 163 | 163 |
| 164 scoped_refptr<NodeChannel> channel; | 164 scoped_refptr<NodeChannel> channel; |
| 165 ports::PortRef local_port; | 165 ports::PortRef local_port; |
| 166 std::string peer_token; | 166 std::string peer_token; |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 void ConnectToChildOnIOThread( | 169 void ConnectToChildOnIOThread( |
| 170 base::ProcessHandle process_handle, | 170 base::ProcessHandle process_handle, |
| 171 ScopedPlatformHandle platform_handle, | 171 ConnectionParam connection_param, |
| 172 ports::NodeName token, | 172 ports::NodeName token, |
| 173 const ProcessErrorCallback& process_error_callback); | 173 const ProcessErrorCallback& process_error_callback); |
| 174 void ConnectToParentOnIOThread(ScopedPlatformHandle platform_handle); | 174 void ConnectToParentOnIOThread(ConnectionParam connection_param); |
| 175 | 175 |
| 176 void ConnectToPeerOnIOThread(ScopedPlatformHandle handle, | 176 void ConnectToPeerOnIOThread(ConnectionParam connection_param, |
| 177 ports::NodeName token, | 177 ports::NodeName token, |
| 178 ports::PortRef port, | 178 ports::PortRef port, |
| 179 const std::string& peer_token); | 179 const std::string& peer_token); |
| 180 void ClosePeerConnectionOnIOThread(const std::string& node_name); | 180 void ClosePeerConnectionOnIOThread(const std::string& node_name); |
| 181 | 181 |
| 182 scoped_refptr<NodeChannel> GetPeerChannel(const ports::NodeName& name); | 182 scoped_refptr<NodeChannel> GetPeerChannel(const ports::NodeName& name); |
| 183 scoped_refptr<NodeChannel> GetParentChannel(); | 183 scoped_refptr<NodeChannel> GetParentChannel(); |
| 184 scoped_refptr<NodeChannel> GetBrokerChannel(); | 184 scoped_refptr<NodeChannel> GetBrokerChannel(); |
| 185 | 185 |
| 186 void AddPeer(const ports::NodeName& name, | 186 void AddPeer(const ports::NodeName& name, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 std::unique_ptr<MachPortRelay> mach_port_relay_; | 369 std::unique_ptr<MachPortRelay> mach_port_relay_; |
| 370 #endif | 370 #endif |
| 371 | 371 |
| 372 DISALLOW_COPY_AND_ASSIGN(NodeController); | 372 DISALLOW_COPY_AND_ASSIGN(NodeController); |
| 373 }; | 373 }; |
| 374 | 374 |
| 375 } // namespace edk | 375 } // namespace edk |
| 376 } // namespace mojo | 376 } // namespace mojo |
| 377 | 377 |
| 378 #endif // MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_ | 378 #endif // MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_ |
| OLD | NEW |