| 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 <set> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> | 61 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> |
| 62 EstablishChannelCallback; | 62 EstablishChannelCallback; |
| 63 | 63 |
| 64 typedef base::Callback<void(CreateCommandBufferResult)> | 64 typedef base::Callback<void(CreateCommandBufferResult)> |
| 65 CreateCommandBufferCallback; | 65 CreateCommandBufferCallback; |
| 66 | 66 |
| 67 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> | 67 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> |
| 68 CreateGpuMemoryBufferCallback; | 68 CreateGpuMemoryBufferCallback; |
| 69 | 69 |
| 70 static bool gpu_enabled() { return gpu_enabled_; } | 70 static bool gpu_enabled() { return gpu_enabled_; } |
| 71 static int gpu_crash_count() { return gpu_crash_count_; } |
| 71 | 72 |
| 72 // Creates a new GpuProcessHost or gets an existing one, resulting in the | 73 // Creates a new GpuProcessHost or gets an existing one, resulting in the |
| 73 // launching of a GPU process if required. Returns null on failure. It | 74 // launching of a GPU process if required. Returns null on failure. It |
| 74 // is not safe to store the pointer once control has returned to the message | 75 // is not safe to store the pointer once control has returned to the message |
| 75 // loop as it can be destroyed. Instead store the associated GPU host ID. | 76 // loop as it can be destroyed. Instead store the associated GPU host ID. |
| 76 // This could return NULL if GPU access is not allowed (blacklisted). | 77 // This could return NULL if GPU access is not allowed (blacklisted). |
| 77 CONTENT_EXPORT static GpuProcessHost* Get(GpuProcessKind kind, | 78 CONTENT_EXPORT static GpuProcessHost* Get(GpuProcessKind kind, |
| 78 CauseForGpuLaunch cause); | 79 CauseForGpuLaunch cause); |
| 79 | 80 |
| 80 // Retrieves a list of process handles for all gpu processes. | 81 // Retrieves a list of process handles for all gpu processes. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 void OnDestroyChannel(int32 client_id); | 181 void OnDestroyChannel(int32 client_id); |
| 181 void OnCacheShader(int32 client_id, const std::string& key, | 182 void OnCacheShader(int32 client_id, const std::string& key, |
| 182 const std::string& shader); | 183 const std::string& shader); |
| 183 | 184 |
| 184 bool LaunchGpuProcess(const std::string& channel_id); | 185 bool LaunchGpuProcess(const std::string& channel_id); |
| 185 | 186 |
| 186 void SendOutstandingReplies(); | 187 void SendOutstandingReplies(); |
| 187 | 188 |
| 188 void BlockLiveOffscreenContexts(); | 189 void BlockLiveOffscreenContexts(); |
| 189 | 190 |
| 191 // Update GPU crash counters. Disable GPU if crash limit is reached. |
| 192 void RecordProcessCrash(); |
| 193 |
| 190 std::string GetShaderPrefixKey(); | 194 std::string GetShaderPrefixKey(); |
| 191 | 195 |
| 192 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. | 196 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. |
| 193 int host_id_; | 197 int host_id_; |
| 194 | 198 |
| 195 // These are the channel requests that we have already sent to | 199 // These are the channel requests that we have already sent to |
| 196 // the GPU process, but haven't heard back about yet. | 200 // the GPU process, but haven't heard back about yet. |
| 197 std::queue<EstablishChannelCallback> channel_requests_; | 201 std::queue<EstablishChannelCallback> channel_requests_; |
| 198 | 202 |
| 199 // The pending create command buffer requests we need to reply to. | 203 // The pending create command buffer requests we need to reply to. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 219 | 223 |
| 220 // Whether we actually launched a GPU process. | 224 // Whether we actually launched a GPU process. |
| 221 bool process_launched_; | 225 bool process_launched_; |
| 222 | 226 |
| 223 // Whether the GPU process successfully initialized. | 227 // Whether the GPU process successfully initialized. |
| 224 bool initialized_; | 228 bool initialized_; |
| 225 | 229 |
| 226 // Time Init started. Used to log total GPU process startup time to UMA. | 230 // Time Init started. Used to log total GPU process startup time to UMA. |
| 227 base::TimeTicks init_start_time_; | 231 base::TimeTicks init_start_time_; |
| 228 | 232 |
| 233 // Whether this host recorded a GPU crash or not. |
| 234 bool gpu_crash_recorded_; |
| 235 |
| 229 // Master switch for enabling/disabling GPU acceleration for the current | 236 // Master switch for enabling/disabling GPU acceleration for the current |
| 230 // browser session. It does not change the acceleration settings for | 237 // browser session. It does not change the acceleration settings for |
| 231 // existing tabs, just the future ones. | 238 // existing tabs, just the future ones. |
| 232 static bool gpu_enabled_; | 239 static bool gpu_enabled_; |
| 233 | 240 |
| 234 static bool hardware_gpu_enabled_; | 241 static bool hardware_gpu_enabled_; |
| 235 | 242 |
| 243 static int gpu_crash_count_; |
| 244 static int gpu_recent_crash_count_; |
| 245 static bool crashed_before_; |
| 246 static int swiftshader_crash_count_; |
| 247 |
| 236 scoped_ptr<BrowserChildProcessHostImpl> process_; | 248 scoped_ptr<BrowserChildProcessHostImpl> process_; |
| 237 | 249 |
| 238 // Track the URLs of the pages which have live offscreen contexts, | 250 // Track the URLs of the pages which have live offscreen contexts, |
| 239 // assumed to be associated with untrusted content such as WebGL. | 251 // assumed to be associated with untrusted content such as WebGL. |
| 240 // For best robustness, when any context lost notification is | 252 // For best robustness, when any context lost notification is |
| 241 // received, assume all of these URLs are guilty, and block | 253 // received, assume all of these URLs are guilty, and block |
| 242 // automatic execution of 3D content from those domains. | 254 // automatic execution of 3D content from those domains. |
| 243 std::multiset<GURL> urls_with_live_offscreen_contexts_; | 255 std::multiset<GURL> urls_with_live_offscreen_contexts_; |
| 244 | 256 |
| 245 // Statics kept around to send to UMA histograms on GPU process lost. | 257 // Statics kept around to send to UMA histograms on GPU process lost. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 265 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > | 277 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > |
| 266 SurfaceRefMap; | 278 SurfaceRefMap; |
| 267 SurfaceRefMap surface_refs_; | 279 SurfaceRefMap surface_refs_; |
| 268 | 280 |
| 269 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 281 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 270 }; | 282 }; |
| 271 | 283 |
| 272 } // namespace content | 284 } // namespace content |
| 273 | 285 |
| 274 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 286 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| OLD | NEW |