Chromium Code Reviews| Index: content/browser/gpu/gpu_process_host.cc |
| diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc |
| index ed05dcb8a350aa5720c3eb2d2aef45f4123f3fb7..7186a0415f2740be5b7f000e799e0074fd4b78e3 100644 |
| --- a/content/browser/gpu/gpu_process_host.cc |
| +++ b/content/browser/gpu/gpu_process_host.cc |
| @@ -23,6 +23,7 @@ |
| #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| #include "content/browser/gpu/gpu_surface_tracker.h" |
| #include "content/browser/gpu/shader_disk_cache.h" |
| +#include "content/browser/mojo/mojo_application_host.h" |
| #include "content/browser/renderer_host/render_widget_host_impl.h" |
| #include "content/common/child_process_host_impl.h" |
| #include "content/common/gpu/gpu_messages.h" |
| @@ -527,6 +528,13 @@ GpuProcessHost::~GpuProcessHost() { |
| } |
| } |
| + // We could be destroyed as a result of Chrome shutdown. When that happens, |
| + // the Mojo channel doesn't get the opportunity to shut down cleanly because |
| + // it posts to the IO thread (the current thread) which is being destroyed. |
| + // To guarantee proper shutdown of the Mojo channel, do it explicitly here. |
| + if (mojo_application_host_) |
| + mojo_application_host_->ShutdownOnIOThread(); |
| + |
| BrowserThread::PostTask(BrowserThread::UI, |
| FROM_HERE, |
| base::Bind(&GpuProcessHostUIShim::Destroy, |
| @@ -543,6 +551,9 @@ bool GpuProcessHost::Init() { |
| if (channel_id.empty()) |
| return false; |
| + if (!SetupMojo()) |
| + return false; |
| + |
| if (in_process_) { |
| DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| DCHECK(g_gpu_main_thread_factory); |
| @@ -575,6 +586,12 @@ bool GpuProcessHost::Init() { |
| return true; |
| } |
| +bool GpuProcessHost::SetupMojo() { |
| + CHECK(!mojo_application_host_); |
|
piman
2015/10/06 19:59:35
DCHECK
xhwang
2015/10/07 19:07:58
Done.
|
| + mojo_application_host_.reset(new MojoApplicationHost); |
| + return mojo_application_host_->Init(); |
| +} |
| + |
| void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { |
| BrowserThread::PostTask( |
| BrowserThread::UI, |
| @@ -868,6 +885,15 @@ void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
| void GpuProcessHost::OnProcessLaunched() { |
| UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", |
| base::TimeTicks::Now() - init_start_time_); |
| + if (mojo_application_host_) { |
|
piman
2015/10/06 19:59:35
When would this be false?
xhwang
2015/10/07 19:07:58
This should never be false. Removed the if stateme
|
| + base::ProcessHandle handle; |
| + if (in_process_) |
| + handle = base::GetCurrentProcessHandle(); |
| + else |
| + handle = process_->GetData().handle; |
| + |
| + mojo_application_host_->Activate(this, handle); |
| + } |
| } |
| void GpuProcessHost::OnProcessLaunchFailed() { |
| @@ -881,6 +907,12 @@ void GpuProcessHost::OnProcessCrashed(int exit_code) { |
| process_->GetTerminationStatus(true /* known_dead */, NULL)); |
| } |
| +ServiceRegistry* GpuProcessHost::GetServiceRegistry() { |
| + if (mojo_application_host_) |
|
piman
2015/10/06 19:59:35
When would this be false?
xhwang
2015/10/07 19:07:58
Done.
|
| + return mojo_application_host_->service_registry(); |
| + return nullptr; |
| +} |
| + |
| GpuProcessHost::GpuProcessKind GpuProcessHost::kind() { |
| return kind_; |
| } |