| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 5 #ifndef CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| 6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <set> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/callback.h" | 13 #include "base/callback.h" |
| 13 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
| 14 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
| 15 #include "base/time.h" | 16 #include "base/time.h" |
| 16 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
| 17 #include "content/common/gpu/gpu_process_launch_causes.h" | 18 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 18 #include "content/public/browser/browser_child_process_host_delegate.h" | 19 #include "content/public/browser/browser_child_process_host_delegate.h" |
| 19 #include "content/public/browser/gpu_data_manager.h" | 20 #include "content/public/browser/gpu_data_manager.h" |
| 20 #include "content/public/common/gpu_info.h" | 21 #include "content/public/common/gpu_info.h" |
| 22 #include "googleurl/src/gurl.h" |
| 23 #include "gpu/command_buffer/common/constants.h" |
| 21 #include "ipc/ipc_channel_proxy.h" | 24 #include "ipc/ipc_channel_proxy.h" |
| 22 #include "ipc/ipc_sender.h" | 25 #include "ipc/ipc_sender.h" |
| 23 #include "ui/gfx/native_widget_types.h" | 26 #include "ui/gfx/native_widget_types.h" |
| 24 #include "ui/gfx/size.h" | 27 #include "ui/gfx/size.h" |
| 25 | 28 |
| 26 struct GPUCreateCommandBufferConfig; | 29 struct GPUCreateCommandBufferConfig; |
| 27 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; | 30 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; |
| 28 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; | 31 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; |
| 29 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; | 32 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; |
| 30 | 33 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 137 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| 135 virtual void OnProcessLaunched() OVERRIDE; | 138 virtual void OnProcessLaunched() OVERRIDE; |
| 136 virtual void OnProcessCrashed(int exit_code) OVERRIDE; | 139 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
| 137 | 140 |
| 138 // Message handlers. | 141 // Message handlers. |
| 139 void OnInitialized(bool result); | 142 void OnInitialized(bool result); |
| 140 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 143 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
| 141 void OnCommandBufferCreated(const int32 route_id); | 144 void OnCommandBufferCreated(const int32 route_id); |
| 142 void OnDestroyCommandBuffer(int32 surface_id); | 145 void OnDestroyCommandBuffer(int32 surface_id); |
| 143 void OnImageCreated(const gfx::Size size); | 146 void OnImageCreated(const gfx::Size size); |
| 144 | 147 void OnDidCreateOffscreenContext(const GURL& url); |
| 148 void OnDidLoseContext(bool offscreen, |
| 149 gpu::error::ContextLostReason reason, |
| 150 const GURL& url); |
| 151 void OnDidDestroyOffscreenContext(const GURL& url); |
| 145 #if defined(OS_MACOSX) | 152 #if defined(OS_MACOSX) |
| 146 void OnAcceleratedSurfaceBuffersSwapped( | 153 void OnAcceleratedSurfaceBuffersSwapped( |
| 147 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); | 154 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); |
| 148 #endif | 155 #endif |
| 149 // Note: Different implementations depending on USE_AURA. | 156 // Note: Different implementations depending on USE_AURA. |
| 150 #if defined(OS_WIN) | 157 #if defined(OS_WIN) |
| 151 void OnAcceleratedSurfaceBuffersSwapped( | 158 void OnAcceleratedSurfaceBuffersSwapped( |
| 152 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); | 159 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); |
| 153 void OnAcceleratedSurfacePostSubBuffer( | 160 void OnAcceleratedSurfacePostSubBuffer( |
| 154 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params); | 161 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params); |
| 155 void OnAcceleratedSurfaceSuspend(int32 surface_id); | 162 void OnAcceleratedSurfaceSuspend(int32 surface_id); |
| 156 void OnAcceleratedSurfaceRelease( | 163 void OnAcceleratedSurfaceRelease( |
| 157 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params); | 164 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params); |
| 158 #endif | 165 #endif |
| 159 | 166 |
| 160 bool LaunchGpuProcess(const std::string& channel_id); | 167 bool LaunchGpuProcess(const std::string& channel_id); |
| 161 | 168 |
| 162 void SendOutstandingReplies(); | 169 void SendOutstandingReplies(); |
| 163 void EstablishChannelError( | 170 void EstablishChannelError( |
| 164 const EstablishChannelCallback& callback, | 171 const EstablishChannelCallback& callback, |
| 165 const IPC::ChannelHandle& channel_handle, | 172 const IPC::ChannelHandle& channel_handle, |
| 166 base::ProcessHandle client_process_for_gpu, | 173 base::ProcessHandle client_process_for_gpu, |
| 167 const GPUInfo& gpu_info); | 174 const GPUInfo& gpu_info); |
| 168 void CreateCommandBufferError(const CreateCommandBufferCallback& callback, | 175 void CreateCommandBufferError(const CreateCommandBufferCallback& callback, |
| 169 int32 route_id); | 176 int32 route_id); |
| 170 void CreateImageError(const CreateImageCallback& callback, | 177 void CreateImageError(const CreateImageCallback& callback, |
| 171 const gfx::Size size); | 178 const gfx::Size size); |
| 172 | 179 |
| 180 void BlockLiveOffscreenContexts(); |
| 181 |
| 173 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. | 182 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. |
| 174 int host_id_; | 183 int host_id_; |
| 175 | 184 |
| 176 // These are the channel requests that we have already sent to | 185 // These are the channel requests that we have already sent to |
| 177 // the GPU process, but haven't heard back about yet. | 186 // the GPU process, but haven't heard back about yet. |
| 178 std::queue<EstablishChannelCallback> channel_requests_; | 187 std::queue<EstablishChannelCallback> channel_requests_; |
| 179 | 188 |
| 180 // The pending create command buffer requests we need to reply to. | 189 // The pending create command buffer requests we need to reply to. |
| 181 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; | 190 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; |
| 182 | 191 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 228 |
| 220 // Master switch for enabling/disabling GPU acceleration for the current | 229 // Master switch for enabling/disabling GPU acceleration for the current |
| 221 // browser session. It does not change the acceleration settings for | 230 // browser session. It does not change the acceleration settings for |
| 222 // existing tabs, just the future ones. | 231 // existing tabs, just the future ones. |
| 223 static bool gpu_enabled_; | 232 static bool gpu_enabled_; |
| 224 | 233 |
| 225 static bool hardware_gpu_enabled_; | 234 static bool hardware_gpu_enabled_; |
| 226 | 235 |
| 227 scoped_ptr<BrowserChildProcessHostImpl> process_; | 236 scoped_ptr<BrowserChildProcessHostImpl> process_; |
| 228 | 237 |
| 238 // Track the URLs of the pages which have live offscreen contexts, |
| 239 // assumed to be associated with untrusted content such as WebGL. |
| 240 // For best robustness, when any context lost notification is |
| 241 // received, assume all of these URLs are guilty, and block |
| 242 // automatic execution of 3D content from those domains. |
| 243 std::multiset<GURL> urls_with_live_offscreen_contexts_; |
| 244 |
| 229 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 245 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 230 }; | 246 }; |
| 231 | 247 |
| 232 } // namespace content | 248 } // namespace content |
| 233 | 249 |
| 234 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 250 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| OLD | NEW |