| 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 #include "base/watchdog.h" | 5 #include "base/watchdog.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" |
| 8 #include "base/platform_thread.h" | 9 #include "base/platform_thread.h" |
| 9 | 10 |
| 10 using base::TimeDelta; | 11 using base::TimeDelta; |
| 11 using base::TimeTicks; | 12 using base::TimeTicks; |
| 12 | 13 |
| 13 //------------------------------------------------------------------------------ | 14 //------------------------------------------------------------------------------ |
| 14 // Public API methods. | 15 // Public API methods. |
| 15 | 16 |
| 16 // Start thread running in a Disarmed state. | 17 // Start thread running in a Disarmed state. |
| 17 Watchdog::Watchdog(const TimeDelta& duration, | 18 Watchdog::Watchdog(const TimeDelta& duration, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 66 } |
| 66 | 67 |
| 67 // Disable watchdog so that it won't do anything when time expires. | 68 // Disable watchdog so that it won't do anything when time expires. |
| 68 void Watchdog::Disarm() { | 69 void Watchdog::Disarm() { |
| 69 AutoLock lock(lock_); | 70 AutoLock lock(lock_); |
| 70 state_ = DISARMED; | 71 state_ = DISARMED; |
| 71 // We don't need to signal, as the watchdog will eventually wake up, and it | 72 // We don't need to signal, as the watchdog will eventually wake up, and it |
| 72 // will check its state and time, and act accordingly. | 73 // will check its state and time, and act accordingly. |
| 73 } | 74 } |
| 74 | 75 |
| 76 void Watchdog::Alarm() { |
| 77 DLOG(INFO) << "Watchdog alarmed for " << thread_watched_name_; |
| 78 } |
| 79 |
| 75 //------------------------------------------------------------------------------ | 80 //------------------------------------------------------------------------------ |
| 76 // Internal private methods that the watchdog thread uses. | 81 // Internal private methods that the watchdog thread uses. |
| 77 | 82 |
| 78 void Watchdog::ThreadDelegate::ThreadMain() { | 83 void Watchdog::ThreadDelegate::ThreadMain() { |
| 79 SetThreadName(); | 84 SetThreadName(); |
| 80 TimeDelta remaining_duration; | 85 TimeDelta remaining_duration; |
| 81 while (1) { | 86 while (1) { |
| 82 AutoLock lock(watchdog_->lock_); | 87 AutoLock lock(watchdog_->lock_); |
| 83 while (DISARMED == watchdog_->state_) | 88 while (DISARMED == watchdog_->state_) |
| 84 watchdog_->condition_variable_.Wait(); | 89 watchdog_->condition_variable_.Wait(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 last_debugged_alarm_time_ = TimeTicks(); | 137 last_debugged_alarm_time_ = TimeTicks(); |
| 133 last_debugged_alarm_delay_ = TimeDelta(); | 138 last_debugged_alarm_delay_ = TimeDelta(); |
| 134 } | 139 } |
| 135 | 140 |
| 136 // static | 141 // static |
| 137 Lock Watchdog::static_lock_; // Lock for access of static data... | 142 Lock Watchdog::static_lock_; // Lock for access of static data... |
| 138 // static | 143 // static |
| 139 TimeTicks Watchdog::last_debugged_alarm_time_ = TimeTicks(); | 144 TimeTicks Watchdog::last_debugged_alarm_time_ = TimeTicks(); |
| 140 // static | 145 // static |
| 141 TimeDelta Watchdog::last_debugged_alarm_delay_; | 146 TimeDelta Watchdog::last_debugged_alarm_delay_; |
| OLD | NEW |