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/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/metrics/field_trial.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
19 #include "content/child/child_thread_impl.h" | 20 #include "content/child/child_thread_impl.h" |
20 #include "content/common/process_control.mojom.h" | 21 #include "content/common/process_control.mojom.h" |
21 #include "gpu/command_buffer/service/gpu_preferences.h" | 22 #include "gpu/command_buffer/service/gpu_preferences.h" |
22 #include "gpu/config/gpu_info.h" | 23 #include "gpu/config/gpu_info.h" |
23 #include "gpu/ipc/service/gpu_channel.h" | 24 #include "gpu/ipc/service/gpu_channel.h" |
24 #include "gpu/ipc/service/gpu_channel_manager.h" | 25 #include "gpu/ipc/service/gpu_channel_manager.h" |
25 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 26 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
26 #include "gpu/ipc/service/gpu_config.h" | 27 #include "gpu/ipc/service/gpu_config.h" |
(...skipping 18 matching lines...) Expand all Loading... |
45 namespace content { | 46 namespace content { |
46 class GpuProcessControlImpl; | 47 class GpuProcessControlImpl; |
47 class GpuWatchdogThread; | 48 class GpuWatchdogThread; |
48 struct EstablishChannelParams; | 49 struct EstablishChannelParams; |
49 | 50 |
50 // The main thread of the GPU child process. There will only ever be one of | 51 // The main thread of the GPU child process. There will only ever be one of |
51 // these per process. It does process initialization and shutdown. It forwards | 52 // these per process. It does process initialization and shutdown. It forwards |
52 // IPC messages to gpu::GpuChannelManager, which is responsible for issuing | 53 // IPC messages to gpu::GpuChannelManager, which is responsible for issuing |
53 // rendering commands to the GPU. | 54 // rendering commands to the GPU. |
54 class GpuChildThread : public ChildThreadImpl, | 55 class GpuChildThread : public ChildThreadImpl, |
55 public gpu::GpuChannelManagerDelegate { | 56 public gpu::GpuChannelManagerDelegate, |
| 57 public base::FieldTrialList::Observer { |
56 public: | 58 public: |
57 typedef std::queue<IPC::Message*> DeferredMessages; | 59 typedef std::queue<IPC::Message*> DeferredMessages; |
58 | 60 |
59 // Returns the one gpu thread for this process. Note that this can only | 61 // Returns the one gpu thread for this process. Note that this can only |
60 // be accessed when running on the gpu thread itself. | 62 // be accessed when running on the gpu thread itself. |
61 static GpuChildThread* current(); | 63 static GpuChildThread* current(); |
62 | 64 |
63 GpuChildThread(GpuWatchdogThread* gpu_watchdog_thread, | 65 GpuChildThread(GpuWatchdogThread* gpu_watchdog_thread, |
64 bool dead_on_arrival, | 66 bool dead_on_arrival, |
65 const gpu::GPUInfo& gpu_info, | 67 const gpu::GPUInfo& gpu_info, |
66 const DeferredMessages& deferred_messages, | 68 const DeferredMessages& deferred_messages, |
67 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory); | 69 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory); |
68 | 70 |
69 GpuChildThread(const gpu::GpuPreferences& gpu_preferences, | 71 GpuChildThread(const gpu::GpuPreferences& gpu_preferences, |
70 const InProcessChildThreadParams& params, | 72 const InProcessChildThreadParams& params, |
71 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory); | 73 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory); |
72 | 74 |
73 ~GpuChildThread() override; | 75 ~GpuChildThread() override; |
74 | 76 |
75 void Shutdown() override; | 77 void Shutdown() override; |
76 | 78 |
77 void Init(const base::Time& process_start_time); | 79 void Init(const base::Time& process_start_time); |
78 void StopWatchdog(); | 80 void StopWatchdog(); |
79 | 81 |
80 gpu::GpuPreferences gpu_preferences() { return gpu_preferences_; } | 82 gpu::GpuPreferences gpu_preferences() { return gpu_preferences_; } |
81 | 83 |
82 private: | 84 private: |
83 // ChildThread overrides. | 85 // ChildThreadImpl:. |
84 bool Send(IPC::Message* msg) override; | 86 bool Send(IPC::Message* msg) override; |
85 bool OnControlMessageReceived(const IPC::Message& msg) override; | 87 bool OnControlMessageReceived(const IPC::Message& msg) override; |
86 bool OnMessageReceived(const IPC::Message& msg) override; | 88 bool OnMessageReceived(const IPC::Message& msg) override; |
87 | 89 |
88 // gpu::GpuChannelManagerDelegate implementation. | 90 // gpu::GpuChannelManagerDelegate: |
89 void SetActiveURL(const GURL& url) override; | 91 void SetActiveURL(const GURL& url) override; |
90 void DidCreateOffscreenContext(const GURL& active_url) override; | 92 void DidCreateOffscreenContext(const GURL& active_url) override; |
91 void DidDestroyChannel(int client_id) override; | 93 void DidDestroyChannel(int client_id) override; |
92 void DidDestroyOffscreenContext(const GURL& active_url) override; | 94 void DidDestroyOffscreenContext(const GURL& active_url) override; |
93 void DidLoseContext(bool offscreen, | 95 void DidLoseContext(bool offscreen, |
94 gpu::error::ContextLostReason reason, | 96 gpu::error::ContextLostReason reason, |
95 const GURL& active_url) override; | 97 const GURL& active_url) override; |
96 void GpuMemoryUmaStats(const gpu::GPUMemoryUmaStats& params) override; | 98 void GpuMemoryUmaStats(const gpu::GPUMemoryUmaStats& params) override; |
97 #if defined(OS_WIN) | 99 #if defined(OS_WIN) |
98 void SendAcceleratedSurfaceCreatedChildWindow( | 100 void SendAcceleratedSurfaceCreatedChildWindow( |
99 gpu::SurfaceHandle parent_window, | 101 gpu::SurfaceHandle parent_window, |
100 gpu::SurfaceHandle child_window) override; | 102 gpu::SurfaceHandle child_window) override; |
101 #endif | 103 #endif |
102 void StoreShaderToDisk(int32_t client_id, | 104 void StoreShaderToDisk(int32_t client_id, |
103 const std::string& key, | 105 const std::string& key, |
104 const std::string& shader) override; | 106 const std::string& shader) override; |
105 | 107 |
| 108 // base::FieldTrialList::Observer: |
| 109 void OnFieldTrialGroupFinalized(const std::string& trial_name, |
| 110 const std::string& group_name) override; |
| 111 |
106 // Message handlers. | 112 // Message handlers. |
107 void OnInitialize(const gpu::GpuPreferences& gpu_preferences); | 113 void OnInitialize(const gpu::GpuPreferences& gpu_preferences); |
108 void OnFinalize(); | 114 void OnFinalize(); |
109 void OnCollectGraphicsInfo(); | 115 void OnCollectGraphicsInfo(); |
110 void OnGetVideoMemoryUsageStats(); | 116 void OnGetVideoMemoryUsageStats(); |
111 void OnSetVideoMemoryWindowCount(uint32_t window_count); | 117 void OnSetVideoMemoryWindowCount(uint32_t window_count); |
112 | 118 |
113 void OnClean(); | 119 void OnClean(); |
114 void OnCrash(); | 120 void OnCrash(); |
115 void OnHang(); | 121 void OnHang(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 174 |
169 // Bindings to the mojom::ProcessControl impl. | 175 // Bindings to the mojom::ProcessControl impl. |
170 mojo::BindingSet<mojom::ProcessControl> process_control_bindings_; | 176 mojo::BindingSet<mojom::ProcessControl> process_control_bindings_; |
171 | 177 |
172 DISALLOW_COPY_AND_ASSIGN(GpuChildThread); | 178 DISALLOW_COPY_AND_ASSIGN(GpuChildThread); |
173 }; | 179 }; |
174 | 180 |
175 } // namespace content | 181 } // namespace content |
176 | 182 |
177 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_ | 183 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_ |
OLD | NEW |