OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "mojo/edk/system/core.h" | 5 #include "mojo/edk/system/core.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 base::AutoLock lock(handles_lock_); | 165 base::AutoLock lock(handles_lock_); |
166 return handles_.GetDispatcher(handle); | 166 return handles_.GetDispatcher(handle); |
167 } | 167 } |
168 | 168 |
169 void Core::SetDefaultProcessErrorCallback( | 169 void Core::SetDefaultProcessErrorCallback( |
170 const ProcessErrorCallback& callback) { | 170 const ProcessErrorCallback& callback) { |
171 default_process_error_callback_ = callback; | 171 default_process_error_callback_ = callback; |
172 } | 172 } |
173 | 173 |
174 void Core::AddChild(base::ProcessHandle process_handle, | 174 void Core::AddChild(base::ProcessHandle process_handle, |
175 ScopedPlatformHandle platform_handle, | 175 ConnectionParams connection_params, |
176 const std::string& child_token, | 176 const std::string& child_token, |
177 const ProcessErrorCallback& process_error_callback) { | 177 const ProcessErrorCallback& process_error_callback) { |
178 GetNodeController()->ConnectToChild(process_handle, | 178 GetNodeController()->ConnectToChild(process_handle, |
179 std::move(platform_handle), | 179 std::move(connection_params), child_token, |
180 child_token, | |
181 process_error_callback); | 180 process_error_callback); |
182 } | 181 } |
183 | 182 |
184 void Core::ChildLaunchFailed(const std::string& child_token) { | 183 void Core::ChildLaunchFailed(const std::string& child_token) { |
185 RequestContext request_context; | 184 RequestContext request_context; |
186 GetNodeController()->CloseChildPorts(child_token); | 185 GetNodeController()->CloseChildPorts(child_token); |
187 } | 186 } |
188 | 187 |
189 ScopedMessagePipeHandle Core::ConnectToPeerProcess( | 188 ScopedMessagePipeHandle Core::ConnectToPeerProcess( |
190 ScopedPlatformHandle pipe_handle, | 189 ScopedPlatformHandle pipe_handle, |
191 const std::string& peer_token) { | 190 const std::string& peer_token) { |
192 RequestContext request_context; | 191 RequestContext request_context; |
193 ports::PortRef port0, port1; | 192 ports::PortRef port0, port1; |
194 GetNodeController()->node()->CreatePortPair(&port0, &port1); | 193 GetNodeController()->node()->CreatePortPair(&port0, &port1); |
195 MojoHandle handle = AddDispatcher(new MessagePipeDispatcher( | 194 MojoHandle handle = AddDispatcher(new MessagePipeDispatcher( |
196 GetNodeController(), port0, kUnknownPipeIdForDebug, 0)); | 195 GetNodeController(), port0, kUnknownPipeIdForDebug, 0)); |
197 GetNodeController()->ConnectToPeer(std::move(pipe_handle), port1, peer_token); | 196 ConnectionParams connection_params(std::move(pipe_handle)); |
| 197 GetNodeController()->ConnectToPeer(std::move(connection_params), port1, |
| 198 peer_token); |
198 return ScopedMessagePipeHandle(MessagePipeHandle(handle)); | 199 return ScopedMessagePipeHandle(MessagePipeHandle(handle)); |
199 } | 200 } |
200 | 201 |
201 void Core::ClosePeerConnection(const std::string& peer_token) { | 202 void Core::ClosePeerConnection(const std::string& peer_token) { |
202 GetNodeController()->ClosePeerConnection(peer_token); | 203 GetNodeController()->ClosePeerConnection(peer_token); |
203 } | 204 } |
204 | 205 |
205 void Core::InitChild(ScopedPlatformHandle platform_handle) { | 206 void Core::InitChild(ConnectionParams connection_params) { |
206 GetNodeController()->ConnectToParent(std::move(platform_handle)); | 207 GetNodeController()->ConnectToParent(std::move(connection_params)); |
207 } | 208 } |
208 | 209 |
209 void Core::SetMachPortProvider(base::PortProvider* port_provider) { | 210 void Core::SetMachPortProvider(base::PortProvider* port_provider) { |
210 #if defined(OS_MACOSX) && !defined(OS_IOS) | 211 #if defined(OS_MACOSX) && !defined(OS_IOS) |
211 GetNodeController()->CreateMachPortRelay(port_provider); | 212 GetNodeController()->CreateMachPortRelay(port_provider); |
212 #endif | 213 #endif |
213 } | 214 } |
214 | 215 |
215 MojoHandle Core::AddDispatcher(scoped_refptr<Dispatcher> dispatcher) { | 216 MojoHandle Core::AddDispatcher(scoped_refptr<Dispatcher> dispatcher) { |
216 base::AutoLock lock(handles_lock_); | 217 base::AutoLock lock(handles_lock_); |
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 std::unique_ptr<NodeController> node_controller) { | 1170 std::unique_ptr<NodeController> node_controller) { |
1170 // It's OK to leak this reference. At this point we know the IO loop is still | 1171 // It's OK to leak this reference. At this point we know the IO loop is still |
1171 // running, and we know the NodeController will observe its eventual | 1172 // running, and we know the NodeController will observe its eventual |
1172 // destruction. This tells the NodeController to delete itself when that | 1173 // destruction. This tells the NodeController to delete itself when that |
1173 // happens. | 1174 // happens. |
1174 node_controller.release()->DestroyOnIOThreadShutdown(); | 1175 node_controller.release()->DestroyOnIOThreadShutdown(); |
1175 } | 1176 } |
1176 | 1177 |
1177 } // namespace edk | 1178 } // namespace edk |
1178 } // namespace mojo | 1179 } // namespace mojo |
OLD | NEW |