diff options
author | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-03 15:42:00 +0000 |
---|---|---|
committer | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-03 15:42:00 +0000 |
commit | c26b4f1fdd2104673654e34a34d80b68d51bd146 (patch) | |
tree | bc74c50f7b950f202d18d78ce97457853d72b1fb /chrome/browser/gpu_process_host.h | |
parent | f7b73adeff4efc43d7e596db442be2be6037fe6a (diff) | |
download | chromium_src-c26b4f1fdd2104673654e34a34d80b68d51bd146.zip chromium_src-c26b4f1fdd2104673654e34a34d80b68d51bd146.tar.gz chromium_src-c26b4f1fdd2104673654e34a34d80b68d51bd146.tar.bz2 |
Refactoring GpuProcessHost for use by the browser.
This is a step towards allowing the browser to make requests of the GpuProcessHost (it's traditionally done by renderers). This is done with a level of indirection. It replaces the sending of IPCs to the renderer with calling a callback (which now sends the IPCs). The IPCs sent from callbacks originating in GpuMessageFilter use WeakPtrs to guard against the filter disappearing before the callback is called.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6287026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73624 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gpu_process_host.h')
-rw-r--r-- | chrome/browser/gpu_process_host.h | 57 |
1 files changed, 19 insertions, 38 deletions
diff --git a/chrome/browser/gpu_process_host.h b/chrome/browser/gpu_process_host.h index 487e9ef..5b6bef4 100644 --- a/chrome/browser/gpu_process_host.h +++ b/chrome/browser/gpu_process_host.h @@ -9,7 +9,8 @@ #include <queue> #include "base/basictypes.h" -#include "base/ref_counted.h" +#include "base/callback.h" +#include "base/linked_ptr.h" #include "base/threading/non_thread_safe.h" #include "chrome/browser/browser_child_process_host.h" #include "chrome/common/gpu_feature_flags.h" @@ -18,7 +19,6 @@ class GpuBlacklist; struct GPUCreateCommandBufferConfig; class GPUInfo; -class GpuMessageFilter; namespace IPC { struct ChannelHandle; @@ -36,15 +36,22 @@ class GpuProcessHost : public BrowserChildProcessHost, // IPC::Channel::Listener implementation. virtual bool OnMessageReceived(const IPC::Message& message); + typedef Callback2<const IPC::ChannelHandle&, const GPUInfo&>::Type + EstablishChannelCallback; + // 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, - GpuMessageFilter* filter); + // renderer. Once the GPU process responds asynchronously with the IPC handle + // and GPUInfo, we call the callback. + void EstablishGpuChannel( + int renderer_id, EstablishChannelCallback* callback); + + typedef Callback0::Type SynchronizeCallback; // Sends a reply message later when the next GpuHostMsg_SynchronizeReply comes // in. - void Synchronize(IPC::Message* reply, GpuMessageFilter* filter); + void Synchronize(SynchronizeCallback* callback); + + typedef Callback1<int32>::Type CreateCommandBufferCallback; // Tells the GPU process to create a new command buffer that draws into the // window associated with the given renderer. @@ -52,35 +59,13 @@ class GpuProcessHost : public BrowserChildProcessHost, int32 render_view_id, int32 renderer_id, const GPUCreateCommandBufferConfig& init_params, - IPC::Message* reply, - GpuMessageFilter* filter); + CreateCommandBufferCallback* callback); // We need to hop threads when creating the command buffer. // Let these tasks access our internals. friend class CVCBThreadHopping; private: - // Used to queue pending channel requests. - struct ChannelRequest { - explicit ChannelRequest(GpuMessageFilter* filter); - ~ChannelRequest(); - - // Used to send the reply message back to the renderer. - scoped_refptr<GpuMessageFilter> filter; - }; - - struct DelayedReply { - DelayedReply(IPC::Message* reply, GpuMessageFilter* filter); - ~DelayedReply(); - - // 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<GpuMessageFilter> filter; - }; - GpuProcessHost(); virtual ~GpuProcessHost(); @@ -95,11 +80,6 @@ class GpuProcessHost : public BrowserChildProcessHost, void OnSynchronizeReply(); void OnCommandBufferCreated(const int32 route_id); - // Sends the response for establish channel request to the renderer. - void SendEstablishChannelReply(const IPC::ChannelHandle& channel, - const GPUInfo& gpu_info, - GpuMessageFilter* filter); - // Sends outstanding replies to renderer processes. This is only called // in error situations like the GPU process crashing -- but is necessary // to prevent the renderer process from hanging. @@ -123,13 +103,14 @@ class GpuProcessHost : public BrowserChildProcessHost, // 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_; + std::queue<linked_ptr<EstablishChannelCallback> > channel_requests_; // The pending synchronization requests we need to reply to. - std::queue<DelayedReply> queued_synchronization_replies_; + std::queue<linked_ptr<SynchronizeCallback> > synchronize_requests_; // The pending create command buffer requests we need to reply to. - std::queue<DelayedReply> create_command_buffer_replies_; + std::queue<linked_ptr<CreateCommandBufferCallback> > + create_command_buffer_requests_; DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); }; |