Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(535)

Side by Side Diff: base/watchdog.cc

Issue 42147: Increase fudge factor to let WatchdogTest.AlarmTest pass reliably on slower m... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/platform_thread.h" 8 #include "base/platform_thread.h"
9 9
10 using base::TimeDelta; 10 using base::TimeDelta;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 if (last_debugged_alarm_time_ > watchdog_->start_time_) 102 if (last_debugged_alarm_time_ > watchdog_->start_time_)
103 // Too many alarms must have taken place. 103 // Too many alarms must have taken place.
104 watchdog_->state_ = DISARMED; 104 watchdog_->state_ = DISARMED;
105 continue; 105 continue;
106 } 106 }
107 } 107 }
108 watchdog_->state_ = DISARMED; // Only alarm at most once. 108 watchdog_->state_ = DISARMED; // Only alarm at most once.
109 TimeTicks last_alarm_time = TimeTicks::Now(); 109 TimeTicks last_alarm_time = TimeTicks::Now();
110 watchdog_->Alarm(); // Set a break point here to debug on alarms. 110 watchdog_->Alarm(); // Set a break point here to debug on alarms.
111 TimeDelta last_alarm_delay = TimeTicks::Now() - last_alarm_time; 111 TimeDelta last_alarm_delay = TimeTicks::Now() - last_alarm_time;
112 if (last_alarm_delay > TimeDelta::FromMilliseconds(2)) { 112 // Normally, a threshold of 2ms works here, but 10x higher
113 // threshold needed to reliably pass WatchdogTest.AlarmTest
114 // under valgrind on an old 3.4GHz Pentium 4. Use 15x for margin.
115 if (last_alarm_delay > TimeDelta::FromMilliseconds(30)) {
113 // Ignore race of two alarms/breaks going off at roughly the same time. 116 // Ignore race of two alarms/breaks going off at roughly the same time.
114 AutoLock static_lock(static_lock_); 117 AutoLock static_lock(static_lock_);
115 // This was a real debugger break. 118 // This was a real debugger break.
116 last_debugged_alarm_time_ = last_alarm_time; 119 last_debugged_alarm_time_ = last_alarm_time;
117 last_debugged_alarm_delay_ = last_alarm_delay; 120 last_debugged_alarm_delay_ = last_alarm_delay;
118 } 121 }
119 } 122 }
120 } 123 }
121 } 124 }
122 125
123 void Watchdog::ThreadDelegate::SetThreadName() const { 126 void Watchdog::ThreadDelegate::SetThreadName() const {
124 std::string name = watchdog_->thread_watched_name_ + " Watchdog"; 127 std::string name = watchdog_->thread_watched_name_ + " Watchdog";
125 PlatformThread::SetName(name.c_str()); 128 PlatformThread::SetName(name.c_str());
126 DLOG(INFO) << "Watchdog active: " << name; 129 DLOG(INFO) << "Watchdog active: " << name;
127 } 130 }
128 131
129 // static 132 // static
130 Lock Watchdog::static_lock_; // Lock for access of static data... 133 Lock Watchdog::static_lock_; // Lock for access of static data...
131 // static 134 // static
132 TimeTicks Watchdog::last_debugged_alarm_time_ = TimeTicks(); 135 TimeTicks Watchdog::last_debugged_alarm_time_ = TimeTicks();
133 // static 136 // static
134 TimeDelta Watchdog::last_debugged_alarm_delay_; 137 TimeDelta Watchdog::last_debugged_alarm_delay_;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698