| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // The Watchdog class creates a second thread that can Alarm if a specific | 5 // The Watchdog class creates a second thread that can Alarm if a specific |
| 6 // duration of time passes without proper attention. The duration of time is | 6 // duration of time passes without proper attention. The duration of time is |
| 7 // specified at construction time. The Watchdog may be used many times by | 7 // specified at construction time. The Watchdog may be used many times by |
| 8 // simply calling Arm() (to start timing) and Disarm() (to reset the timer). | 8 // simply calling Arm() (to start timing) and Disarm() (to reset the timer). |
| 9 // The Watchdog is typically used under a debugger, where the stack traces on | 9 // The Watchdog is typically used under a debugger, where the stack traces on |
| 10 // other threads can be examined if/when the Watchdog alarms. | 10 // other threads can be examined if/when the Watchdog alarms. |
| 11 | 11 |
| 12 // Some watchdogs will be enabled or disabled via command line switches. To | 12 // Some watchdogs will be enabled or disabled via command line switches. To |
| 13 // facilitate such code, an "enabled" argument for the constuctor can be used | 13 // facilitate such code, an "enabled" argument for the constuctor can be used |
| 14 // to permanently disable the watchdog. Disabled watchdogs don't even spawn | 14 // to permanently disable the watchdog. Disabled watchdogs don't even spawn |
| 15 // a second thread, and their methods call (Arm() and Disarm()) return very | 15 // a second thread, and their methods call (Arm() and Disarm()) return very |
| 16 // quickly. | 16 // quickly. |
| 17 | 17 |
| 18 #ifndef BASE_WATCHDOG_H__ | 18 #ifndef BASE_WATCHDOG_H__ |
| 19 #define BASE_WATCHDOG_H__ | 19 #define BASE_WATCHDOG_H__ |
| 20 | 20 |
| 21 #include <string> | 21 #include <string> |
| 22 | 22 |
| 23 #include "base/condition_variable.h" | 23 #include "base/condition_variable.h" |
| 24 #include "base/lock.h" | 24 #include "base/lock.h" |
| 25 #include "base/logging.h" |
| 25 #include "base/platform_thread.h" | 26 #include "base/platform_thread.h" |
| 26 #include "base/time.h" | 27 #include "base/time.h" |
| 27 | 28 |
| 28 class Watchdog { | 29 class Watchdog { |
| 29 public: | 30 public: |
| 30 // Constructor specifies how long the Watchdog will wait before alarming. | 31 // Constructor specifies how long the Watchdog will wait before alarming. |
| 31 Watchdog(const base::TimeDelta& duration, | 32 Watchdog(const base::TimeDelta& duration, |
| 32 const std::string& thread_watched_name, | 33 const std::string& thread_watched_name, |
| 33 bool enabled); | 34 bool enabled); |
| 34 virtual ~Watchdog(); | 35 virtual ~Watchdog(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 static Lock static_lock_; // Lock for access of static data... | 83 static Lock static_lock_; // Lock for access of static data... |
| 83 // When did we last alarm and get stuck (for a while) in a debugger? | 84 // When did we last alarm and get stuck (for a while) in a debugger? |
| 84 static base::TimeTicks last_debugged_alarm_time_; | 85 static base::TimeTicks last_debugged_alarm_time_; |
| 85 // How long did we sit on a break in the debugger? | 86 // How long did we sit on a break in the debugger? |
| 86 static base::TimeDelta last_debugged_alarm_delay_; | 87 static base::TimeDelta last_debugged_alarm_delay_; |
| 87 | 88 |
| 88 DISALLOW_COPY_AND_ASSIGN(Watchdog); | 89 DISALLOW_COPY_AND_ASSIGN(Watchdog); |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 #endif // BASE_WATCHDOG_H__ | 92 #endif // BASE_WATCHDOG_H__ |
| OLD | NEW |