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_CHANNEL_H_ | 5 #ifndef MOJO_EDK_SYSTEM_NODE_CHANNEL_H_ |
6 #define MOJO_EDK_SYSTEM_NODE_CHANNEL_H_ | 6 #define MOJO_EDK_SYSTEM_NODE_CHANNEL_H_ |
7 | 7 |
8 #include <unordered_map> | 8 #include <unordered_map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 public: | 29 public: |
30 virtual ~Delegate() {} | 30 virtual ~Delegate() {} |
31 virtual void OnAcceptChild(const ports::NodeName& from_node, | 31 virtual void OnAcceptChild(const ports::NodeName& from_node, |
32 const ports::NodeName& parent_name, | 32 const ports::NodeName& parent_name, |
33 const ports::NodeName& token) = 0; | 33 const ports::NodeName& token) = 0; |
34 virtual void OnAcceptParent(const ports::NodeName& from_node, | 34 virtual void OnAcceptParent(const ports::NodeName& from_node, |
35 const ports::NodeName& token, | 35 const ports::NodeName& token, |
36 const ports::NodeName& child_name) = 0; | 36 const ports::NodeName& child_name) = 0; |
37 virtual void OnAddBrokerClient(const ports::NodeName& from_node, | 37 virtual void OnAddBrokerClient(const ports::NodeName& from_node, |
38 const ports::NodeName& client_name, | 38 const ports::NodeName& client_name, |
39 ScopedPlatformHandle process_handle) = 0; | 39 base::ProcessHandle process_handle) = 0; |
40 virtual void OnBrokerClientAdded(const ports::NodeName& from_node, | 40 virtual void OnBrokerClientAdded(const ports::NodeName& from_node, |
41 const ports::NodeName& client_name, | 41 const ports::NodeName& client_name, |
42 ScopedPlatformHandle broker_channel) = 0; | 42 ScopedPlatformHandle broker_channel) = 0; |
43 virtual void OnAcceptBrokerClient(const ports::NodeName& from_node, | 43 virtual void OnAcceptBrokerClient(const ports::NodeName& from_node, |
44 const ports::NodeName& broker_name, | 44 const ports::NodeName& broker_name, |
45 ScopedPlatformHandle broker_channel) = 0; | 45 ScopedPlatformHandle broker_channel) = 0; |
46 virtual void OnPortsMessage(Channel::MessagePtr message) = 0; | 46 virtual void OnPortsMessage(Channel::MessagePtr message) = 0; |
47 virtual void OnRequestPortMerge(const ports::NodeName& from_node, | 47 virtual void OnRequestPortMerge(const ports::NodeName& from_node, |
48 const ports::PortName& connector_port_name, | 48 const ports::PortName& connector_port_name, |
49 const std::string& token) = 0; | 49 const std::string& token) = 0; |
(...skipping 25 matching lines...) Expand all Loading... |
75 size_t* num_data_bytes); | 75 size_t* num_data_bytes); |
76 | 76 |
77 // Start receiving messages. | 77 // Start receiving messages. |
78 void Start(); | 78 void Start(); |
79 | 79 |
80 // Permanently stop the channel from sending or receiving messages. | 80 // Permanently stop the channel from sending or receiving messages. |
81 void ShutDown(); | 81 void ShutDown(); |
82 | 82 |
83 void SetRemoteProcessHandle(base::ProcessHandle process_handle); | 83 void SetRemoteProcessHandle(base::ProcessHandle process_handle); |
84 bool HasRemoteProcessHandle(); | 84 bool HasRemoteProcessHandle(); |
85 ScopedPlatformHandle CopyRemoteProcessHandle(); | 85 // Note: The returned |ProcessHandle| is owned by the caller and should be |
| 86 // freed if necessary. |
| 87 base::ProcessHandle CopyRemoteProcessHandle(); |
86 | 88 |
87 // Used for context in Delegate calls (via |from_node| arguments.) | 89 // Used for context in Delegate calls (via |from_node| arguments.) |
88 void SetRemoteNodeName(const ports::NodeName& name); | 90 void SetRemoteNodeName(const ports::NodeName& name); |
89 | 91 |
90 void AcceptChild(const ports::NodeName& parent_name, | 92 void AcceptChild(const ports::NodeName& parent_name, |
91 const ports::NodeName& token); | 93 const ports::NodeName& token); |
92 void AcceptParent(const ports::NodeName& token, | 94 void AcceptParent(const ports::NodeName& token, |
93 const ports::NodeName& child_name); | 95 const ports::NodeName& child_name); |
94 void AddBrokerClient(const ports::NodeName& client_name, | 96 void AddBrokerClient(const ports::NodeName& client_name, |
95 ScopedPlatformHandle process_handle); | 97 base::ProcessHandle process_handle); |
96 void BrokerClientAdded(const ports::NodeName& client_name, | 98 void BrokerClientAdded(const ports::NodeName& client_name, |
97 ScopedPlatformHandle broker_channel); | 99 ScopedPlatformHandle broker_channel); |
98 void AcceptBrokerClient(const ports::NodeName& broker_name, | 100 void AcceptBrokerClient(const ports::NodeName& broker_name, |
99 ScopedPlatformHandle broker_channel); | 101 ScopedPlatformHandle broker_channel); |
100 void PortsMessage(Channel::MessagePtr message); | 102 void PortsMessage(Channel::MessagePtr message); |
101 void RequestPortMerge(const ports::PortName& connector_port_name, | 103 void RequestPortMerge(const ports::PortName& connector_port_name, |
102 const std::string& token); | 104 const std::string& token); |
103 void RequestIntroduction(const ports::NodeName& name); | 105 void RequestIntroduction(const ports::NodeName& name); |
104 void Introduce(const ports::NodeName& name, | 106 void Introduce(const ports::NodeName& name, |
105 ScopedPlatformHandle channel_handle); | 107 ScopedPlatformHandle channel_handle); |
(...skipping 25 matching lines...) Expand all Loading... |
131 | 133 |
132 Delegate* const delegate_; | 134 Delegate* const delegate_; |
133 const scoped_refptr<base::TaskRunner> io_task_runner_; | 135 const scoped_refptr<base::TaskRunner> io_task_runner_; |
134 | 136 |
135 base::Lock channel_lock_; | 137 base::Lock channel_lock_; |
136 scoped_refptr<Channel> channel_; | 138 scoped_refptr<Channel> channel_; |
137 | 139 |
138 // Must only be accessed from |io_task_runner_|'s thread. | 140 // Must only be accessed from |io_task_runner_|'s thread. |
139 ports::NodeName remote_node_name_; | 141 ports::NodeName remote_node_name_; |
140 | 142 |
141 #if defined(OS_WIN) | |
142 base::Lock remote_process_handle_lock_; | 143 base::Lock remote_process_handle_lock_; |
143 base::ProcessHandle remote_process_handle_ = base::kNullProcessHandle; | 144 base::ProcessHandle remote_process_handle_ = base::kNullProcessHandle; |
144 #endif | |
145 | 145 |
146 DISALLOW_COPY_AND_ASSIGN(NodeChannel); | 146 DISALLOW_COPY_AND_ASSIGN(NodeChannel); |
147 }; | 147 }; |
148 | 148 |
149 } // namespace edk | 149 } // namespace edk |
150 } // namespace mojo | 150 } // namespace mojo |
151 | 151 |
152 #endif // MOJO_EDK_SYSTEM_NODE_CHANNEL_H_ | 152 #endif // MOJO_EDK_SYSTEM_NODE_CHANNEL_H_ |
OLD | NEW |