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/thread.h" | 9 #include "base/thread.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 195 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
196 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 196 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
197 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply) | 197 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply) |
198 #if defined(OS_LINUX) | 198 #if defined(OS_LINUX) |
199 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetViewXID, OnGetViewXID) | 199 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetViewXID, OnGetViewXID) |
200 #elif defined(OS_MACOSX) | 200 #elif defined(OS_MACOSX) |
201 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, | 201 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, |
202 OnAcceleratedSurfaceSetIOSurface) | 202 OnAcceleratedSurfaceSetIOSurface) |
203 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 203 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
204 OnAcceleratedSurfaceBuffersSwapped) | 204 OnAcceleratedSurfaceBuffersSwapped) |
205 #elif defined(OS_WIN) | |
206 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_CreateCompositorHostWindow, | |
207 OnCreateCompositorHostWindow) | |
208 IPC_MESSAGE_HANDLER(GpuHostMsg_ScheduleComposite, OnScheduleComposite) | |
205 #endif | 209 #endif |
206 // If the IO thread does not handle the message then automatically route it | 210 // If the IO thread does not handle the message then automatically route it |
207 // to the UI thread. The UI thread will report an error if it does not | 211 // to the UI thread. The UI thread will report an error if it does not |
208 // handle it. | 212 // handle it. |
209 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 213 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
210 IPC_END_MESSAGE_MAP() | 214 IPC_END_MESSAGE_MAP() |
211 } | 215 } |
212 | 216 |
213 void GpuProcessHost::OnChannelEstablished( | 217 void GpuProcessHost::OnChannelEstablished( |
214 const IPC::ChannelHandle& channel_handle, | 218 const IPC::ChannelHandle& channel_handle, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 344 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
341 int32 renderer_id, | 345 int32 renderer_id, |
342 int32 render_view_id, | 346 int32 render_view_id, |
343 gfx::PluginWindowHandle window, | 347 gfx::PluginWindowHandle window, |
344 uint64 surface_id) { | 348 uint64 surface_id) { |
345 BrowserThread::PostTask( | 349 BrowserThread::PostTask( |
346 BrowserThread::UI, FROM_HERE, | 350 BrowserThread::UI, FROM_HERE, |
347 new BuffersSwappedDispatcher( | 351 new BuffersSwappedDispatcher( |
348 renderer_id, render_view_id, window, surface_id)); | 352 renderer_id, render_view_id, window, surface_id)); |
349 } | 353 } |
354 | |
355 #elif defined(OS_WIN) | |
356 | |
357 namespace { | |
358 | |
359 void SendDelayedReply(IPC::Message* reply_msg) { | |
360 GpuProcessHost::Get()->Send(reply_msg); | |
361 } | |
362 | |
363 void CreateCompositorHostWindowDispatcher( | |
364 int renderer_id, | |
365 int render_view_id, | |
366 IPC::Message* reply_msg) { | |
367 RenderViewHost* host = RenderViewHost::FromID(renderer_id, | |
apatrick_chromium
2010/11/19 23:09:51
What if the renderer process has been destroyed or
nduca
2010/11/20 00:28:49
Done.
| |
368 render_view_id); | |
369 | |
370 RenderWidgetHostView* view = host->view(); | |
371 gfx::PluginWindowHandle id = view->CreateCompositorHostWindow(); | |
372 | |
373 | |
374 GpuHostMsg_CreateCompositorHostWindow::WriteReplyParams(reply_msg, id); | |
375 BrowserThread::PostTask( | |
apatrick_chromium
2010/11/19 23:09:51
If this is running on the UI thread it should be i
nduca
2010/11/20 00:28:49
Summarizing verbal conversation: the reason that t
| |
376 BrowserThread::IO, FROM_HERE, | |
377 NewRunnableFunction(&SendDelayedReply, reply_msg)); | |
378 } | |
379 | |
380 void ScheduleCompositeDispatcher(int renderer_id, int render_view_id) { | |
381 RenderViewHost* host = RenderViewHost::FromID(renderer_id, | |
382 render_view_id); | |
383 DCHECK(host); | |
apatrick_chromium
2010/11/19 23:09:51
See above about renderer process terminating.
nduca
2010/11/20 00:28:49
Done.
| |
384 | |
385 | |
386 host->ScheduleComposite(); | |
387 } | |
388 } // namespace | |
389 | |
390 void GpuProcessHost::OnCreateCompositorHostWindow( | |
391 int32 renderer_id, | |
392 int32 render_view_id, | |
393 IPC::Message* reply_message) { | |
394 BrowserThread::PostTask( | |
395 BrowserThread::UI, FROM_HERE, | |
396 NewRunnableFunction(&CreateCompositorHostWindowDispatcher, | |
397 renderer_id, render_view_id, reply_message)); | |
398 } | |
399 | |
400 void GpuProcessHost::OnScheduleComposite(int renderer_id, int render_view_id) { | |
apatrick_chromium
2010/11/19 23:09:51
Messages received by GpuProcessHost but not handle
nduca
2010/11/20 00:28:49
Done.
| |
401 BrowserThread::PostTask( | |
402 BrowserThread::UI, FROM_HERE, | |
403 NewRunnableFunction(&ScheduleCompositeDispatcher, | |
404 renderer_id, render_view_id)); | |
405 } | |
350 #endif | 406 #endif |
351 | 407 |
352 void GpuProcessHost::SendEstablishChannelReply( | 408 void GpuProcessHost::SendEstablishChannelReply( |
353 const IPC::ChannelHandle& channel, | 409 const IPC::ChannelHandle& channel, |
354 const GPUInfo& gpu_info, | 410 const GPUInfo& gpu_info, |
355 ResourceMessageFilter* filter) { | 411 ResourceMessageFilter* filter) { |
356 ViewMsg_GpuChannelEstablished* message = | 412 ViewMsg_GpuChannelEstablished* message = |
357 new ViewMsg_GpuChannelEstablished(channel, gpu_info); | 413 new ViewMsg_GpuChannelEstablished(channel, gpu_info); |
358 // If the renderer process is performing synchronous initialization, | 414 // If the renderer process is performing synchronous initialization, |
359 // it needs to handle this message before receiving the reply for | 415 // it needs to handle this message before receiving the reply for |
(...skipping 17 matching lines...) Expand all Loading... | |
377 | 433 |
378 bool GpuProcessHost::CanShutdown() { | 434 bool GpuProcessHost::CanShutdown() { |
379 return true; | 435 return true; |
380 } | 436 } |
381 | 437 |
382 void GpuProcessHost::OnProcessCrashed() { | 438 void GpuProcessHost::OnProcessCrashed() { |
383 // TODO(alokp): Update gpu process crash rate. | 439 // TODO(alokp): Update gpu process crash rate. |
384 BrowserChildProcessHost::OnProcessCrashed(); | 440 BrowserChildProcessHost::OnProcessCrashed(); |
385 } | 441 } |
386 | 442 |
OLD | NEW |