| OLD | NEW |
| 1 // TODO(jam): move this file to src/content once we have an interface that the | 1 // TODO(jam): move this file to src/content once we have an interface that the |
| 2 // embedder provides. We can then use it to get the resource and resize the | 2 // embedder provides. We can then use it to get the resource and resize the |
| 3 // window. | 3 // window. |
| 4 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 4 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 5 // Use of this source code is governed by a BSD-style license that can be | 5 // Use of this source code is governed by a BSD-style license that can be |
| 6 // found in the LICENSE file. | 6 // found in the LICENSE file. |
| 7 | 7 |
| 8 #include "chrome/browser/gpu_process_host_ui_shim.h" | 8 #include "chrome/browser/gpu_process_host_ui_shim.h" |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 public: | 63 public: |
| 64 virtual bool Send(IPC::Message* msg) { | 64 virtual bool Send(IPC::Message* msg) { |
| 65 // The GPU process must never send a synchronous IPC message to the browser | 65 // The GPU process must never send a synchronous IPC message to the browser |
| 66 // process. This could result in deadlock. Unfortunately linux does this for | 66 // process. This could result in deadlock. Unfortunately linux does this for |
| 67 // GpuHostMsg_ResizeXID. TODO(apatrick): fix this before issuing any GL calls | 67 // GpuHostMsg_ResizeXID. TODO(apatrick): fix this before issuing any GL calls |
| 68 // on the browser process' GPU thread. | 68 // on the browser process' GPU thread. |
| 69 #if !defined(OS_LINUX) | 69 #if !defined(OS_LINUX) |
| 70 DCHECK(!msg->is_sync()); | 70 DCHECK(!msg->is_sync()); |
| 71 #endif | 71 #endif |
| 72 | 72 |
| 73 // When the GpuRenderThread sends an IPC, post it to the UI thread without | 73 // When the GpuChannelManager sends an IPC, post it to the UI thread without |
| 74 // using IPC. | 74 // using IPC. |
| 75 bool success = BrowserThread::PostTask( | 75 bool success = BrowserThread::PostTask( |
| 76 BrowserThread::UI, | 76 BrowserThread::UI, |
| 77 FROM_HERE, | 77 FROM_HERE, |
| 78 new RouteToGpuProcessHostUIShimTask(0, *msg)); | 78 new RouteToGpuProcessHostUIShimTask(0, *msg)); |
| 79 | 79 |
| 80 delete msg; | 80 delete msg; |
| 81 return success; | 81 return success; |
| 82 } | 82 } |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 void ForwardMessageToGpuThread(GpuRenderThread* render_thread, | 85 void ForwardMessageToGpuThread(GpuChannelManager* gpu_channel_manager, |
| 86 IPC::Message* msg) { | 86 IPC::Message* msg) { |
| 87 bool success = render_thread->OnMessageReceived(*msg); | 87 bool success = gpu_channel_manager->OnMessageReceived(*msg); |
| 88 | 88 |
| 89 // If the message was not handled, it is likely it was intended for the | 89 // If the message was not handled, it is likely it was intended for the |
| 90 // GpuChildThread, which does not exist in single process and in process GPU | 90 // GpuChildThread, which does not exist in single process and in process GPU |
| 91 // mode. | 91 // mode. |
| 92 DCHECK(success); | 92 DCHECK(success); |
| 93 | 93 |
| 94 delete msg; | 94 delete msg; |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace | 97 } // namespace |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 RenderWidgetHostView* view = NULL; | 155 RenderWidgetHostView* view = NULL; |
| 156 if (host) | 156 if (host) |
| 157 view = host->view(); | 157 view = host->view(); |
| 158 | 158 |
| 159 return view; | 159 return view; |
| 160 } | 160 } |
| 161 | 161 |
| 162 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) | 162 GpuProcessHostUIShim::GpuProcessHostUIShim(int host_id) |
| 163 : host_id_(host_id), | 163 : host_id_(host_id), |
| 164 gpu_process_(base::kNullProcessHandle), | 164 gpu_process_(base::kNullProcessHandle), |
| 165 gpu_render_thread_(NULL), | 165 gpu_channel_manager_(NULL), |
| 166 ui_thread_sender_(NULL) { | 166 ui_thread_sender_(NULL) { |
| 167 g_hosts_by_id.AddWithID(this, host_id_); | 167 g_hosts_by_id.AddWithID(this, host_id_); |
| 168 gpu_data_manager_ = GpuDataManager::GetInstance(); | 168 gpu_data_manager_ = GpuDataManager::GetInstance(); |
| 169 DCHECK(gpu_data_manager_); | 169 DCHECK(gpu_data_manager_); |
| 170 | 170 |
| 171 if (host_id == 0) { | 171 if (host_id == 0) { |
| 172 gpu_process_ = base::GetCurrentProcessHandle(); | 172 gpu_process_ = base::GetCurrentProcessHandle(); |
| 173 ui_thread_sender_ = new UIThreadSender; | 173 ui_thread_sender_ = new UIThreadSender; |
| 174 gpu_render_thread_ = new GpuRenderThread( | 174 gpu_channel_manager_ = new GpuChannelManager( |
| 175 ui_thread_sender_, | 175 ui_thread_sender_, |
| 176 NULL, | 176 NULL, |
| 177 g_browser_process->io_thread()->message_loop(), | 177 g_browser_process->io_thread()->message_loop(), |
| 178 g_browser_process->shutdown_event()); | 178 g_browser_process->shutdown_event()); |
| 179 } else { | 179 } else { |
| 180 // Post a task to create the corresponding GpuProcessHost. | 180 // Post a task to create the corresponding GpuProcessHost. |
| 181 // The GpuProcessHostUIShim will be destroyed if either the browser exits, | 181 // The GpuProcessHostUIShim will be destroyed if either the browser exits, |
| 182 // in which case it calls GpuProcessHostUIShim::DestroyAll, or the | 182 // in which case it calls GpuProcessHostUIShim::DestroyAll, or the |
| 183 // GpuProcessHost is destroyed, which happens when the corresponding GPU | 183 // GpuProcessHost is destroyed, which happens when the corresponding GPU |
| 184 // process terminates or fails to launch. | 184 // process terminates or fails to launch. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 bool GpuProcessHostUIShim::Send(IPC::Message* msg) { | 268 bool GpuProcessHostUIShim::Send(IPC::Message* msg) { |
| 269 DCHECK(CalledOnValidThread()); | 269 DCHECK(CalledOnValidThread()); |
| 270 | 270 |
| 271 bool success; | 271 bool success; |
| 272 | 272 |
| 273 if (host_id_ == 0) { | 273 if (host_id_ == 0) { |
| 274 success = BrowserThread::PostTask( | 274 success = BrowserThread::PostTask( |
| 275 BrowserThread::GPU, | 275 BrowserThread::GPU, |
| 276 FROM_HERE, | 276 FROM_HERE, |
| 277 NewRunnableFunction(ForwardMessageToGpuThread, | 277 NewRunnableFunction(ForwardMessageToGpuThread, |
| 278 gpu_render_thread_, | 278 gpu_channel_manager_, |
| 279 msg)); | 279 msg)); |
| 280 } else { | 280 } else { |
| 281 success = BrowserThread::PostTask( | 281 success = BrowserThread::PostTask( |
| 282 BrowserThread::IO, | 282 BrowserThread::IO, |
| 283 FROM_HERE, | 283 FROM_HERE, |
| 284 new SendOnIOThreadTask(host_id_, msg)); | 284 new SendOnIOThreadTask(host_id_, msg)); |
| 285 } | 285 } |
| 286 | 286 |
| 287 return success; | 287 return success; |
| 288 } | 288 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 GpuProcessHostUIShim::~GpuProcessHostUIShim() { | 478 GpuProcessHostUIShim::~GpuProcessHostUIShim() { |
| 479 DCHECK(CalledOnValidThread()); | 479 DCHECK(CalledOnValidThread()); |
| 480 g_hosts_by_id.Remove(host_id_); | 480 g_hosts_by_id.Remove(host_id_); |
| 481 | 481 |
| 482 #if defined(OS_WIN) | 482 #if defined(OS_WIN) |
| 483 if (gpu_process_) | 483 if (gpu_process_) |
| 484 CloseHandle(gpu_process_); | 484 CloseHandle(gpu_process_); |
| 485 #endif | 485 #endif |
| 486 | 486 |
| 487 // Ensure these are destroyed on the GPU thread. | 487 // Ensure these are destroyed on the GPU thread. |
| 488 if (gpu_render_thread_) { | 488 if (gpu_channel_manager_) { |
| 489 BrowserThread::DeleteSoon(BrowserThread::GPU, | 489 BrowserThread::DeleteSoon(BrowserThread::GPU, |
| 490 FROM_HERE, | 490 FROM_HERE, |
| 491 gpu_render_thread_); | 491 gpu_channel_manager_); |
| 492 gpu_render_thread_ = NULL; | 492 gpu_channel_manager_ = NULL; |
| 493 } | 493 } |
| 494 if (ui_thread_sender_) { | 494 if (ui_thread_sender_) { |
| 495 BrowserThread::DeleteSoon(BrowserThread::GPU, | 495 BrowserThread::DeleteSoon(BrowserThread::GPU, |
| 496 FROM_HERE, | 496 FROM_HERE, |
| 497 ui_thread_sender_); | 497 ui_thread_sender_); |
| 498 ui_thread_sender_ = NULL; | 498 ui_thread_sender_ = NULL; |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 | 501 |
| 502 void GpuProcessHostUIShim::AddCustomLogMessage(int level, | 502 void GpuProcessHostUIShim::AddCustomLogMessage(int level, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 int render_view_id) { | 666 int render_view_id) { |
| 667 RenderViewHost* host = RenderViewHost::FromID(renderer_id, | 667 RenderViewHost* host = RenderViewHost::FromID(renderer_id, |
| 668 render_view_id); | 668 render_view_id); |
| 669 if (!host) { | 669 if (!host) { |
| 670 return; | 670 return; |
| 671 } | 671 } |
| 672 host->ScheduleComposite(); | 672 host->ScheduleComposite(); |
| 673 } | 673 } |
| 674 | 674 |
| 675 #endif | 675 #endif |
| OLD | NEW |