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 #include "content/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 ChildProcess::current()->io_message_loop_proxy(), | 152 ChildProcess::current()->io_message_loop_proxy(), |
153 ChildProcess::current()->GetShutDownEvent())); | 153 ChildProcess::current()->GetShutDownEvent())); |
154 | 154 |
155 // Ensure the browser process receives the GPU info before a reply to any | 155 // Ensure the browser process receives the GPU info before a reply to any |
156 // subsequent IPC it might send. | 156 // subsequent IPC it might send. |
157 if (!in_browser_process_) | 157 if (!in_browser_process_) |
158 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); | 158 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); |
159 } | 159 } |
160 | 160 |
161 void GpuChildThread::StopWatchdog() { | 161 void GpuChildThread::StopWatchdog() { |
162 if (watchdog_thread_.get()) { | 162 if (watchdog_thread_) { |
163 watchdog_thread_->Stop(); | 163 watchdog_thread_->Stop(); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 void GpuChildThread::OnCollectGraphicsInfo() { | 167 void GpuChildThread::OnCollectGraphicsInfo() { |
168 #if defined(OS_WIN) | 168 #if defined(OS_WIN) |
169 // GPU full info collection should only happen on un-sandboxed GPU process | 169 // GPU full info collection should only happen on un-sandboxed GPU process |
170 // or single process/in-process gpu mode on Windows. | 170 // or single process/in-process gpu mode on Windows. |
171 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 171 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
172 DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || | 172 DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || |
(...skipping 17 matching lines...) Expand all Loading... |
190 #if defined(OS_WIN) | 190 #if defined(OS_WIN) |
191 if (!in_browser_process_) { | 191 if (!in_browser_process_) { |
192 // The unsandboxed GPU process fulfilled its duty. Rest in peace. | 192 // The unsandboxed GPU process fulfilled its duty. Rest in peace. |
193 MessageLoop::current()->Quit(); | 193 MessageLoop::current()->Quit(); |
194 } | 194 } |
195 #endif // OS_WIN | 195 #endif // OS_WIN |
196 } | 196 } |
197 | 197 |
198 void GpuChildThread::OnGetVideoMemoryUsageStats() { | 198 void GpuChildThread::OnGetVideoMemoryUsageStats() { |
199 GPUVideoMemoryUsageStats video_memory_usage_stats; | 199 GPUVideoMemoryUsageStats video_memory_usage_stats; |
200 if (gpu_channel_manager_.get()) | 200 if (gpu_channel_manager_) |
201 gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( | 201 gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( |
202 &video_memory_usage_stats); | 202 &video_memory_usage_stats); |
203 Send(new GpuHostMsg_VideoMemoryUsageStats(video_memory_usage_stats)); | 203 Send(new GpuHostMsg_VideoMemoryUsageStats(video_memory_usage_stats)); |
204 } | 204 } |
205 | 205 |
206 void GpuChildThread::OnClean() { | 206 void GpuChildThread::OnClean() { |
207 VLOG(1) << "GPU: Removing all contexts"; | 207 VLOG(1) << "GPU: Removing all contexts"; |
208 if (gpu_channel_manager_.get()) | 208 if (gpu_channel_manager_) |
209 gpu_channel_manager_->LoseAllContexts(); | 209 gpu_channel_manager_->LoseAllContexts(); |
210 } | 210 } |
211 | 211 |
212 void GpuChildThread::OnCrash() { | 212 void GpuChildThread::OnCrash() { |
213 VLOG(1) << "GPU: Simulating GPU crash"; | 213 VLOG(1) << "GPU: Simulating GPU crash"; |
214 // Good bye, cruel world. | 214 // Good bye, cruel world. |
215 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; | 215 volatile int* it_s_the_end_of_the_world_as_we_know_it = NULL; |
216 *it_s_the_end_of_the_world_as_we_know_it = 0xdead; | 216 *it_s_the_end_of_the_world_as_we_know_it = 0xdead; |
217 } | 217 } |
218 | 218 |
219 void GpuChildThread::OnHang() { | 219 void GpuChildThread::OnHang() { |
220 VLOG(1) << "GPU: Simulating GPU hang"; | 220 VLOG(1) << "GPU: Simulating GPU hang"; |
221 for (;;) { | 221 for (;;) { |
222 // Do not sleep here. The GPU watchdog timer tracks the amount of user | 222 // Do not sleep here. The GPU watchdog timer tracks the amount of user |
223 // time this thread is using and it doesn't use much while calling Sleep. | 223 // time this thread is using and it doesn't use much while calling Sleep. |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 void GpuChildThread::OnDisableWatchdog() { | 227 void GpuChildThread::OnDisableWatchdog() { |
228 VLOG(1) << "GPU: Disabling watchdog thread"; | 228 VLOG(1) << "GPU: Disabling watchdog thread"; |
229 if (watchdog_thread_.get()) { | 229 if (watchdog_thread_) { |
230 // Disarm the watchdog before shutting down the message loop. This prevents | 230 // Disarm the watchdog before shutting down the message loop. This prevents |
231 // the future posting of tasks to the message loop. | 231 // the future posting of tasks to the message loop. |
232 if (watchdog_thread_->message_loop()) | 232 if (watchdog_thread_->message_loop()) |
233 watchdog_thread_->PostAcknowledge(); | 233 watchdog_thread_->PostAcknowledge(); |
234 // Prevent rearming. | 234 // Prevent rearming. |
235 watchdog_thread_->Stop(); | 235 watchdog_thread_->Stop(); |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 } // namespace content | 239 } // namespace content |
240 | 240 |
OLD | NEW |