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