| 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> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 public: | 65 public: |
| 66 enum GpuProcessKind { | 66 enum GpuProcessKind { |
| 67 GPU_PROCESS_KIND_UNSANDBOXED, | 67 GPU_PROCESS_KIND_UNSANDBOXED, |
| 68 GPU_PROCESS_KIND_SANDBOXED, | 68 GPU_PROCESS_KIND_SANDBOXED, |
| 69 GPU_PROCESS_KIND_COUNT | 69 GPU_PROCESS_KIND_COUNT |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> | 72 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> |
| 73 EstablishChannelCallback; | 73 EstablishChannelCallback; |
| 74 | 74 |
| 75 struct EstablishChannelRequest { | |
| 76 EstablishChannelRequest(); | |
| 77 EstablishChannelRequest(const EstablishChannelRequest& other); | |
| 78 ~EstablishChannelRequest(); | |
| 79 int32_t client_id; | |
| 80 EstablishChannelCallback callback; | |
| 81 }; | |
| 82 | |
| 83 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> | 75 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> |
| 84 CreateGpuMemoryBufferCallback; | 76 CreateGpuMemoryBufferCallback; |
| 85 | 77 |
| 86 static bool gpu_enabled() { return gpu_enabled_; } | 78 static bool gpu_enabled() { return gpu_enabled_; } |
| 87 static int gpu_crash_count() { return gpu_crash_count_; } | 79 static int gpu_crash_count() { return gpu_crash_count_; } |
| 88 | 80 |
| 89 // Creates a new GpuProcessHost (if |force_create| is turned on) or gets an | 81 // Creates a new GpuProcessHost (if |force_create| is turned on) or gets an |
| 90 // existing one, resulting in the launching of a GPU process if required. | 82 // existing one, resulting in the launching of a GPU process if required. |
| 91 // Returns null on failure. It is not safe to store the pointer once control | 83 // Returns null on failure. It is not safe to store the pointer once control |
| 92 // has returned to the message loop as it can be destroyed. Instead store the | 84 // has returned to the message loop as it can be destroyed. Instead store the |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 void DidDestroyChannel(int32_t client_id) override; | 181 void DidDestroyChannel(int32_t client_id) override; |
| 190 void DidLoseContext(bool offscreen, | 182 void DidLoseContext(bool offscreen, |
| 191 gpu::error::ContextLostReason reason, | 183 gpu::error::ContextLostReason reason, |
| 192 const GURL& active_url) override; | 184 const GURL& active_url) override; |
| 193 void SetChildSurface(gpu::SurfaceHandle parent, | 185 void SetChildSurface(gpu::SurfaceHandle parent, |
| 194 gpu::SurfaceHandle child) override; | 186 gpu::SurfaceHandle child) override; |
| 195 void StoreShaderToDisk(int32_t client_id, | 187 void StoreShaderToDisk(int32_t client_id, |
| 196 const std::string& key, | 188 const std::string& key, |
| 197 const std::string& shader) override; | 189 const std::string& shader) override; |
| 198 | 190 |
| 191 void OnChannelEstablished(int client_id, |
| 192 const EstablishChannelCallback& callback, |
| 193 mojo::ScopedMessagePipeHandle channel_handle); |
| 194 |
| 199 // Message handlers. | 195 // Message handlers. |
| 200 void OnInitialized(bool result, | 196 void OnInitialized(bool result, |
| 201 const gpu::GPUInfo& gpu_info, | 197 const gpu::GPUInfo& gpu_info, |
| 202 const gpu::GpuFeatureInfo& gpu_feature_info); | 198 const gpu::GpuFeatureInfo& gpu_feature_info); |
| 203 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | |
| 204 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); | 199 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); |
| 205 #if defined(OS_ANDROID) | 200 #if defined(OS_ANDROID) |
| 206 void OnDestroyingVideoSurfaceAck(int surface_id); | 201 void OnDestroyingVideoSurfaceAck(int surface_id); |
| 207 #endif | 202 #endif |
| 208 void OnFieldTrialActivated(const std::string& trial_name); | 203 void OnFieldTrialActivated(const std::string& trial_name); |
| 209 | 204 |
| 210 void CreateChannelCache(int32_t client_id); | 205 void CreateChannelCache(int32_t client_id); |
| 211 | 206 |
| 212 bool LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences); | 207 bool LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences); |
| 213 | 208 |
| 214 void SendOutstandingReplies(); | 209 void SendOutstandingReplies(); |
| 215 | 210 |
| 216 void BlockLiveOffscreenContexts(); | 211 void BlockLiveOffscreenContexts(); |
| 217 | 212 |
| 218 // Update GPU crash counters. Disable GPU if crash limit is reached. | 213 // Update GPU crash counters. Disable GPU if crash limit is reached. |
| 219 void RecordProcessCrash(); | 214 void RecordProcessCrash(); |
| 220 | 215 |
| 221 std::string GetShaderPrefixKey(const std::string& shader); | 216 std::string GetShaderPrefixKey(const std::string& shader); |
| 222 | 217 |
| 223 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. | 218 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. |
| 224 int host_id_; | 219 int host_id_; |
| 225 | 220 |
| 226 // These are the channel requests that we have already sent to | 221 // These are the channel requests that we have already sent to |
| 227 // the GPU process, but haven't heard back about yet. | 222 // the GPU process, but haven't heard back about yet. |
| 228 std::queue<EstablishChannelRequest> channel_requests_; | 223 std::queue<EstablishChannelCallback> channel_requests_; |
| 229 | 224 |
| 230 // The pending create gpu memory buffer requests we need to reply to. | 225 // The pending create gpu memory buffer requests we need to reply to. |
| 231 std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_; | 226 std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_; |
| 232 | 227 |
| 233 // A callback to signal the completion of a SendDestroyingVideoSurface call. | 228 // A callback to signal the completion of a SendDestroyingVideoSurface call. |
| 234 base::Closure send_destroying_video_surface_done_cb_; | 229 base::Closure send_destroying_video_surface_done_cb_; |
| 235 | 230 |
| 236 // Qeueud messages to send when the process launches. | 231 // Qeueud messages to send when the process launches. |
| 237 std::queue<IPC::Message*> queued_messages_; | 232 std::queue<IPC::Message*> queued_messages_; |
| 238 | 233 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 typedef std::map<int32_t, scoped_refptr<gpu::ShaderDiskCache>> | 280 typedef std::map<int32_t, scoped_refptr<gpu::ShaderDiskCache>> |
| 286 ClientIdToShaderCacheMap; | 281 ClientIdToShaderCacheMap; |
| 287 ClientIdToShaderCacheMap client_id_to_shader_cache_; | 282 ClientIdToShaderCacheMap client_id_to_shader_cache_; |
| 288 | 283 |
| 289 std::string shader_prefix_key_info_; | 284 std::string shader_prefix_key_info_; |
| 290 | 285 |
| 291 ui::mojom::GpuMainAssociatedPtr gpu_main_ptr_; | 286 ui::mojom::GpuMainAssociatedPtr gpu_main_ptr_; |
| 292 ui::mojom::GpuServicePtr gpu_service_ptr_; | 287 ui::mojom::GpuServicePtr gpu_service_ptr_; |
| 293 mojo::Binding<ui::mojom::GpuHost> gpu_host_binding_; | 288 mojo::Binding<ui::mojom::GpuHost> gpu_host_binding_; |
| 294 | 289 |
| 290 base::WeakPtrFactory<GpuProcessHost> weak_ptr_factory_; |
| 291 |
| 295 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 292 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 296 }; | 293 }; |
| 297 | 294 |
| 298 } // namespace content | 295 } // namespace content |
| 299 | 296 |
| 300 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 297 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| OLD | NEW |