| 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 <queue> | 10 #include <queue> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "content/child/child_thread_impl.h" | 19 #include "content/child/child_thread_impl.h" |
| 20 #include "content/common/gpu/gpu_channel.h" | 20 #include "content/common/gpu/gpu_channel.h" |
| 21 #include "content/common/gpu/gpu_channel_manager.h" | 21 #include "content/common/gpu/gpu_channel_manager.h" |
| 22 #include "content/common/gpu/gpu_channel_manager_delegate.h" |
| 22 #include "content/common/gpu/gpu_config.h" | 23 #include "content/common/gpu/gpu_config.h" |
| 23 #include "content/common/gpu/x_util.h" | 24 #include "content/common/gpu/x_util.h" |
| 24 #include "content/common/process_control.mojom.h" | 25 #include "content/common/process_control.mojom.h" |
| 25 #include "gpu/config/gpu_info.h" | 26 #include "gpu/config/gpu_info.h" |
| 26 #include "mojo/public/cpp/bindings/interface_request.h" | 27 #include "mojo/public/cpp/bindings/interface_request.h" |
| 27 #include "mojo/public/cpp/bindings/weak_binding_set.h" | 28 #include "mojo/public/cpp/bindings/weak_binding_set.h" |
| 28 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
| 29 | 30 |
| 30 namespace gpu { | 31 namespace gpu { |
| 31 class SyncPointManager; | 32 class SyncPointManager; |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace sandbox { | 35 namespace sandbox { |
| 35 class TargetServices; | 36 class TargetServices; |
| 36 } | 37 } |
| 37 | 38 |
| 38 namespace content { | 39 namespace content { |
| 39 class GpuMemoryBufferFactory; | 40 class GpuMemoryBufferFactory; |
| 40 class GpuProcessControlImpl; | 41 class GpuProcessControlImpl; |
| 41 class GpuWatchdogThread; | 42 class GpuWatchdogThread; |
| 42 | 43 |
| 43 // The main thread of the GPU child process. There will only ever be one of | 44 // The main thread of the GPU child process. There will only ever be one of |
| 44 // these per process. It does process initialization and shutdown. It forwards | 45 // these per process. It does process initialization and shutdown. It forwards |
| 45 // IPC messages to GpuChannelManager, which is responsible for issuing rendering | 46 // IPC messages to GpuChannelManager, which is responsible for issuing rendering |
| 46 // commands to the GPU. | 47 // commands to the GPU. |
| 47 class GpuChildThread : public ChildThreadImpl { | 48 class GpuChildThread : public ChildThreadImpl, |
| 49 public GpuChannelManagerDelegate { |
| 48 public: | 50 public: |
| 49 typedef std::queue<IPC::Message*> DeferredMessages; | 51 typedef std::queue<IPC::Message*> DeferredMessages; |
| 50 | 52 |
| 51 GpuChildThread(GpuWatchdogThread* gpu_watchdog_thread, | 53 GpuChildThread(GpuWatchdogThread* gpu_watchdog_thread, |
| 52 bool dead_on_arrival, | 54 bool dead_on_arrival, |
| 53 const gpu::GPUInfo& gpu_info, | 55 const gpu::GPUInfo& gpu_info, |
| 54 const DeferredMessages& deferred_messages, | 56 const DeferredMessages& deferred_messages, |
| 55 GpuMemoryBufferFactory* gpu_memory_buffer_factory, | 57 GpuMemoryBufferFactory* gpu_memory_buffer_factory, |
| 56 gpu::SyncPointManager* sync_point_manager); | 58 gpu::SyncPointManager* sync_point_manager); |
| 57 | 59 |
| 58 GpuChildThread(const InProcessChildThreadParams& params, | 60 GpuChildThread(const InProcessChildThreadParams& params, |
| 59 GpuMemoryBufferFactory* gpu_memory_buffer_factory, | 61 GpuMemoryBufferFactory* gpu_memory_buffer_factory, |
| 60 gpu::SyncPointManager* sync_point_manager); | 62 gpu::SyncPointManager* sync_point_manager); |
| 61 | 63 |
| 62 ~GpuChildThread() override; | 64 ~GpuChildThread() override; |
| 63 | 65 |
| 64 void Shutdown() override; | 66 void Shutdown() override; |
| 65 | 67 |
| 66 void Init(const base::Time& process_start_time); | 68 void Init(const base::Time& process_start_time); |
| 67 void StopWatchdog(); | 69 void StopWatchdog(); |
| 68 | 70 |
| 69 // ChildThread overrides. | 71 // ChildThread overrides. |
| 70 bool Send(IPC::Message* msg) override; | 72 bool Send(IPC::Message* msg) override; |
| 71 bool OnControlMessageReceived(const IPC::Message& msg) override; | 73 bool OnControlMessageReceived(const IPC::Message& msg) override; |
| 72 bool OnMessageReceived(const IPC::Message& msg) override; | 74 bool OnMessageReceived(const IPC::Message& msg) override; |
| 73 | 75 |
| 74 private: | 76 private: |
| 77 // GpuChannelManagerDelegate implementation. |
| 78 void AddSubscription(int32_t client_id, unsigned int target) override; |
| 79 void CacheShader(int32_t client_id, |
| 80 const std::string& key, |
| 81 const std::string& shader) override; |
| 82 void ChannelEstablished(const IPC::ChannelHandle& channel_handle) override; |
| 83 void DestroyChannel(int client_id) override; |
| 84 void DidCreateOffscreenContext(const GURL& active_url) override; |
| 85 void DidDestroyOffscreenContext(const GURL& active_url) override; |
| 86 void DidLoseContext(bool offscreen, |
| 87 gpu::error::ContextLostReason reason, |
| 88 const GURL& active_url) override; |
| 89 void GpuMemoryUmaStats(const GPUMemoryUmaStats& params) override; |
| 90 void RemoveSubscription(int32_t client_id, unsigned int target) override; |
| 91 |
| 75 // Message handlers. | 92 // Message handlers. |
| 76 void OnInitialize(); | 93 void OnInitialize(); |
| 77 void OnFinalize(); | 94 void OnFinalize(); |
| 78 void OnCollectGraphicsInfo(); | 95 void OnCollectGraphicsInfo(); |
| 79 void OnGetVideoMemoryUsageStats(); | 96 void OnGetVideoMemoryUsageStats(); |
| 80 void OnSetVideoMemoryWindowCount(uint32_t window_count); | 97 void OnSetVideoMemoryWindowCount(uint32_t window_count); |
| 81 | 98 |
| 82 void OnClean(); | 99 void OnClean(); |
| 83 void OnCrash(); | 100 void OnCrash(); |
| 84 void OnHang(); | 101 void OnHang(); |
| 85 void OnDisableWatchdog(); | 102 void OnDisableWatchdog(); |
| 86 void OnGpuSwitched(); | 103 void OnGpuSwitched(); |
| 87 | 104 |
| 105 void OnEstablishChannel(const EstablishChannelParams& params); |
| 106 void OnCloseChannel(const IPC::ChannelHandle& channel_handle); |
| 107 void OnLoadedShader(const std::string& shader); |
| 108 void OnDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| 109 int client_id, |
| 110 const gpu::SyncToken& sync_token); |
| 111 void OnUpdateValueState(int client_id, |
| 112 unsigned int target, |
| 113 const gpu::ValueState& state); |
| 114 #if defined(OS_ANDROID) |
| 115 void OnWakeUpGpu(); |
| 116 #endif |
| 117 void OnLoseAllContexts(); |
| 118 |
| 88 void BindProcessControlRequest( | 119 void BindProcessControlRequest( |
| 89 mojo::InterfaceRequest<ProcessControl> request); | 120 mojo::InterfaceRequest<ProcessControl> request); |
| 90 | 121 |
| 91 // Set this flag to true if a fatal error occurred before we receive the | 122 // Set this flag to true if a fatal error occurred before we receive the |
| 92 // OnInitialize message, in which case we just declare ourselves DOA. | 123 // OnInitialize message, in which case we just declare ourselves DOA. |
| 93 bool dead_on_arrival_; | 124 bool dead_on_arrival_; |
| 94 base::Time process_start_time_; | 125 base::Time process_start_time_; |
| 95 scoped_refptr<GpuWatchdogThread> watchdog_thread_; | 126 scoped_refptr<GpuWatchdogThread> watchdog_thread_; |
| 96 | 127 |
| 97 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 121 | 152 |
| 122 // Bindings to the ProcessControl impl. | 153 // Bindings to the ProcessControl impl. |
| 123 mojo::WeakBindingSet<ProcessControl> process_control_bindings_; | 154 mojo::WeakBindingSet<ProcessControl> process_control_bindings_; |
| 124 | 155 |
| 125 DISALLOW_COPY_AND_ASSIGN(GpuChildThread); | 156 DISALLOW_COPY_AND_ASSIGN(GpuChildThread); |
| 126 }; | 157 }; |
| 127 | 158 |
| 128 } // namespace content | 159 } // namespace content |
| 129 | 160 |
| 130 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_ | 161 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_ |
| OLD | NEW |