| 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 #ifndef CHROME_BROWSER_GPU_PROCESS_HOST_H_ | 5 #ifndef CHROME_BROWSER_GPU_PROCESS_HOST_H_ |
| 6 #define CHROME_BROWSER_GPU_PROCESS_HOST_H_ | 6 #define CHROME_BROWSER_GPU_PROCESS_HOST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/non_thread_safe.h" | 12 #include "base/non_thread_safe.h" |
| 13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 14 #include "chrome/browser/browser_child_process_host.h" | 14 #include "chrome/browser/browser_child_process_host.h" |
| 15 #include "gfx/native_widget_types.h" | 15 #include "gfx/native_widget_types.h" |
| 16 | 16 |
| 17 struct GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params; | 17 struct GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params; |
| 18 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; | 18 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; |
| 19 class GpuBlacklist; | 19 class GpuBlacklist; |
| 20 class GPUInfo; | 20 class GPUInfo; |
| 21 class ResourceMessageFilter; | 21 class RenderMessageFilter; |
| 22 | 22 |
| 23 namespace gfx { | 23 namespace gfx { |
| 24 class Size; | 24 class Size; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace IPC { | 27 namespace IPC { |
| 28 struct ChannelHandle; | 28 struct ChannelHandle; |
| 29 class Message; | 29 class Message; |
| 30 } | 30 } |
| 31 | 31 |
| 32 class GpuProcessHost : public BrowserChildProcessHost, public NonThreadSafe { | 32 class GpuProcessHost : public BrowserChildProcessHost, public NonThreadSafe { |
| 33 public: | 33 public: |
| 34 // Getter for the singleton. This will return NULL on failure. | 34 // Getter for the singleton. This will return NULL on failure. |
| 35 static GpuProcessHost* Get(); | 35 static GpuProcessHost* Get(); |
| 36 | 36 |
| 37 virtual bool Send(IPC::Message* msg); | 37 virtual bool Send(IPC::Message* msg); |
| 38 | 38 |
| 39 // IPC::Channel::Listener implementation. | 39 // IPC::Channel::Listener implementation. |
| 40 virtual void OnMessageReceived(const IPC::Message& message); | 40 virtual void OnMessageReceived(const IPC::Message& message); |
| 41 | 41 |
| 42 // Tells the GPU process to create a new channel for communication with a | 42 // Tells the GPU process to create a new channel for communication with a |
| 43 // renderer. Will asynchronously send message to object with given routing id | 43 // renderer. Will asynchronously send message to object with given routing id |
| 44 // on completion. | 44 // on completion. |
| 45 void EstablishGpuChannel(int renderer_id, | 45 void EstablishGpuChannel(int renderer_id, RenderMessageFilter* filter); |
| 46 ResourceMessageFilter* filter); | |
| 47 | 46 |
| 48 // Sends a reply message later when the next GpuHostMsg_SynchronizeReply comes | 47 // Sends a reply message later when the next GpuHostMsg_SynchronizeReply comes |
| 49 // in. | 48 // in. |
| 50 void Synchronize(IPC::Message* reply, | 49 void Synchronize(IPC::Message* reply, RenderMessageFilter* filter); |
| 51 ResourceMessageFilter* filter); | |
| 52 | 50 |
| 53 private: | 51 private: |
| 54 // Used to queue pending channel requests. | 52 // Used to queue pending channel requests. |
| 55 struct ChannelRequest { | 53 struct ChannelRequest { |
| 56 explicit ChannelRequest(ResourceMessageFilter* filter); | 54 explicit ChannelRequest(RenderMessageFilter* filter); |
| 57 ~ChannelRequest(); | 55 ~ChannelRequest(); |
| 58 | 56 |
| 59 // Used to send the reply message back to the renderer. | 57 // Used to send the reply message back to the renderer. |
| 60 scoped_refptr<ResourceMessageFilter> filter; | 58 scoped_refptr<RenderMessageFilter> filter; |
| 61 }; | 59 }; |
| 62 | 60 |
| 63 // Used to queue pending synchronization requests. | 61 // Used to queue pending synchronization requests. |
| 64 struct SynchronizationRequest { | 62 struct SynchronizationRequest { |
| 65 SynchronizationRequest(IPC::Message* reply, | 63 SynchronizationRequest(IPC::Message* reply, RenderMessageFilter* filter); |
| 66 ResourceMessageFilter* filter); | |
| 67 ~SynchronizationRequest(); | 64 ~SynchronizationRequest(); |
| 68 | 65 |
| 69 // The delayed reply message which needs to be sent to the | 66 // The delayed reply message which needs to be sent to the |
| 70 // renderer. | 67 // renderer. |
| 71 IPC::Message* reply; | 68 IPC::Message* reply; |
| 72 | 69 |
| 73 // Used to send the reply message back to the renderer. | 70 // Used to send the reply message back to the renderer. |
| 74 scoped_refptr<ResourceMessageFilter> filter; | 71 scoped_refptr<RenderMessageFilter> filter; |
| 75 }; | 72 }; |
| 76 | 73 |
| 77 GpuProcessHost(); | 74 GpuProcessHost(); |
| 78 virtual ~GpuProcessHost(); | 75 virtual ~GpuProcessHost(); |
| 79 | 76 |
| 80 bool EnsureInitialized(); | 77 bool EnsureInitialized(); |
| 81 bool Init(); | 78 bool Init(); |
| 82 | 79 |
| 83 void OnControlMessageReceived(const IPC::Message& message); | 80 void OnControlMessageReceived(const IPC::Message& message); |
| 84 | 81 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 97 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); | 94 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); |
| 98 #elif defined(OS_WIN) | 95 #elif defined(OS_WIN) |
| 99 void OnGetCompositorHostWindow(int renderer_id, | 96 void OnGetCompositorHostWindow(int renderer_id, |
| 100 int render_view_id, | 97 int render_view_id, |
| 101 IPC::Message* reply_message); | 98 IPC::Message* reply_message); |
| 102 #endif | 99 #endif |
| 103 | 100 |
| 104 // Sends the response for establish channel request to the renderer. | 101 // Sends the response for establish channel request to the renderer. |
| 105 void SendEstablishChannelReply(const IPC::ChannelHandle& channel, | 102 void SendEstablishChannelReply(const IPC::ChannelHandle& channel, |
| 106 const GPUInfo& gpu_info, | 103 const GPUInfo& gpu_info, |
| 107 ResourceMessageFilter* filter); | 104 RenderMessageFilter* filter); |
| 108 // Sends the response for synchronization request to the renderer. | 105 // Sends the response for synchronization request to the renderer. |
| 109 void SendSynchronizationReply(IPC::Message* reply, | 106 void SendSynchronizationReply(IPC::Message* reply, |
| 110 ResourceMessageFilter* filter); | 107 RenderMessageFilter* filter); |
| 111 | 108 |
| 112 // ResourceDispatcherHost::Receiver implementation: | 109 // ResourceDispatcherHost::Receiver implementation: |
| 113 virtual URLRequestContext* GetRequestContext( | 110 virtual URLRequestContext* GetRequestContext( |
| 114 uint32 request_id, | 111 uint32 request_id, |
| 115 const ViewHostMsg_Resource_Request& request_data); | 112 const ViewHostMsg_Resource_Request& request_data); |
| 116 | 113 |
| 117 virtual bool CanShutdown(); | 114 virtual bool CanShutdown(); |
| 118 virtual void OnChildDied(); | 115 virtual void OnChildDied(); |
| 119 virtual void OnProcessCrashed(); | 116 virtual void OnProcessCrashed(); |
| 120 | 117 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 132 // the GPU process, but haven't heard back about yet. | 129 // the GPU process, but haven't heard back about yet. |
| 133 std::queue<ChannelRequest> sent_requests_; | 130 std::queue<ChannelRequest> sent_requests_; |
| 134 | 131 |
| 135 // The pending synchronization requests we need to reply to. | 132 // The pending synchronization requests we need to reply to. |
| 136 std::queue<SynchronizationRequest> queued_synchronization_replies_; | 133 std::queue<SynchronizationRequest> queued_synchronization_replies_; |
| 137 | 134 |
| 138 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 135 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 139 }; | 136 }; |
| 140 | 137 |
| 141 #endif // CHROME_BROWSER_GPU_PROCESS_HOST_H_ | 138 #endif // CHROME_BROWSER_GPU_PROCESS_HOST_H_ |
| OLD | NEW |