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_watchdog_thread.h" | 5 #include "content/gpu/gpu_watchdog_thread.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 void GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang() { | 234 void GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang() { |
235 // Should not get here while the system is suspended. | 235 // Should not get here while the system is suspended. |
236 DCHECK(!suspended_); | 236 DCHECK(!suspended_); |
237 | 237 |
238 #if defined(OS_WIN) | 238 #if defined(OS_WIN) |
239 // Defer termination until a certain amount of CPU time has elapsed on the | 239 // Defer termination until a certain amount of CPU time has elapsed on the |
240 // watched thread. | 240 // watched thread. |
241 base::ThreadTicks current_cpu_time = GetWatchedThreadTime(); | 241 base::ThreadTicks current_cpu_time = GetWatchedThreadTime(); |
242 base::TimeDelta time_since_arm = current_cpu_time - arm_cpu_time_; | 242 base::TimeDelta time_since_arm = current_cpu_time - arm_cpu_time_; |
243 if (use_thread_cpu_time_ && (time_since_arm < timeout_)) { | 243 if (use_thread_cpu_time_ && (time_since_arm < timeout_)) { |
244 message_loop()->PostDelayedTask( | 244 task_runner()->PostDelayedTask( |
245 FROM_HERE, | 245 FROM_HERE, |
246 base::Bind( | 246 base::Bind(&GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang, |
247 &GpuWatchdogThread::DeliberatelyTerminateToRecoverFromHang, | 247 weak_factory_.GetWeakPtr()), |
248 weak_factory_.GetWeakPtr()), | |
249 timeout_ - time_since_arm); | 248 timeout_ - time_since_arm); |
250 return; | 249 return; |
251 } | 250 } |
252 #endif | 251 #endif |
253 | 252 |
254 // If the watchdog woke up significantly behind schedule, disarm and reset | 253 // If the watchdog woke up significantly behind schedule, disarm and reset |
255 // the watchdog check. This is to prevent the watchdog thread from terminating | 254 // the watchdog check. This is to prevent the watchdog thread from terminating |
256 // when a machine wakes up from sleep or hibernation, which would otherwise | 255 // when a machine wakes up from sleep or hibernation, which would otherwise |
257 // appear to be a hang. | 256 // appear to be a hang. |
258 if (base::Time::Now() > suspension_timeout_) { | 257 if (base::Time::Now() > suspension_timeout_) { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 int tty_number; | 463 int tty_number; |
465 size_t num_res = sscanf(tty_string, "tty%d\n", &tty_number); | 464 size_t num_res = sscanf(tty_string, "tty%d\n", &tty_number); |
466 if (num_res == 1) | 465 if (num_res == 1) |
467 return tty_number; | 466 return tty_number; |
468 } | 467 } |
469 return -1; | 468 return -1; |
470 } | 469 } |
471 #endif | 470 #endif |
472 | 471 |
473 } // namespace content | 472 } // namespace content |
OLD | NEW |