| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 node_controller_.reset(new NodeController(this)); | 162 node_controller_.reset(new NodeController(this)); |
| 163 return node_controller_.get(); | 163 return node_controller_.get(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) { | 166 scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) { |
| 167 base::AutoLock lock(handles_lock_); | 167 base::AutoLock lock(handles_lock_); |
| 168 return handles_.GetDispatcher(handle); | 168 return handles_.GetDispatcher(handle); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void Core::AddChild(base::ProcessHandle process_handle, | 171 void Core::AddChild(base::ProcessHandle process_handle, |
| 172 ScopedPlatformHandle platform_handle) { | 172 ScopedPlatformHandle platform_handle, |
| 173 const std::string& child_token) { |
| 173 GetNodeController()->ConnectToChild(process_handle, | 174 GetNodeController()->ConnectToChild(process_handle, |
| 174 std::move(platform_handle)); | 175 std::move(platform_handle), |
| 176 child_token); |
| 177 } |
| 178 |
| 179 void Core::ChildLaunchFailed(const std::string& child_token) { |
| 180 RequestContext request_context; |
| 181 GetNodeController()->CloseChildPorts(child_token); |
| 175 } | 182 } |
| 176 | 183 |
| 177 void Core::InitChild(ScopedPlatformHandle platform_handle) { | 184 void Core::InitChild(ScopedPlatformHandle platform_handle) { |
| 178 GetNodeController()->ConnectToParent(std::move(platform_handle)); | 185 GetNodeController()->ConnectToParent(std::move(platform_handle)); |
| 179 } | 186 } |
| 180 | 187 |
| 181 void Core::SetMachPortProvider(base::PortProvider* port_provider) { | 188 void Core::SetMachPortProvider(base::PortProvider* port_provider) { |
| 182 #if defined(OS_MACOSX) && !defined(OS_IOS) | 189 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 183 GetNodeController()->CreateMachPortRelay(port_provider); | 190 GetNodeController()->CreateMachPortRelay(port_provider); |
| 184 #endif | 191 #endif |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 GetNodeController()->node()->CreatePortPair(&port0, &port1); | 327 GetNodeController()->node()->CreatePortPair(&port0, &port1); |
| 321 MojoHandle handle = AddDispatcher( | 328 MojoHandle handle = AddDispatcher( |
| 322 new MessagePipeDispatcher(GetNodeController(), port0, | 329 new MessagePipeDispatcher(GetNodeController(), port0, |
| 323 kUnknownPipeIdForDebug, 0)); | 330 kUnknownPipeIdForDebug, 0)); |
| 324 RemoteMessagePipeBootstrap::Create( | 331 RemoteMessagePipeBootstrap::Create( |
| 325 GetNodeController(), std::move(platform_handle), port1); | 332 GetNodeController(), std::move(platform_handle), port1); |
| 326 return ScopedMessagePipeHandle(MessagePipeHandle(handle)); | 333 return ScopedMessagePipeHandle(MessagePipeHandle(handle)); |
| 327 } | 334 } |
| 328 | 335 |
| 329 ScopedMessagePipeHandle Core::CreateParentMessagePipe( | 336 ScopedMessagePipeHandle Core::CreateParentMessagePipe( |
| 330 const std::string& token) { | 337 const std::string& token, const std::string& child_token) { |
| 331 RequestContext request_context; | 338 RequestContext request_context; |
| 332 ports::PortRef port0, port1; | 339 ports::PortRef port0, port1; |
| 333 GetNodeController()->node()->CreatePortPair(&port0, &port1); | 340 GetNodeController()->node()->CreatePortPair(&port0, &port1); |
| 334 MojoHandle handle = AddDispatcher( | 341 MojoHandle handle = AddDispatcher( |
| 335 new MessagePipeDispatcher(GetNodeController(), port0, | 342 new MessagePipeDispatcher(GetNodeController(), port0, |
| 336 kUnknownPipeIdForDebug, 0)); | 343 kUnknownPipeIdForDebug, 0)); |
| 337 GetNodeController()->ReservePort(token, port1); | 344 GetNodeController()->ReservePort(token, port1, child_token); |
| 338 return ScopedMessagePipeHandle(MessagePipeHandle(handle)); | 345 return ScopedMessagePipeHandle(MessagePipeHandle(handle)); |
| 339 } | 346 } |
| 340 | 347 |
| 341 ScopedMessagePipeHandle Core::CreateChildMessagePipe(const std::string& token) { | 348 ScopedMessagePipeHandle Core::CreateChildMessagePipe(const std::string& token) { |
| 342 RequestContext request_context; | 349 RequestContext request_context; |
| 343 ports::PortRef port0, port1; | 350 ports::PortRef port0, port1; |
| 344 GetNodeController()->node()->CreatePortPair(&port0, &port1); | 351 GetNodeController()->node()->CreatePortPair(&port0, &port1); |
| 345 MojoHandle handle = AddDispatcher( | 352 MojoHandle handle = AddDispatcher( |
| 346 new MessagePipeDispatcher(GetNodeController(), port0, | 353 new MessagePipeDispatcher(GetNodeController(), port0, |
| 347 kUnknownPipeIdForDebug, 1)); | 354 kUnknownPipeIdForDebug, 1)); |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 std::unique_ptr<NodeController> node_controller) { | 1140 std::unique_ptr<NodeController> node_controller) { |
| 1134 // It's OK to leak this reference. At this point we know the IO loop is still | 1141 // It's OK to leak this reference. At this point we know the IO loop is still |
| 1135 // running, and we know the NodeController will observe its eventual | 1142 // running, and we know the NodeController will observe its eventual |
| 1136 // destruction. This tells the NodeController to delete itself when that | 1143 // destruction. This tells the NodeController to delete itself when that |
| 1137 // happens. | 1144 // happens. |
| 1138 node_controller.release()->DestroyOnIOThreadShutdown(); | 1145 node_controller.release()->DestroyOnIOThreadShutdown(); |
| 1139 } | 1146 } |
| 1140 | 1147 |
| 1141 } // namespace edk | 1148 } // namespace edk |
| 1142 } // namespace mojo | 1149 } // namespace mojo |
| OLD | NEW |