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_GPU_GPU_CHILD_THREAD_H_ | 5 #ifndef CONTENT_GPU_GPU_CHILD_THREAD_H_ |
6 #define CONTENT_GPU_GPU_CHILD_THREAD_H_ | 6 #define CONTENT_GPU_GPU_CHILD_THREAD_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <queue> | 11 #include <queue> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/metrics/field_trial.h" | 18 #include "base/metrics/field_trial.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 #include "content/child/child_thread_impl.h" | 21 #include "content/child/child_thread_impl.h" |
22 #include "content/common/process_control.mojom.h" | |
23 #include "gpu/command_buffer/service/gpu_preferences.h" | 22 #include "gpu/command_buffer/service/gpu_preferences.h" |
24 #include "gpu/config/gpu_info.h" | 23 #include "gpu/config/gpu_info.h" |
25 #include "gpu/ipc/service/gpu_channel.h" | 24 #include "gpu/ipc/service/gpu_channel.h" |
26 #include "gpu/ipc/service/gpu_channel_manager.h" | 25 #include "gpu/ipc/service/gpu_channel_manager.h" |
27 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 26 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
28 #include "gpu/ipc/service/gpu_config.h" | 27 #include "gpu/ipc/service/gpu_config.h" |
29 #include "gpu/ipc/service/x_util.h" | 28 #include "gpu/ipc/service/x_util.h" |
30 #include "mojo/public/cpp/bindings/binding_set.h" | |
31 #include "mojo/public/cpp/bindings/interface_request.h" | |
32 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
33 | 30 |
34 namespace gpu { | 31 namespace gpu { |
35 class GpuMemoryBufferFactory; | 32 class GpuMemoryBufferFactory; |
36 class SyncPointManager; | 33 class SyncPointManager; |
37 } | 34 } |
38 | 35 |
39 namespace media { | 36 namespace media { |
40 class MediaService; | 37 class MediaService; |
41 } | 38 } |
42 | 39 |
43 namespace sandbox { | 40 namespace sandbox { |
44 class TargetServices; | 41 class TargetServices; |
45 } | 42 } |
46 | 43 |
47 namespace content { | 44 namespace content { |
48 class GpuProcessControlImpl; | |
49 class GpuWatchdogThread; | 45 class GpuWatchdogThread; |
50 struct EstablishChannelParams; | 46 struct EstablishChannelParams; |
51 | 47 |
52 // The main thread of the GPU child process. There will only ever be one of | 48 // The main thread of the GPU child process. There will only ever be one of |
53 // these per process. It does process initialization and shutdown. It forwards | 49 // these per process. It does process initialization and shutdown. It forwards |
54 // IPC messages to gpu::GpuChannelManager, which is responsible for issuing | 50 // IPC messages to gpu::GpuChannelManager, which is responsible for issuing |
55 // rendering commands to the GPU. | 51 // rendering commands to the GPU. |
56 class GpuChildThread : public ChildThreadImpl, | 52 class GpuChildThread : public ChildThreadImpl, |
57 public gpu::GpuChannelManagerDelegate, | 53 public gpu::GpuChannelManagerDelegate, |
58 public base::FieldTrialList::Observer { | 54 public base::FieldTrialList::Observer { |
(...skipping 18 matching lines...) Expand all Loading... |
77 | 73 |
78 void Shutdown() override; | 74 void Shutdown() override; |
79 | 75 |
80 void Init(const base::Time& process_start_time); | 76 void Init(const base::Time& process_start_time); |
81 void StopWatchdog(); | 77 void StopWatchdog(); |
82 | 78 |
83 gpu::GpuPreferences gpu_preferences() { return gpu_preferences_; } | 79 gpu::GpuPreferences gpu_preferences() { return gpu_preferences_; } |
84 | 80 |
85 private: | 81 private: |
86 // ChildThreadImpl:. | 82 // ChildThreadImpl:. |
| 83 void AddConnectionFilters(MojoShellConnection* connection) override; |
87 bool Send(IPC::Message* msg) override; | 84 bool Send(IPC::Message* msg) override; |
88 bool OnControlMessageReceived(const IPC::Message& msg) override; | 85 bool OnControlMessageReceived(const IPC::Message& msg) override; |
89 bool OnMessageReceived(const IPC::Message& msg) override; | 86 bool OnMessageReceived(const IPC::Message& msg) override; |
90 bool OnConnect(shell::Connection* connection) override; | |
91 shell::InterfaceRegistry* GetInterfaceRegistryForConnection() override; | |
92 shell::InterfaceProvider* GetInterfaceProviderForConnection() override; | |
93 | 87 |
94 // gpu::GpuChannelManagerDelegate: | 88 // gpu::GpuChannelManagerDelegate: |
95 void SetActiveURL(const GURL& url) override; | 89 void SetActiveURL(const GURL& url) override; |
96 void DidCreateOffscreenContext(const GURL& active_url) override; | 90 void DidCreateOffscreenContext(const GURL& active_url) override; |
97 void DidDestroyChannel(int client_id) override; | 91 void DidDestroyChannel(int client_id) override; |
98 void DidDestroyOffscreenContext(const GURL& active_url) override; | 92 void DidDestroyOffscreenContext(const GURL& active_url) override; |
99 void DidLoseContext(bool offscreen, | 93 void DidLoseContext(bool offscreen, |
100 gpu::error::ContextLostReason reason, | 94 gpu::error::ContextLostReason reason, |
101 const GURL& active_url) override; | 95 const GURL& active_url) override; |
102 void GpuMemoryUmaStats(const gpu::GPUMemoryUmaStats& params) override; | 96 void GpuMemoryUmaStats(const gpu::GPUMemoryUmaStats& params) override; |
(...skipping 28 matching lines...) Expand all Loading... |
131 void OnLoadedShader(const std::string& shader); | 125 void OnLoadedShader(const std::string& shader); |
132 void OnDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 126 void OnDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
133 int client_id, | 127 int client_id, |
134 const gpu::SyncToken& sync_token); | 128 const gpu::SyncToken& sync_token); |
135 #if defined(OS_ANDROID) | 129 #if defined(OS_ANDROID) |
136 void OnWakeUpGpu(); | 130 void OnWakeUpGpu(); |
137 void OnDestroyingVideoSurface(int surface_id); | 131 void OnDestroyingVideoSurface(int surface_id); |
138 #endif | 132 #endif |
139 void OnLoseAllContexts(); | 133 void OnLoseAllContexts(); |
140 | 134 |
141 void BindProcessControlRequest( | |
142 mojo::InterfaceRequest<mojom::ProcessControl> request); | |
143 | |
144 gpu::GpuPreferences gpu_preferences_; | 135 gpu::GpuPreferences gpu_preferences_; |
145 | 136 |
146 // Set this flag to true if a fatal error occurred before we receive the | 137 // Set this flag to true if a fatal error occurred before we receive the |
147 // OnInitialize message, in which case we just declare ourselves DOA. | 138 // OnInitialize message, in which case we just declare ourselves DOA. |
148 bool dead_on_arrival_; | 139 bool dead_on_arrival_; |
149 base::Time process_start_time_; | 140 base::Time process_start_time_; |
150 scoped_refptr<GpuWatchdogThread> watchdog_thread_; | 141 scoped_refptr<GpuWatchdogThread> watchdog_thread_; |
151 | 142 |
152 #if defined(OS_WIN) | 143 #if defined(OS_WIN) |
153 // Windows specific client sandbox interface. | 144 // Windows specific client sandbox interface. |
(...skipping 12 matching lines...) Expand all Loading... |
166 | 157 |
167 // Error messages collected in gpu_main() before the thread is created. | 158 // Error messages collected in gpu_main() before the thread is created. |
168 DeferredMessages deferred_messages_; | 159 DeferredMessages deferred_messages_; |
169 | 160 |
170 // Whether the GPU thread is running in the browser process. | 161 // Whether the GPU thread is running in the browser process. |
171 bool in_browser_process_; | 162 bool in_browser_process_; |
172 | 163 |
173 // The gpu::GpuMemoryBufferFactory instance used to allocate GpuMemoryBuffers. | 164 // The gpu::GpuMemoryBufferFactory instance used to allocate GpuMemoryBuffers. |
174 gpu::GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; | 165 gpu::GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; |
175 | 166 |
176 // Process control for Mojo application hosting. | |
177 std::unique_ptr<GpuProcessControlImpl> process_control_; | |
178 | |
179 // Bindings to the mojom::ProcessControl impl. | |
180 mojo::BindingSet<mojom::ProcessControl> process_control_bindings_; | |
181 | |
182 base::Closure resume_interface_bindings_callback_; | |
183 | |
184 DISALLOW_COPY_AND_ASSIGN(GpuChildThread); | 167 DISALLOW_COPY_AND_ASSIGN(GpuChildThread); |
185 }; | 168 }; |
186 | 169 |
187 } // namespace content | 170 } // namespace content |
188 | 171 |
189 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_ | 172 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_ |
OLD | NEW |