Index: content/common/gpu/gpu_channel.cc |
=================================================================== |
--- content/common/gpu/gpu_channel.cc (revision 132251) |
+++ content/common/gpu/gpu_channel.cc (working copy) |
@@ -40,6 +40,8 @@ |
bool software) |
: gpu_channel_manager_(gpu_channel_manager), |
client_id_(client_id), |
+ renderer_process_(base::kNullProcessHandle), |
+ renderer_pid_(base::kNullProcessId), |
share_group_(share_group ? share_group : new gfx::GLShareGroup), |
watchdog_(watchdog), |
software_(software), |
@@ -60,6 +62,10 @@ |
} |
GpuChannel::~GpuChannel() { |
+#if defined(OS_WIN) |
+ if (renderer_process_) |
+ CloseHandle(renderer_process_); |
+#endif |
} |
bool GpuChannel::OnMessageReceived(const IPC::Message& message) { |
@@ -107,6 +113,10 @@ |
gpu_channel_manager_->RemoveChannel(client_id_); |
} |
+void GpuChannel::OnChannelConnected(int32 peer_pid) { |
+ renderer_pid_ = peer_pid; |
+} |
+ |
bool GpuChannel::Send(IPC::Message* message) { |
// The GPU process must never send a synchronous IPC message to the renderer |
// process. This could result in deadlock. |
@@ -201,6 +211,7 @@ |
// here. This is so the reply can be delayed if the scheduler is unscheduled. |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) |
+ IPC_MESSAGE_HANDLER(GpuChannelMsg_Initialize, OnInitialize) |
IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_CreateOffscreenCommandBuffer, |
OnCreateOffscreenCommandBuffer) |
IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuChannelMsg_DestroyCommandBuffer, |
@@ -301,6 +312,15 @@ |
return num_contexts_preferring_discrete_gpu_ > 0; |
} |
+void GpuChannel::OnInitialize(base::ProcessHandle renderer_process) { |
+ // Initialize should only happen once. |
+ DCHECK(!renderer_process_); |
+ |
+ // Verify that the renderer has passed its own process handle. |
+ if (base::GetProcId(renderer_process) == renderer_pid_) |
+ renderer_process_ = renderer_process; |
+} |
+ |
void GpuChannel::OnCreateOffscreenCommandBuffer( |
const gfx::Size& size, |
const GPUCreateCommandBufferConfig& init_params, |