diff options
author | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 00:31:22 +0000 |
---|---|---|
committer | kbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 00:31:22 +0000 |
commit | 1082b1dd85c92e5260911989d8022988bacb676e (patch) | |
tree | db12d29cafe47d38e3e9657dea037daf694348d7 /chrome/browser/gpu_process_host.h | |
parent | 66ee443252fd759c5e20cb93be1e90a732da0ebe (diff) | |
download | chromium_src-1082b1dd85c92e5260911989d8022988bacb676e.zip chromium_src-1082b1dd85c92e5260911989d8022988bacb676e.tar.gz chromium_src-1082b1dd85c92e5260911989d8022988bacb676e.tar.bz2 |
Split GpuProcessHost into GpuProcessHostUIShim, which runs on the UI
thread, and GpuProcessHost, which now runs on the IO thread and
derives from ChildProcessHost. This split was necessary in order to
service synchronous messages from the renderer process. Moved message
handlers for GPU messages from renderer to browser from
BrowserRenderProcessHost to ResourceMessageFilter.
Stopped sending multiple ViewHostMsg_EstablishGpuChannel messages from
the same renderer if the connection was already established. Resetting
the channel was causing failures in Send, and every other page reload
containing WebGL content to fail. This cleanup will allow further
simplification in the GPU process, but this is being left for a
subsequent CL.
Fixed bug in sandboxing of GPU process. Fixed latent bugs in cleanup
code in GpuChannel and GpuChannelHost. Fixed crashes in
ChildProcessHost if resource_dispatcher_host_ was NULL. Fixed apparent
latent race conditions in creation of BackingStoreProxy and
VideoLayerProxy.
With these changes, WebGL content is running in the sandbox on both
Mac and Windows. Linux support will be added in a following CL.
BUG=29120
TEST=ran WebGL demos on Mac and Windows
Review URL: http://codereview.chromium.org/1546001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43029 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gpu_process_host.h')
-rw-r--r-- | chrome/browser/gpu_process_host.h | 101 |
1 files changed, 45 insertions, 56 deletions
diff --git a/chrome/browser/gpu_process_host.h b/chrome/browser/gpu_process_host.h index 27d3fe3..4065124 100644 --- a/chrome/browser/gpu_process_host.h +++ b/chrome/browser/gpu_process_host.h @@ -9,83 +9,74 @@ #include "base/basictypes.h" #include "base/scoped_ptr.h" -#include "base/singleton.h" -#include "chrome/browser/child_process_launcher.h" -#include "chrome/common/gpu_native_window_handle.h" -#include "chrome/common/message_router.h" -#include "gfx/native_widget_types.h" -#include "ipc/ipc_channel_handle.h" -#include "ipc/ipc_channel_proxy.h" +#include "chrome/browser/child_process_host.h" +#include "chrome/browser/renderer_host/resource_message_filter.h" class ChildProcessLauncher; class CommandBufferProxy; -class GpuProcessHost : public IPC::Channel::Sender, - public IPC::Channel::Listener, - public ChildProcessLauncher::Client { +class GpuProcessHost : public ChildProcessHost { public: // Getter for the singleton. This will return NULL on failure. static GpuProcessHost* Get(); - int32 GetNextRoutingId(); + // Shutdown routine, which should only be called upon process + // termination. + static void Shutdown(); - // Creates the new remote view and returns the routing ID for the view, or 0 - // on failure. - int32 NewRenderWidgetHostView(GpuNativeWindowHandle parent); - - // IPC::Channel::Sender implementation. virtual bool Send(IPC::Message* msg); // IPC::Channel::Listener implementation. virtual void OnMessageReceived(const IPC::Message& message); - virtual void OnChannelConnected(int32 peer_pid); - virtual void OnChannelError(); - - // ChildProcessLauncher::Client implementation. - virtual void OnProcessLaunched(); - - // See documentation on MessageRouter for AddRoute and RemoveRoute - void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); - void RemoveRoute(int32 routing_id); // Tells the GPU process to create a new channel for communication with a // renderer. Will asynchronously send message to object with given routing id // on completion. - void EstablishGpuChannel(int renderer_id); + void EstablishGpuChannel(int renderer_id, + ResourceMessageFilter* filter); // Sends a reply message later when the next GpuHostMsg_SynchronizeReply comes // in. - void Synchronize(int renderer_id, IPC::Message* reply); + void Synchronize(IPC::Message* reply, + ResourceMessageFilter* filter); private: - friend struct DefaultSingletonTraits<GpuProcessHost>; - // Used to queue pending channel requests. struct ChannelRequest { - explicit ChannelRequest(int renderer_id) : renderer_id(renderer_id) {} - // Used to identify the renderer. The ID is used instead of a pointer to - // the RenderProcessHost in case it is destroyed while the request is - // pending. - // TODO(apatrick): investigate whether these IDs are used for future - // render processes. - int renderer_id; + explicit ChannelRequest(ResourceMessageFilter* filter) + : filter(filter) {} + // Used to send the reply message back to the renderer. + scoped_refptr<ResourceMessageFilter> filter; + }; + + // Used to queue pending synchronization requests. + struct SynchronizationRequest { + SynchronizationRequest(IPC::Message* reply, + ResourceMessageFilter* filter) + : reply(reply), + filter(filter) {} + // The delayed reply message which needs to be sent to the + // renderer. + IPC::Message* reply; + + // Used to send the reply message back to the renderer. + scoped_refptr<ResourceMessageFilter> filter; }; GpuProcessHost(); virtual ~GpuProcessHost(); + bool EnsureInitialized(); + bool Init(); + void OnControlMessageReceived(const IPC::Message& message); // Message handlers. void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); - void OnSynchronizeReply(int renderer_id); + void OnSynchronizeReply(); - void ReplyToRenderer(int renderer_id, - const IPC::ChannelHandle& channel); - - // These are the channel requests that we have already sent to - // the GPU process, but haven't heard back about yet. - std::queue<ChannelRequest> sent_requests_; + void ReplyToRenderer(const IPC::ChannelHandle& channel, + ResourceMessageFilter* filter); // Copies applicable command line switches from the given |browser_cmd| line // flags to the output |gpu_cmd| line flags. Not all switches will be @@ -93,24 +84,22 @@ class GpuProcessHost : public IPC::Channel::Sender, void PropagateBrowserCommandLineToGpu(const CommandLine& browser_cmd, CommandLine* gpu_cmd) const; - scoped_ptr<ChildProcessLauncher> child_process_; - - // A proxy for our IPC::Channel that lives on the IO thread (see - // browser_process.h). This will be NULL if the class failed to connect. - scoped_ptr<IPC::ChannelProxy> channel_; + // ResourceDispatcherHost::Receiver implementation: + virtual URLRequestContext* GetRequestContext( + uint32 request_id, + const ViewHostMsg_Resource_Request& request_data); - int last_routing_id_; + virtual bool CanShutdown(); - MessageRouter router_; + bool initialized_; + bool initialized_successfully_; - // Messages we queue while waiting for the process handle. We queue them here - // instead of in the channel so that we ensure they're sent after init related - // messages that are sent once the process handle is available. This is - // because the queued messages may have dependencies on the init messages. - std::queue<IPC::Message*> queued_messages_; + // These are the channel requests that we have already sent to + // the GPU process, but haven't heard back about yet. + std::queue<ChannelRequest> sent_requests_; // The pending synchronization requests we need to reply to. - std::queue<IPC::Message*> queued_synchronization_replies_; + std::queue<SynchronizationRequest> queued_synchronization_replies_; DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); }; |