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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (!in_browser_process_) | 137 if (!in_browser_process_) |
138 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 138 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
139 | 139 |
140 // Record initialization only after collecting the GPU info because that can | 140 // Record initialization only after collecting the GPU info because that can |
141 // take a significant amount of time. | 141 // take a significant amount of time. |
142 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; | 142 gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |
143 | 143 |
144 // Defer creation of the render thread. This is to prevent it from handling | 144 // Defer creation of the render thread. This is to prevent it from handling |
145 // IPC messages before the sandbox has been enabled and all other necessary | 145 // IPC messages before the sandbox has been enabled and all other necessary |
146 // initialization has succeeded. | 146 // initialization has succeeded. |
147 gpu_channel_manager_.reset(new GpuChannelManager( | 147 gpu_channel_manager_.reset( |
148 this, | 148 new GpuChannelManager(this, |
149 watchdog_thread_, | 149 watchdog_thread_.get(), |
150 ChildProcess::current()->io_message_loop_proxy(), | 150 ChildProcess::current()->io_message_loop_proxy(), |
151 ChildProcess::current()->GetShutDownEvent())); | 151 ChildProcess::current()->GetShutDownEvent())); |
152 | 152 |
153 // Ensure the browser process receives the GPU info before a reply to any | 153 // Ensure the browser process receives the GPU info before a reply to any |
154 // subsequent IPC it might send. | 154 // subsequent IPC it might send. |
155 if (!in_browser_process_) | 155 if (!in_browser_process_) |
156 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); | 156 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); |
157 } | 157 } |
158 | 158 |
159 void GpuChildThread::StopWatchdog() { | 159 void GpuChildThread::StopWatchdog() { |
160 if (watchdog_thread_) { | 160 if (watchdog_thread_.get()) { |
161 watchdog_thread_->Stop(); | 161 watchdog_thread_->Stop(); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 void GpuChildThread::OnCollectGraphicsInfo() { | 165 void GpuChildThread::OnCollectGraphicsInfo() { |
166 #if defined(OS_WIN) | 166 #if defined(OS_WIN) |
167 // GPU full info collection should only happen on un-sandboxed GPU process | 167 // GPU full info collection should only happen on un-sandboxed GPU process |
168 // or single process/in-process gpu mode on Windows. | 168 // or single process/in-process gpu mode on Windows. |
169 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 169 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
170 DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || | 170 DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 void GpuChildThread::OnHang() { | 217 void GpuChildThread::OnHang() { |
218 VLOG(1) << "GPU: Simulating GPU hang"; | 218 VLOG(1) << "GPU: Simulating GPU hang"; |
219 for (;;) { | 219 for (;;) { |
220 // Do not sleep here. The GPU watchdog timer tracks the amount of user | 220 // Do not sleep here. The GPU watchdog timer tracks the amount of user |
221 // time this thread is using and it doesn't use much while calling Sleep. | 221 // time this thread is using and it doesn't use much while calling Sleep. |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 void GpuChildThread::OnDisableWatchdog() { | 225 void GpuChildThread::OnDisableWatchdog() { |
226 VLOG(1) << "GPU: Disabling watchdog thread"; | 226 VLOG(1) << "GPU: Disabling watchdog thread"; |
227 if (watchdog_thread_) { | 227 if (watchdog_thread_.get()) { |
228 // Disarm the watchdog before shutting down the message loop. This prevents | 228 // Disarm the watchdog before shutting down the message loop. This prevents |
229 // the future posting of tasks to the message loop. | 229 // the future posting of tasks to the message loop. |
230 if (watchdog_thread_->message_loop()) | 230 if (watchdog_thread_->message_loop()) |
231 watchdog_thread_->PostAcknowledge(); | 231 watchdog_thread_->PostAcknowledge(); |
232 // Prevent rearming. | 232 // Prevent rearming. |
233 watchdog_thread_->Stop(); | 233 watchdog_thread_->Stop(); |
234 } | 234 } |
235 } | 235 } |
236 | 236 |
237 } // namespace content | 237 } // namespace content |
238 | 238 |
OLD | NEW |