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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
6 #include <windows.h> | 6 #include <windows.h> |
7 #endif | 7 #endif |
8 | 8 |
9 #include "content/gpu/gpu_watchdog_thread.h" | 9 #include "content/gpu/gpu_watchdog_thread.h" |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/process_util.h" | 15 #include "base/process_util.h" |
16 #include "base/process.h" | 16 #include "base/process.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
19 #include "content/public/common/result_codes.h" | 19 #include "content/public/common/result_codes.h" |
20 | 20 |
| 21 namespace content { |
21 namespace { | 22 namespace { |
22 const int64 kCheckPeriodMs = 2000; | 23 const int64 kCheckPeriodMs = 2000; |
23 } // namespace | 24 } // namespace |
24 | 25 |
25 GpuWatchdogThread::GpuWatchdogThread(int timeout) | 26 GpuWatchdogThread::GpuWatchdogThread(int timeout) |
26 : base::Thread("Watchdog"), | 27 : base::Thread("Watchdog"), |
27 watched_message_loop_(MessageLoop::current()), | 28 watched_message_loop_(MessageLoop::current()), |
28 timeout_(base::TimeDelta::FromMilliseconds(timeout)), | 29 timeout_(base::TimeDelta::FromMilliseconds(timeout)), |
29 armed_(false), | 30 armed_(false), |
30 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 #endif | 199 #endif |
199 | 200 |
200 LOG(ERROR) << "The GPU process hung. Terminating after " | 201 LOG(ERROR) << "The GPU process hung. Terminating after " |
201 << timeout_.InMilliseconds() << " ms."; | 202 << timeout_.InMilliseconds() << " ms."; |
202 | 203 |
203 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kCrashOnGpuHang)) { | 204 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kCrashOnGpuHang)) { |
204 // Deliberately crash the process to create a crash dump. | 205 // Deliberately crash the process to create a crash dump. |
205 *((volatile int*)0) = 0x1337; | 206 *((volatile int*)0) = 0x1337; |
206 } else { | 207 } else { |
207 base::Process current_process(base::GetCurrentProcessHandle()); | 208 base::Process current_process(base::GetCurrentProcessHandle()); |
208 current_process.Terminate(content::RESULT_CODE_HUNG); | 209 current_process.Terminate(RESULT_CODE_HUNG); |
209 } | 210 } |
210 | 211 |
211 terminated = true; | 212 terminated = true; |
212 } | 213 } |
213 | 214 |
214 #if defined(OS_WIN) | 215 #if defined(OS_WIN) |
215 base::TimeDelta GpuWatchdogThread::GetWatchedThreadTime() { | 216 base::TimeDelta GpuWatchdogThread::GetWatchedThreadTime() { |
216 FILETIME creation_time; | 217 FILETIME creation_time; |
217 FILETIME exit_time; | 218 FILETIME exit_time; |
218 FILETIME user_time; | 219 FILETIME user_time; |
(...skipping 17 matching lines...) Expand all Loading... |
236 // summed to deal with to kinds of hangs. One is where the GPU process is | 237 // summed to deal with to kinds of hangs. One is where the GPU process is |
237 // stuck in user level, never calling into the kernel and kernel time is | 238 // stuck in user level, never calling into the kernel and kernel time is |
238 // not increasing. The other is where either the kernel hangs and never | 239 // not increasing. The other is where either the kernel hangs and never |
239 // returns to user level or where user level code | 240 // returns to user level or where user level code |
240 // calls into kernel level repeatedly, giving up its quanta before it is | 241 // calls into kernel level repeatedly, giving up its quanta before it is |
241 // tracked, for example a loop that repeatedly Sleeps. | 242 // tracked, for example a loop that repeatedly Sleeps. |
242 return base::TimeDelta::FromMilliseconds(static_cast<int64>( | 243 return base::TimeDelta::FromMilliseconds(static_cast<int64>( |
243 (user_time64.QuadPart + kernel_time64.QuadPart) / 10000)); | 244 (user_time64.QuadPart + kernel_time64.QuadPart) / 10000)); |
244 } | 245 } |
245 #endif | 246 #endif |
| 247 |
| 248 } // namespace content |
OLD | NEW |