OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/gpu_process_host.h" | 5 #include "chrome/browser/gpu_process_host.h" |
6 | 6 |
7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/thread.h" | 10 #include "base/thread.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 #if defined(OS_LINUX) | 179 #if defined(OS_LINUX) |
180 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetViewXID, OnGetViewXID) | 180 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetViewXID, OnGetViewXID) |
181 IPC_MESSAGE_HANDLER(GpuHostMsg_ReleaseXID, OnReleaseXID) | 181 IPC_MESSAGE_HANDLER(GpuHostMsg_ReleaseXID, OnReleaseXID) |
182 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_ResizeXID, OnResizeXID) | 182 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_ResizeXID, OnResizeXID) |
183 #elif defined(OS_MACOSX) | 183 #elif defined(OS_MACOSX) |
184 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, | 184 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, |
185 OnAcceleratedSurfaceSetIOSurface) | 185 OnAcceleratedSurfaceSetIOSurface) |
186 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 186 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
187 OnAcceleratedSurfaceBuffersSwapped) | 187 OnAcceleratedSurfaceBuffersSwapped) |
188 #elif defined(OS_WIN) | 188 #elif defined(OS_WIN) |
189 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_CreateCompositorHostWindow, | 189 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetCompositorHostWindow, |
190 OnCreateCompositorHostWindow) | 190 OnGetCompositorHostWindow) |
191 #endif | 191 #endif |
192 // If the IO thread does not handle the message then automatically route it | 192 // If the IO thread does not handle the message then automatically route it |
193 // to the UI thread. The UI thread will report an error if it does not | 193 // to the UI thread. The UI thread will report an error if it does not |
194 // handle it. | 194 // handle it. |
195 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 195 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
196 IPC_END_MESSAGE_MAP() | 196 IPC_END_MESSAGE_MAP() |
197 } | 197 } |
198 | 198 |
199 void GpuProcessHost::OnChannelEstablished( | 199 void GpuProcessHost::OnChannelEstablished( |
200 const IPC::ChannelHandle& channel_handle, | 200 const IPC::ChannelHandle& channel_handle, |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 } | 391 } |
392 | 392 |
393 #elif defined(OS_WIN) | 393 #elif defined(OS_WIN) |
394 | 394 |
395 namespace { | 395 namespace { |
396 | 396 |
397 void SendDelayedReply(IPC::Message* reply_msg) { | 397 void SendDelayedReply(IPC::Message* reply_msg) { |
398 GpuProcessHost::Get()->Send(reply_msg); | 398 GpuProcessHost::Get()->Send(reply_msg); |
399 } | 399 } |
400 | 400 |
401 void CreateCompositorHostWindowDispatcher( | 401 void GetCompositorHostWindowDispatcher( |
402 int renderer_id, | 402 int renderer_id, |
403 int render_view_id, | 403 int render_view_id, |
404 IPC::Message* reply_msg) { | 404 IPC::Message* reply_msg) { |
405 RenderViewHost* host = RenderViewHost::FromID(renderer_id, | 405 RenderViewHost* host = RenderViewHost::FromID(renderer_id, |
406 render_view_id); | 406 render_view_id); |
407 if (!host) { | 407 if (!host) { |
408 GpuHostMsg_CreateCompositorHostWindow::WriteReplyParams(reply_msg, | 408 GpuHostMsg_GetCompositorHostWindow::WriteReplyParams(reply_msg, |
409 gfx::kNullPluginWindow); | 409 gfx::kNullPluginWindow); |
410 BrowserThread::PostTask( | 410 BrowserThread::PostTask( |
411 BrowserThread::IO, FROM_HERE, | 411 BrowserThread::IO, FROM_HERE, |
412 NewRunnableFunction(&SendDelayedReply, reply_msg)); | 412 NewRunnableFunction(&SendDelayedReply, reply_msg)); |
413 return; | 413 return; |
414 } | 414 } |
415 | 415 |
416 RenderWidgetHostView* view = host->view(); | 416 RenderWidgetHostView* view = host->view(); |
417 gfx::PluginWindowHandle id = view->CreateCompositorHostWindow(); | 417 gfx::PluginWindowHandle id = view->GetCompositorHostWindow(); |
418 | 418 |
419 | 419 |
420 GpuHostMsg_CreateCompositorHostWindow::WriteReplyParams(reply_msg, id); | 420 GpuHostMsg_GetCompositorHostWindow::WriteReplyParams(reply_msg, id); |
421 BrowserThread::PostTask( | 421 BrowserThread::PostTask( |
422 BrowserThread::IO, FROM_HERE, | 422 BrowserThread::IO, FROM_HERE, |
423 NewRunnableFunction(&SendDelayedReply, reply_msg)); | 423 NewRunnableFunction(&SendDelayedReply, reply_msg)); |
424 } | 424 } |
425 | 425 |
426 } // namespace | 426 } // namespace |
427 | 427 |
428 void GpuProcessHost::OnCreateCompositorHostWindow( | 428 void GpuProcessHost::OnGetCompositorHostWindow( |
429 int renderer_id, | 429 int renderer_id, |
430 int render_view_id, | 430 int render_view_id, |
431 IPC::Message* reply_message) { | 431 IPC::Message* reply_message) { |
432 BrowserThread::PostTask( | 432 BrowserThread::PostTask( |
433 BrowserThread::UI, FROM_HERE, | 433 BrowserThread::UI, FROM_HERE, |
434 NewRunnableFunction(&CreateCompositorHostWindowDispatcher, | 434 NewRunnableFunction(&GetCompositorHostWindowDispatcher, |
435 renderer_id, render_view_id, reply_message)); | 435 renderer_id, render_view_id, reply_message)); |
436 } | 436 } |
437 | 437 |
438 #endif | 438 #endif |
439 | 439 |
440 void GpuProcessHost::SendEstablishChannelReply( | 440 void GpuProcessHost::SendEstablishChannelReply( |
441 const IPC::ChannelHandle& channel, | 441 const IPC::ChannelHandle& channel, |
442 const GPUInfo& gpu_info, | 442 const GPUInfo& gpu_info, |
443 ResourceMessageFilter* filter) { | 443 ResourceMessageFilter* filter) { |
444 ViewMsg_GpuChannelEstablished* message = | 444 ViewMsg_GpuChannelEstablished* message = |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 false, // Never use the zygote (GPU plugin can't be sandboxed). | 530 false, // Never use the zygote (GPU plugin can't be sandboxed). |
531 base::environment_vector(), | 531 base::environment_vector(), |
532 #endif | 532 #endif |
533 cmd_line); | 533 cmd_line); |
534 | 534 |
535 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", | 535 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", |
536 kLaunched, kGPUProcessLifetimeEvent_Max); | 536 kLaunched, kGPUProcessLifetimeEvent_Max); |
537 return true; | 537 return true; |
538 } | 538 } |
539 | 539 |
OLD | NEW |