Index: content/browser/gpu/gpu_process_host.cc |
=================================================================== |
--- content/browser/gpu/gpu_process_host.cc (revision 132251) |
+++ content/browser/gpu/gpu_process_host.cc (working copy) |
@@ -267,6 +267,7 @@ |
GpuProcessHost::GpuProcessHost(int host_id, GpuProcessKind kind) |
: host_id_(host_id), |
+ gpu_process_(base::kNullProcessHandle), |
in_process_(false), |
software_rendering_(false), |
kind_(kind), |
@@ -337,6 +338,11 @@ |
content::RESULT_CODE_LAST_CODE); |
} |
+#if defined(OS_WIN) |
+ if (gpu_process_) |
+ CloseHandle(gpu_process_); |
+#endif |
+ |
// In case we never started, clean up. |
while (!queued_messages_.empty()) { |
delete queued_messages_.front(); |
@@ -492,6 +498,10 @@ |
void GpuProcessHost::OnChannelEstablished( |
const IPC::ChannelHandle& channel_handle) { |
+ // The GPU process should have launched at this point and this object should |
+ // have been notified of its process handle. |
+ DCHECK(gpu_process_); |
+ |
EstablishChannelCallback callback = channel_requests_.front(); |
channel_requests_.pop(); |
@@ -511,7 +521,7 @@ |
return; |
} |
- callback.Run(channel_handle, |
+ callback.Run(channel_handle, gpu_process_, |
GpuDataManagerImpl::GetInstance()->GetGPUInfo()); |
} |
@@ -613,6 +623,25 @@ |
#endif // OS_WIN && !USE_AURA |
void GpuProcessHost::OnProcessLaunched() { |
+ // Send the GPU process handle to the UI thread before it has to |
+ // respond to any requests to establish a GPU channel. The response |
+ // to such requests require that the GPU process handle be known. |
+ |
+ base::ProcessHandle child_handle = in_process_ ? |
+ base::GetCurrentProcessHandle() : process_->GetData().handle; |
+ |
+#if defined(OS_WIN) |
+ DuplicateHandle(base::GetCurrentProcessHandle(), |
+ child_handle, |
+ base::GetCurrentProcessHandle(), |
+ &gpu_process_, |
+ PROCESS_DUP_HANDLE, |
+ FALSE, |
+ 0); |
+#else |
+ gpu_process_ = child_handle; |
+#endif |
+ |
UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", |
base::TimeTicks::Now() - init_start_time_); |
} |
@@ -745,7 +774,7 @@ |
const IPC::ChannelHandle& channel_handle, |
base::ProcessHandle renderer_process_for_gpu, |
const content::GPUInfo& gpu_info) { |
- callback.Run(channel_handle, gpu_info); |
+ callback.Run(channel_handle, renderer_process_for_gpu, gpu_info); |
} |
void GpuProcessHost::CreateCommandBufferError( |