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> |
11 #include <queue> | 11 #include <queue> |
12 #include <set> | 12 #include <set> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/callback.h" | 15 #include "base/callback.h" |
16 #include "base/containers/hash_tables.h" | 16 #include "base/containers/hash_tables.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
22 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
23 #include "content/common/gpu/gpu_memory_uma_stats.h" | |
24 #include "content/common/gpu/gpu_process_launch_causes.h" | |
25 #include "content/public/browser/browser_child_process_host_delegate.h" | 23 #include "content/public/browser/browser_child_process_host_delegate.h" |
26 #include "content/public/browser/gpu_data_manager.h" | 24 #include "content/public/browser/gpu_data_manager.h" |
27 #include "gpu/command_buffer/common/constants.h" | 25 #include "gpu/command_buffer/common/constants.h" |
28 #include "gpu/config/gpu_info.h" | 26 #include "gpu/config/gpu_info.h" |
| 27 #include "gpu/ipc/common/gpu_memory_uma_stats.h" |
| 28 #include "gpu/ipc/common/gpu_process_launch_causes.h" |
29 #include "gpu/ipc/common/surface_handle.h" | 29 #include "gpu/ipc/common/surface_handle.h" |
30 #include "ipc/ipc_sender.h" | 30 #include "ipc/ipc_sender.h" |
31 #include "ipc/message_filter.h" | 31 #include "ipc/message_filter.h" |
32 #include "ui/gfx/geometry/size.h" | 32 #include "ui/gfx/geometry/size.h" |
33 #include "ui/gfx/gpu_memory_buffer.h" | 33 #include "ui/gfx/gpu_memory_buffer.h" |
34 #include "url/gurl.h" | 34 #include "url/gurl.h" |
35 | 35 |
36 struct GPUCreateCommandBufferConfig; | 36 struct GPUCreateCommandBufferConfig; |
37 | 37 |
38 namespace IPC { | 38 namespace IPC { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 static bool gpu_enabled() { return gpu_enabled_; } | 81 static bool gpu_enabled() { return gpu_enabled_; } |
82 static int gpu_crash_count() { return gpu_crash_count_; } | 82 static int gpu_crash_count() { return gpu_crash_count_; } |
83 | 83 |
84 // Creates a new GpuProcessHost or gets an existing one, resulting in the | 84 // Creates a new GpuProcessHost or gets an existing one, resulting in the |
85 // launching of a GPU process if required. Returns null on failure. It | 85 // launching of a GPU process if required. Returns null on failure. It |
86 // is not safe to store the pointer once control has returned to the message | 86 // is not safe to store the pointer once control has returned to the message |
87 // loop as it can be destroyed. Instead store the associated GPU host ID. | 87 // loop as it can be destroyed. Instead store the associated GPU host ID. |
88 // This could return NULL if GPU access is not allowed (blacklisted). | 88 // This could return NULL if GPU access is not allowed (blacklisted). |
89 CONTENT_EXPORT static GpuProcessHost* Get(GpuProcessKind kind, | 89 CONTENT_EXPORT static GpuProcessHost* Get(GpuProcessKind kind, |
90 CauseForGpuLaunch cause); | 90 gpu::CauseForGpuLaunch cause); |
91 | 91 |
92 // Retrieves a list of process handles for all gpu processes. | 92 // Retrieves a list of process handles for all gpu processes. |
93 static void GetProcessHandles( | 93 static void GetProcessHandles( |
94 const GpuDataManager::GetGpuProcessHandlesCallback& callback); | 94 const GpuDataManager::GetGpuProcessHandlesCallback& callback); |
95 | 95 |
96 // Helper function to send the given message to the GPU process on the IO | 96 // Helper function to send the given message to the GPU process on the IO |
97 // thread. Calls Get and if a host is returned, sends it. Can be called from | 97 // thread. Calls Get and if a host is returned, sends it. Can be called from |
98 // any thread. Deletes the message if it cannot be sent. | 98 // any thread. Deletes the message if it cannot be sent. |
99 CONTENT_EXPORT static void SendOnIO(GpuProcessKind kind, | 99 CONTENT_EXPORT static void SendOnIO(GpuProcessKind kind, |
100 CauseForGpuLaunch cause, | 100 gpu::CauseForGpuLaunch cause, |
101 IPC::Message* message); | 101 IPC::Message* message); |
102 | 102 |
103 CONTENT_EXPORT static void RegisterGpuMainThreadFactory( | 103 CONTENT_EXPORT static void RegisterGpuMainThreadFactory( |
104 GpuMainThreadFactoryFunction create); | 104 GpuMainThreadFactoryFunction create); |
105 | 105 |
106 // BrowserChildProcessHostDelegate implementation. | 106 // BrowserChildProcessHostDelegate implementation. |
107 ServiceRegistry* GetServiceRegistry() override; | 107 ServiceRegistry* GetServiceRegistry() override; |
108 | 108 |
109 // Get the GPU process host for the GPU process with the given ID. Returns | 109 // Get the GPU process host for the GPU process with the given ID. Returns |
110 // null if the process no longer exists. | 110 // null if the process no longer exists. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // Browser-side Mojo endpoint which sets up a Mojo channel with the child | 292 // Browser-side Mojo endpoint which sets up a Mojo channel with the child |
293 // process and contains the browser's ServiceRegistry. | 293 // process and contains the browser's ServiceRegistry. |
294 scoped_ptr<MojoApplicationHost> mojo_application_host_; | 294 scoped_ptr<MojoApplicationHost> mojo_application_host_; |
295 | 295 |
296 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 296 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
297 }; | 297 }; |
298 | 298 |
299 } // namespace content | 299 } // namespace content |
300 | 300 |
301 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 301 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
OLD | NEW |