Index: mojo/shell/runner/host/child_process.cc |
diff --git a/mojo/shell/runner/host/child_process.cc b/mojo/shell/runner/host/child_process.cc |
index 75230f096baa7471c16d78f129fb3ed3068833eb..0208b8408c0ba77a5eccf3081020840afb388109 100644 |
--- a/mojo/shell/runner/host/child_process.cc |
+++ b/mojo/shell/runner/host/child_process.cc |
@@ -51,6 +51,10 @@ |
namespace { |
+void DidCreateChannel(embedder::ChannelInfo* channel_info) { |
+ DVLOG(2) << "ChildControllerImpl::DidCreateChannel()"; |
+} |
+ |
// Blocker --------------------------------------------------------------------- |
// Blocks a thread until another thread unblocks it, at which point it unblocks |
@@ -296,14 +300,34 @@ |
} |
#endif |
-ScopedMessagePipeHandle InitializeHostMessagePipe( |
- edk::ScopedPlatformHandle platform_channel, |
- scoped_refptr<base::TaskRunner> io_task_runner) { |
- edk::SetParentPipeHandle(std::move(platform_channel)); |
- std::string primordial_pipe_token = |
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
- switches::kPrimordialPipeToken); |
- return edk::CreateChildMessagePipe(primordial_pipe_token); |
+void InitializeHostMessagePipe( |
+ embedder::ScopedPlatformHandle platform_channel, |
+ scoped_refptr<base::TaskRunner> io_task_runner, |
+ const base::Callback<void(ScopedMessagePipeHandle)>& callback) { |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk")) { |
+ embedder::SetParentPipeHandle(std::move(platform_channel)); |
+ std::string primordial_pipe_token = |
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
+ switches::kPrimordialPipeToken); |
+ edk::CreateChildMessagePipe(primordial_pipe_token, callback); |
+ } else { |
+ ScopedMessagePipeHandle host_message_pipe; |
+ host_message_pipe = |
+ embedder::CreateChannel(std::move(platform_channel), |
+ base::Bind(&DidCreateChannel), io_task_runner); |
+ callback.Run(std::move(host_message_pipe)); |
+ } |
+} |
+ |
+void OnHostMessagePipeCreated(AppContext* app_context, |
+ base::NativeLibrary app_library, |
+ const Blocker::Unblocker& unblocker, |
+ ScopedMessagePipeHandle pipe) { |
+ app_context->controller_runner()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&ChildControllerImpl::Init, base::Unretained(app_context), |
+ base::Unretained(app_library), base::Passed(&pipe), |
+ unblocker)); |
} |
} // namespace |
@@ -336,8 +360,8 @@ |
sandbox = InitializeSandbox(); |
#endif |
- edk::ScopedPlatformHandle platform_channel = |
- edk::PlatformChannelPair::PassClientHandleFromParentProcess( |
+ embedder::ScopedPlatformHandle platform_channel = |
+ embedder::PlatformChannelPair::PassClientHandleFromParentProcess( |
command_line); |
CHECK(platform_channel.is_valid()); |
@@ -348,12 +372,13 @@ |
app_context.Init(); |
app_context.StartControllerThread(); |
- ScopedMessagePipeHandle host_pipe = InitializeHostMessagePipe( |
- std::move(platform_channel), app_context.io_runner()); |
app_context.controller_runner()->PostTask( |
FROM_HERE, |
- base::Bind(&ChildControllerImpl::Init, &app_context, app_library, |
- base::Passed(&host_pipe), blocker.GetUnblocker())); |
+ base::Bind( |
+ &InitializeHostMessagePipe, base::Passed(&platform_channel), |
+ make_scoped_refptr(app_context.io_runner()), |
+ base::Bind(&OnHostMessagePipeCreated, base::Unretained(&app_context), |
+ base::Unretained(app_library), blocker.GetUnblocker()))); |
// This will block, then run whatever the controller wants. |
blocker.Block(); |