Index: content/browser/mojo/mojo_application_host.cc |
diff --git a/content/browser/mojo/mojo_application_host.cc b/content/browser/mojo/mojo_application_host.cc |
index 12895d5c35336b261916132d8e37ab19838c7530..1f568efdb69eec5b4e6f7dccc3d79a1faf6ea61c 100644 |
--- a/content/browser/mojo/mojo_application_host.cc |
+++ b/content/browser/mojo/mojo_application_host.cc |
@@ -50,7 +50,7 @@ class ApplicationSetupImpl : public ApplicationSetup { |
} // namespace |
MojoApplicationHost::MojoApplicationHost() |
- : did_activate_(false) { |
+ : did_activate_(false), weak_factory_(this) { |
#if defined(OS_ANDROID) |
service_registry_android_.reset( |
new ServiceRegistryAndroid(&service_registry_)); |
@@ -74,18 +74,15 @@ bool MojoApplicationHost::Init() { |
->task_runner(); |
} |
- mojo::ScopedMessagePipeHandle message_pipe = channel_init_.Init( |
- PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()), |
- io_task_runner); |
- if (!message_pipe.is_valid()) |
- return false; |
- |
// Forward this to the client once we know its process handle. |
client_handle_ = channel_pair.PassClientHandle(); |
- application_setup_.reset(new ApplicationSetupImpl( |
- &service_registry_, |
- mojo::MakeRequest<ApplicationSetup>(std::move(message_pipe)))); |
+ channel_init_.Init( |
+ PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()), |
+ io_task_runner, |
+ base::Bind(&MojoApplicationHost::OnMessagePipeCreated, |
+ weak_factory_.GetWeakPtr())); |
+ |
return true; |
} |
@@ -109,4 +106,12 @@ void MojoApplicationHost::OverrideIOTaskRunnerForTest( |
io_task_runner_override_ = io_task_runner; |
} |
+void MojoApplicationHost::OnMessagePipeCreated( |
+ mojo::ScopedMessagePipeHandle pipe) { |
+ DCHECK(pipe.is_valid()); |
+ application_setup_.reset(new ApplicationSetupImpl( |
+ &service_registry_, |
+ mojo::MakeRequest<ApplicationSetup>(std::move(pipe)))); |
+} |
+ |
} // namespace content |