| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/logging.h" |
| 9 #include "base/platform_thread.h" | 9 #include "base/platform_thread.h" |
| 10 | 10 |
| 11 using base::TimeDelta; | 11 using base::TimeDelta; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 // 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. |
| 69 void Watchdog::Disarm() { | 69 void Watchdog::Disarm() { |
| 70 AutoLock lock(lock_); | 70 AutoLock lock(lock_); |
| 71 state_ = DISARMED; | 71 state_ = DISARMED; |
| 72 // 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 |
| 73 // will check its state and time, and act accordingly. | 73 // will check its state and time, and act accordingly. |
| 74 } | 74 } |
| 75 | 75 |
| 76 void Watchdog::Alarm() { | 76 void Watchdog::Alarm() { |
| 77 DLOG(INFO) << "Watchdog alarmed for " << thread_watched_name_; | 77 DVLOG(1) << "Watchdog alarmed for " << thread_watched_name_; |
| 78 } | 78 } |
| 79 | 79 |
| 80 //------------------------------------------------------------------------------ | 80 //------------------------------------------------------------------------------ |
| 81 // Internal private methods that the watchdog thread uses. | 81 // Internal private methods that the watchdog thread uses. |
| 82 | 82 |
| 83 void Watchdog::ThreadDelegate::ThreadMain() { | 83 void Watchdog::ThreadDelegate::ThreadMain() { |
| 84 SetThreadName(); | 84 SetThreadName(); |
| 85 TimeDelta remaining_duration; | 85 TimeDelta remaining_duration; |
| 86 while (1) { | 86 while (1) { |
| 87 AutoLock lock(watchdog_->lock_); | 87 AutoLock lock(watchdog_->lock_); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 AutoLock static_lock(static_lock_); | 121 AutoLock static_lock(static_lock_); |
| 122 // This was a real debugger break. | 122 // This was a real debugger break. |
| 123 last_debugged_alarm_time_ = last_alarm_time; | 123 last_debugged_alarm_time_ = last_alarm_time; |
| 124 last_debugged_alarm_delay_ = last_alarm_delay; | 124 last_debugged_alarm_delay_ = last_alarm_delay; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 void Watchdog::ThreadDelegate::SetThreadName() const { | 128 void Watchdog::ThreadDelegate::SetThreadName() const { |
| 129 std::string name = watchdog_->thread_watched_name_ + " Watchdog"; | 129 std::string name = watchdog_->thread_watched_name_ + " Watchdog"; |
| 130 PlatformThread::SetName(name.c_str()); | 130 PlatformThread::SetName(name.c_str()); |
| 131 DLOG(INFO) << "Watchdog active: " << name; | 131 DVLOG(1) << "Watchdog active: " << name; |
| 132 } | 132 } |
| 133 | 133 |
| 134 // static | 134 // static |
| 135 void Watchdog::ResetStaticData() { | 135 void Watchdog::ResetStaticData() { |
| 136 AutoLock lock(static_lock_); | 136 AutoLock lock(static_lock_); |
| 137 last_debugged_alarm_time_ = TimeTicks(); | 137 last_debugged_alarm_time_ = TimeTicks(); |
| 138 last_debugged_alarm_delay_ = TimeDelta(); | 138 last_debugged_alarm_delay_ = TimeDelta(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 // static | 141 // static |
| 142 Lock Watchdog::static_lock_; // Lock for access of static data... | 142 Lock Watchdog::static_lock_; // Lock for access of static data... |
| 143 // static | 143 // static |
| 144 TimeTicks Watchdog::last_debugged_alarm_time_ = TimeTicks(); | 144 TimeTicks Watchdog::last_debugged_alarm_time_ = TimeTicks(); |
| 145 // static | 145 // static |
| 146 TimeDelta Watchdog::last_debugged_alarm_delay_; | 146 TimeDelta Watchdog::last_debugged_alarm_delay_; |
| OLD | NEW |