| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 const ProcessErrorCallback& process_error_callback); | 146 const ProcessErrorCallback& process_error_callback); |
| 147 void ConnectToParentOnIOThread(ScopedPlatformHandle platform_handle); | 147 void ConnectToParentOnIOThread(ScopedPlatformHandle platform_handle); |
| 148 | 148 |
| 149 scoped_refptr<NodeChannel> GetPeerChannel(const ports::NodeName& name); | 149 scoped_refptr<NodeChannel> GetPeerChannel(const ports::NodeName& name); |
| 150 scoped_refptr<NodeChannel> GetParentChannel(); | 150 scoped_refptr<NodeChannel> GetParentChannel(); |
| 151 scoped_refptr<NodeChannel> GetBrokerChannel(); | 151 scoped_refptr<NodeChannel> GetBrokerChannel(); |
| 152 | 152 |
| 153 void AddPeer(const ports::NodeName& name, | 153 void AddPeer(const ports::NodeName& name, |
| 154 scoped_refptr<NodeChannel> channel, | 154 scoped_refptr<NodeChannel> channel, |
| 155 bool start_channel); | 155 bool start_channel); |
| 156 void DropPeer(const ports::NodeName& name); | 156 void DropPeer(const ports::NodeName& name, NodeChannel* channel); |
| 157 void SendPeerMessage(const ports::NodeName& name, | 157 void SendPeerMessage(const ports::NodeName& name, |
| 158 ports::ScopedMessage message); | 158 ports::ScopedMessage message); |
| 159 void AcceptIncomingMessages(); | 159 void AcceptIncomingMessages(); |
| 160 void ProcessIncomingMessages(); | 160 void ProcessIncomingMessages(); |
| 161 void DropAllPeers(); | 161 void DropAllPeers(); |
| 162 | 162 |
| 163 // ports::NodeDelegate: | 163 // ports::NodeDelegate: |
| 164 void GenerateRandomPortName(ports::PortName* port_name) override; | 164 void GenerateRandomPortName(ports::PortName* port_name) override; |
| 165 void AllocMessage(size_t num_header_bytes, | 165 void AllocMessage(size_t num_header_bytes, |
| 166 ports::ScopedMessage* message) override; | 166 ports::ScopedMessage* message) override; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 Channel::MessagePtr message) override; | 199 Channel::MessagePtr message) override; |
| 200 #if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS)) | 200 #if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS)) |
| 201 void OnRelayPortsMessage(const ports::NodeName& from_node, | 201 void OnRelayPortsMessage(const ports::NodeName& from_node, |
| 202 base::ProcessHandle from_process, | 202 base::ProcessHandle from_process, |
| 203 const ports::NodeName& destination, | 203 const ports::NodeName& destination, |
| 204 Channel::MessagePtr message) override; | 204 Channel::MessagePtr message) override; |
| 205 void OnPortsMessageFromRelay(const ports::NodeName& from_node, | 205 void OnPortsMessageFromRelay(const ports::NodeName& from_node, |
| 206 const ports::NodeName& source_node, | 206 const ports::NodeName& source_node, |
| 207 Channel::MessagePtr message) override; | 207 Channel::MessagePtr message) override; |
| 208 #endif | 208 #endif |
| 209 void OnChannelError(const ports::NodeName& from_node) override; | 209 void OnChannelError(const ports::NodeName& from_node, |
| 210 NodeChannel* channel) override; |
| 210 #if defined(OS_MACOSX) && !defined(OS_IOS) | 211 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 211 MachPortRelay* GetMachPortRelay() override; | 212 MachPortRelay* GetMachPortRelay() override; |
| 212 #endif | 213 #endif |
| 213 | 214 |
| 214 // Marks this NodeController for destruction when the IO thread shuts down. | 215 // Marks this NodeController for destruction when the IO thread shuts down. |
| 215 // This is used in case Core is torn down before the IO thread. Must only be | 216 // This is used in case Core is torn down before the IO thread. Must only be |
| 216 // called on the IO thread. | 217 // called on the IO thread. |
| 217 void DestroyOnIOThreadShutdown(); | 218 void DestroyOnIOThreadShutdown(); |
| 218 | 219 |
| 219 // If there is a registered shutdown callback (meaning shutdown has been | 220 // If there is a registered shutdown callback (meaning shutdown has been |
| (...skipping 19 matching lines...) Expand all Loading... |
| 239 | 240 |
| 240 // Guards |reserved_ports_| and |pending_child_tokens_|. | 241 // Guards |reserved_ports_| and |pending_child_tokens_|. |
| 241 base::Lock reserved_ports_lock_; | 242 base::Lock reserved_ports_lock_; |
| 242 | 243 |
| 243 // Ports reserved by token. Key is the port token. | 244 // Ports reserved by token. Key is the port token. |
| 244 base::hash_map<std::string, ReservedPort> reserved_ports_; | 245 base::hash_map<std::string, ReservedPort> reserved_ports_; |
| 245 // TODO(amistry): This _really_ needs to be a bimap. Unfortunately, we don't | 246 // TODO(amistry): This _really_ needs to be a bimap. Unfortunately, we don't |
| 246 // have one yet :( | 247 // have one yet :( |
| 247 std::unordered_map<ports::NodeName, std::string> pending_child_tokens_; | 248 std::unordered_map<ports::NodeName, std::string> pending_child_tokens_; |
| 248 | 249 |
| 249 // Guards |pending_port_merges_|. | 250 // Guards |pending_port_merges_| and |reject_pending_merges_|. |
| 250 base::Lock pending_port_merges_lock_; | 251 base::Lock pending_port_merges_lock_; |
| 251 | 252 |
| 252 // A set of port merge requests awaiting parent connection. | 253 // A set of port merge requests awaiting parent connection. |
| 253 std::vector<std::pair<std::string, ports::PortRef>> pending_port_merges_; | 254 std::vector<std::pair<std::string, ports::PortRef>> pending_port_merges_; |
| 254 | 255 |
| 256 // Indicates that new merge requests should be rejected because the parent has |
| 257 // disconnected. |
| 258 bool reject_pending_merges_ = false; |
| 259 |
| 255 // Guards |parent_name_| and |bootstrap_parent_channel_|. | 260 // Guards |parent_name_| and |bootstrap_parent_channel_|. |
| 256 base::Lock parent_lock_; | 261 base::Lock parent_lock_; |
| 257 | 262 |
| 258 // The name of our parent node, if any. | 263 // The name of our parent node, if any. |
| 259 ports::NodeName parent_name_; | 264 ports::NodeName parent_name_; |
| 260 | 265 |
| 261 // A temporary reference to the parent channel before we know their name. | 266 // A temporary reference to the parent channel before we know their name. |
| 262 scoped_refptr<NodeChannel> bootstrap_parent_channel_; | 267 scoped_refptr<NodeChannel> bootstrap_parent_channel_; |
| 263 | 268 |
| 264 // Guards |broker_name_|, |pending_broker_clients_|, and | 269 // Guards |broker_name_|, |pending_broker_clients_|, and |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 std::unique_ptr<MachPortRelay> mach_port_relay_; | 317 std::unique_ptr<MachPortRelay> mach_port_relay_; |
| 313 #endif | 318 #endif |
| 314 | 319 |
| 315 DISALLOW_COPY_AND_ASSIGN(NodeController); | 320 DISALLOW_COPY_AND_ASSIGN(NodeController); |
| 316 }; | 321 }; |
| 317 | 322 |
| 318 } // namespace edk | 323 } // namespace edk |
| 319 } // namespace mojo | 324 } // namespace mojo |
| 320 | 325 |
| 321 #endif // MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_ | 326 #endif // MOJO_EDK_SYSTEM_NODE_CONTROLLER_H_ |
| OLD | NEW |