diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-22 22:00:40 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-22 22:00:40 +0000 |
commit | 06b2fc91993338eb5d7dd77e87bbf4f9685b168a (patch) | |
tree | 848888be1d1c3ccb60e29789418c8344c19eb27c /content | |
parent | a18e47f66e00b8e219f59298b4828d8eaede9fa2 (diff) | |
download | chromium_src-06b2fc91993338eb5d7dd77e87bbf4f9685b168a.zip chromium_src-06b2fc91993338eb5d7dd77e87bbf4f9685b168a.tar.gz chromium_src-06b2fc91993338eb5d7dd77e87bbf4f9685b168a.tar.bz2 |
Recreate both GpuProcessHost and GpuProcessHostUIShim when a new GPU process is launched.
This is so that a renderer that was previously sending messages to the browser regarding a particular GPU process, it can be informed that a new one has been launched and that it has to start over. This part is not done yet.
Both GpuProcessHost and GpuProcessHostUIShim are now identified by a common host ID. Neither are singletons.
This is also a step towards allowing multiple GPU processes.
TEST=trybots, check WebGL and 3D CSS work, check terminating Chrome works while running WebGL, check --single-process works, checking terminated GPU process is relaunched and that 3D CSS restarts automatically
BUG=none
Review URL: http://codereview.chromium.org/6473003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75645 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
4 files changed, 67 insertions, 19 deletions
diff --git a/content/browser/renderer_host/gpu_message_filter.cc b/content/browser/renderer_host/gpu_message_filter.cc index 157b96d..cbece30 100644 --- a/content/browser/renderer_host/gpu_message_filter.cc +++ b/content/browser/renderer_host/gpu_message_filter.cc @@ -2,16 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/renderer_host/gpu_message_filter.h" +#include "chrome/browser/renderer_host/gpu_message_filter.h" #include "base/callback.h" +#include "chrome/browser/gpu_process_host.h" #include "chrome/browser/gpu_process_host_ui_shim.h" #include "chrome/common/gpu_create_command_buffer_config.h" #include "chrome/common/gpu_messages.h" #include "chrome/common/render_messages.h" GpuMessageFilter::GpuMessageFilter(int render_process_id) - : render_process_id_(render_process_id) { + : gpu_host_id_(0), + render_process_id_(render_process_id) { } // WeakPtrs to a GpuMessageFilter need to be Invalidated from @@ -132,20 +134,62 @@ class CreateCommandBufferCallback : public CallbackRunner<Tuple1<int32> > { } // namespace void GpuMessageFilter::OnEstablishGpuChannel() { - GpuProcessHostUIShim::GetInstance()->EstablishGpuChannel( - render_process_id_, new EstablishChannelCallback(this)); + scoped_ptr<EstablishChannelCallback> callback( + new EstablishChannelCallback(this)); + + // TODO(apatrick): Eventually, this will return the route ID of a + // GpuProcessStub, from which the renderer process will create a + // GpuProcessProxy. The renderer will use the proxy for all subsequent + // communication with the GPU process. This means if the GPU process + // terminates, the renderer process will not find itself unknowingly sending + // IPCs to a newly launched GPU process. Also, I will rename this function + // to something like OnCreateGpuProcess. + GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id_); + if (!ui_shim) { + ui_shim = GpuProcessHostUIShim::GetForRenderer(render_process_id_); + if (!ui_shim) { + callback->Run(IPC::ChannelHandle(), GPUInfo()); + return; + } + + gpu_host_id_ = ui_shim->host_id(); + } + + ui_shim->EstablishGpuChannel(render_process_id_, + callback.release()); } void GpuMessageFilter::OnSynchronizeGpu(IPC::Message* reply) { - GpuProcessHostUIShim::GetInstance()-> - Synchronize(new SynchronizeCallback(this, reply)); + GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id_); + if (!ui_shim) { + // TODO(apatrick): Eventually, this IPC message will be routed to a + // GpuProcessStub with a particular routing ID. The error will be set if + // the GpuProcessStub with that routing ID is not in the MessageRouter. + reply->set_reply_error(); + Send(reply); + return; + } + + ui_shim->Synchronize(new SynchronizeCallback(this, reply)); } void GpuMessageFilter::OnCreateViewCommandBuffer( int32 render_view_id, const GPUCreateCommandBufferConfig& init_params, IPC::Message* reply) { - GpuProcessHostUIShim::GetInstance()->CreateViewCommandBuffer( - render_view_id, render_process_id_, init_params, + GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id_); + if (!ui_shim) { + // TODO(apatrick): Eventually, this IPC message will be routed to a + // GpuProcessStub with a particular routing ID. The error will be set if + // the GpuProcessStub with that routing ID is not in the MessageRouter. + reply->set_reply_error(); + Send(reply); + return; + } + + ui_shim->CreateViewCommandBuffer( + render_view_id, + render_process_id_, + init_params, new CreateCommandBufferCallback(this, reply)); } diff --git a/content/browser/renderer_host/gpu_message_filter.h b/content/browser/renderer_host/gpu_message_filter.h index a81fa2a..50d53942 100644 --- a/content/browser/renderer_host/gpu_message_filter.h +++ b/content/browser/renderer_host/gpu_message_filter.h @@ -2,20 +2,22 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ -#define CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ +#ifndef CHROME_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ +#define CHROME_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ #pragma once #include "chrome/browser/browser_message_filter.h" struct GPUCreateCommandBufferConfig; class GPUInfo; +class GpuProcessHost; +class GpuProcessHostUIShim; namespace IPC { struct ChannelHandle; } -// A message filter for messages from the renderer to the GpuProcessHost +// A message filter for messages from the renderer to the GpuProcessHost(UIShim) // in the browser. Such messages are typically destined for the GPU process, // but need to be mediated by the browser. class GpuMessageFilter : public BrowserMessageFilter, @@ -43,9 +45,10 @@ class GpuMessageFilter : public BrowserMessageFilter, const GPUCreateCommandBufferConfig& init_params, IPC::Message* reply); + int gpu_host_id_; int render_process_id_; DISALLOW_COPY_AND_ASSIGN(GpuMessageFilter); }; -#endif // CONTENT_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ +#endif // CHROME_BROWSER_RENDERER_HOST_GPU_MESSAGE_FILTER_H_ diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index 5fbd2df..076d3e0 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/renderer_host/render_widget_host.h" +#include "chrome/browser/renderer_host/render_widget_host.h" #include "base/auto_reset.h" #include "base/command_line.h" @@ -10,17 +10,17 @@ #include "base/metrics/histogram.h" #include "chrome/browser/accessibility/browser_accessibility_state.h" #include "chrome/browser/metrics/user_metrics.h" +#include "chrome/browser/renderer_host/backing_store.h" +#include "chrome/browser/renderer_host/backing_store_manager.h" +#include "chrome/browser/renderer_host/render_process_host.h" +#include "chrome/browser/renderer_host/render_widget_helper.h" +#include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/result_codes.h" #include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/notification_service.h" #include "chrome/common/render_messages.h" #include "chrome/common/render_messages_params.h" -#include "content/browser/renderer_host/backing_store.h" -#include "content/browser/renderer_host/backing_store_manager.h" -#include "content/browser/renderer_host/render_process_host.h" -#include "content/browser/renderer_host/render_widget_helper.h" -#include "content/browser/renderer_host/render_widget_host_view.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCompositionUnderline.h" #include "ui/base/keycodes/keyboard_codes.h" #include "webkit/glue/webcursor.h" @@ -1118,7 +1118,7 @@ void RenderWidgetHost::OnAcceleratedSurfaceBuffersSwapped( // updating of accelerated plugins as well. However, if we add support // for composited plugins then this is not necessary. view_->AcceleratedSurfaceBuffersSwapped(window, surface_id, - 0, 0, 0); + 0, 0, 0, 0); } } #elif defined(OS_POSIX) diff --git a/content/browser/renderer_host/render_widget_host_view.h b/content/browser/renderer_host/render_widget_host_view.h index a3f7031..fa0d39a 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -250,6 +250,7 @@ class RenderWidgetHostView { uint64 surface_id, int renderer_id, int32 route_id, + int gpu_host_id, uint64 swap_buffers_count) = 0; virtual void GpuRenderingStateDidChange() = 0; #endif |