| 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 <stdint.h> |
| 9 |
| 8 #include <map> | 10 #include <map> |
| 9 #include <queue> | 11 #include <queue> |
| 10 #include <set> | 12 #include <set> |
| 11 #include <string> | 13 #include <string> |
| 12 | 14 |
| 13 #include "base/callback.h" | 15 #include "base/callback.h" |
| 14 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
| 17 #include "base/macros.h" |
| 15 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 16 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "build/build_config.h" |
| 18 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 19 #include "content/common/gpu/gpu_memory_uma_stats.h" | 23 #include "content/common/gpu/gpu_memory_uma_stats.h" |
| 20 #include "content/common/gpu/gpu_process_launch_causes.h" | 24 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 21 #include "content/common/gpu/gpu_result_codes.h" | 25 #include "content/common/gpu/gpu_result_codes.h" |
| 22 #include "content/public/browser/browser_child_process_host_delegate.h" | 26 #include "content/public/browser/browser_child_process_host_delegate.h" |
| 23 #include "content/public/browser/gpu_data_manager.h" | 27 #include "content/public/browser/gpu_data_manager.h" |
| 24 #include "gpu/command_buffer/common/constants.h" | 28 #include "gpu/command_buffer/common/constants.h" |
| 25 #include "gpu/config/gpu_info.h" | 29 #include "gpu/config/gpu_info.h" |
| 26 #include "ipc/ipc_sender.h" | 30 #include "ipc/ipc_sender.h" |
| 27 #include "ipc/message_filter.h" | 31 #include "ipc/message_filter.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 const GPUCreateCommandBufferConfig& init_params, | 133 const GPUCreateCommandBufferConfig& init_params, |
| 130 int route_id, | 134 int route_id, |
| 131 const CreateCommandBufferCallback& callback); | 135 const CreateCommandBufferCallback& callback); |
| 132 | 136 |
| 133 // Tells the GPU process to create a new GPU memory buffer. | 137 // Tells the GPU process to create a new GPU memory buffer. |
| 134 void CreateGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 138 void CreateGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| 135 const gfx::Size& size, | 139 const gfx::Size& size, |
| 136 gfx::BufferFormat format, | 140 gfx::BufferFormat format, |
| 137 gfx::BufferUsage usage, | 141 gfx::BufferUsage usage, |
| 138 int client_id, | 142 int client_id, |
| 139 int32 surface_id, | 143 int32_t surface_id, |
| 140 const CreateGpuMemoryBufferCallback& callback); | 144 const CreateGpuMemoryBufferCallback& callback); |
| 141 | 145 |
| 142 // Tells the GPU process to create a new GPU memory buffer from an existing | 146 // Tells the GPU process to create a new GPU memory buffer from an existing |
| 143 // handle. | 147 // handle. |
| 144 void CreateGpuMemoryBufferFromHandle( | 148 void CreateGpuMemoryBufferFromHandle( |
| 145 const gfx::GpuMemoryBufferHandle& handle, | 149 const gfx::GpuMemoryBufferHandle& handle, |
| 146 gfx::GpuMemoryBufferId id, | 150 gfx::GpuMemoryBufferId id, |
| 147 const gfx::Size& size, | 151 const gfx::Size& size, |
| 148 gfx::BufferFormat format, | 152 gfx::BufferFormat format, |
| 149 int client_id, | 153 int client_id, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 178 bool Init(); | 182 bool Init(); |
| 179 | 183 |
| 180 // Sets up mojo support in GPU process. Returns false upon failure. | 184 // Sets up mojo support in GPU process. Returns false upon failure. |
| 181 bool SetupMojo(); | 185 bool SetupMojo(); |
| 182 | 186 |
| 183 // Post an IPC message to the UI shim's message handler on the UI thread. | 187 // Post an IPC message to the UI shim's message handler on the UI thread. |
| 184 void RouteOnUIThread(const IPC::Message& message); | 188 void RouteOnUIThread(const IPC::Message& message); |
| 185 | 189 |
| 186 // BrowserChildProcessHostDelegate implementation. | 190 // BrowserChildProcessHostDelegate implementation. |
| 187 bool OnMessageReceived(const IPC::Message& message) override; | 191 bool OnMessageReceived(const IPC::Message& message) override; |
| 188 void OnChannelConnected(int32 peer_pid) override; | 192 void OnChannelConnected(int32_t peer_pid) override; |
| 189 void OnProcessLaunched() override; | 193 void OnProcessLaunched() override; |
| 190 void OnProcessLaunchFailed() override; | 194 void OnProcessLaunchFailed() override; |
| 191 void OnProcessCrashed(int exit_code) override; | 195 void OnProcessCrashed(int exit_code) override; |
| 192 ServiceRegistry* GetServiceRegistry() override; | 196 ServiceRegistry* GetServiceRegistry() override; |
| 193 | 197 |
| 194 // Message handlers. | 198 // Message handlers. |
| 195 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); | 199 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); |
| 196 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 200 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
| 197 void OnCommandBufferCreated(CreateCommandBufferResult result); | 201 void OnCommandBufferCreated(CreateCommandBufferResult result); |
| 198 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); | 202 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); |
| 199 void OnDidCreateOffscreenContext(const GURL& url); | 203 void OnDidCreateOffscreenContext(const GURL& url); |
| 200 void OnDidLoseContext(bool offscreen, | 204 void OnDidLoseContext(bool offscreen, |
| 201 gpu::error::ContextLostReason reason, | 205 gpu::error::ContextLostReason reason, |
| 202 const GURL& url); | 206 const GURL& url); |
| 203 void OnDidDestroyOffscreenContext(const GURL& url); | 207 void OnDidDestroyOffscreenContext(const GURL& url); |
| 204 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); | 208 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); |
| 205 #if defined(OS_MACOSX) | 209 #if defined(OS_MACOSX) |
| 206 void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message); | 210 void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message); |
| 207 #endif | 211 #endif |
| 208 | 212 |
| 209 void CreateChannelCache(int32 client_id); | 213 void CreateChannelCache(int32_t client_id); |
| 210 void OnDestroyChannel(int32 client_id); | 214 void OnDestroyChannel(int32_t client_id); |
| 211 void OnCacheShader(int32 client_id, const std::string& key, | 215 void OnCacheShader(int32_t client_id, |
| 216 const std::string& key, |
| 212 const std::string& shader); | 217 const std::string& shader); |
| 213 | 218 |
| 214 bool LaunchGpuProcess(const std::string& channel_id); | 219 bool LaunchGpuProcess(const std::string& channel_id); |
| 215 | 220 |
| 216 void SendOutstandingReplies(); | 221 void SendOutstandingReplies(); |
| 217 | 222 |
| 218 void BlockLiveOffscreenContexts(); | 223 void BlockLiveOffscreenContexts(); |
| 219 | 224 |
| 220 // Update GPU crash counters. Disable GPU if crash limit is reached. | 225 // Update GPU crash counters. Disable GPU if crash limit is reached. |
| 221 void RecordProcessCrash(); | 226 void RecordProcessCrash(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // assumed to be associated with untrusted content such as WebGL. | 282 // assumed to be associated with untrusted content such as WebGL. |
| 278 // For best robustness, when any context lost notification is | 283 // For best robustness, when any context lost notification is |
| 279 // received, assume all of these URLs are guilty, and block | 284 // received, assume all of these URLs are guilty, and block |
| 280 // automatic execution of 3D content from those domains. | 285 // automatic execution of 3D content from those domains. |
| 281 std::multiset<GURL> urls_with_live_offscreen_contexts_; | 286 std::multiset<GURL> urls_with_live_offscreen_contexts_; |
| 282 | 287 |
| 283 // Statics kept around to send to UMA histograms on GPU process lost. | 288 // Statics kept around to send to UMA histograms on GPU process lost. |
| 284 bool uma_memory_stats_received_; | 289 bool uma_memory_stats_received_; |
| 285 GPUMemoryUmaStats uma_memory_stats_; | 290 GPUMemoryUmaStats uma_memory_stats_; |
| 286 | 291 |
| 287 typedef std::map<int32, scoped_refptr<ShaderDiskCache> > | 292 typedef std::map<int32_t, scoped_refptr<ShaderDiskCache>> |
| 288 ClientIdToShaderCacheMap; | 293 ClientIdToShaderCacheMap; |
| 289 ClientIdToShaderCacheMap client_id_to_shader_cache_; | 294 ClientIdToShaderCacheMap client_id_to_shader_cache_; |
| 290 | 295 |
| 291 std::string shader_prefix_key_; | 296 std::string shader_prefix_key_; |
| 292 | 297 |
| 293 #if defined(OS_MACOSX) && !defined(OS_IOS) | 298 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 294 // Unique unguessable token that the GPU process is using to register | 299 // Unique unguessable token that the GPU process is using to register |
| 295 // IOSurfaces. | 300 // IOSurfaces. |
| 296 IOSurfaceManagerToken io_surface_manager_token_; | 301 IOSurfaceManagerToken io_surface_manager_token_; |
| 297 #endif | 302 #endif |
| 298 | 303 |
| 299 // Browser-side Mojo endpoint which sets up a Mojo channel with the child | 304 // Browser-side Mojo endpoint which sets up a Mojo channel with the child |
| 300 // process and contains the browser's ServiceRegistry. | 305 // process and contains the browser's ServiceRegistry. |
| 301 scoped_ptr<MojoApplicationHost> mojo_application_host_; | 306 scoped_ptr<MojoApplicationHost> mojo_application_host_; |
| 302 | 307 |
| 303 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 308 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 304 }; | 309 }; |
| 305 | 310 |
| 306 } // namespace content | 311 } // namespace content |
| 307 | 312 |
| 308 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 313 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| OLD | NEW |