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

Unified Diff: base/watchdog.cc

Issue 42266: Break up unit test to avoid internal timing interactions between parts.... (Closed) Base URL: svn://chrome-svn/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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/watchdog_unittest.cc » ('j') | base/watchdog_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/watchdog.cc
===================================================================
--- base/watchdog.cc (revision 11750)
+++ base/watchdog.cc (working copy)
@@ -90,33 +90,33 @@
if (remaining_duration.InMilliseconds() > 0) {
// Spurios wake? Timer drifts? Go back to sleep for remaining time.
watchdog_->condition_variable_.TimedWait(remaining_duration);
- } else {
- // We overslept, so this seems like a real alarm.
- // Watch out for a user that stopped the debugger on a different alarm!
- {
- AutoLock static_lock(static_lock_);
- if (last_debugged_alarm_time_ > watchdog_->start_time_) {
- // False alarm: we started our clock before the debugger break (last
- // alarm time).
- watchdog_->start_time_ += last_debugged_alarm_delay_;
- if (last_debugged_alarm_time_ > watchdog_->start_time_)
- // Too many alarms must have taken place.
- watchdog_->state_ = DISARMED;
- continue;
- }
+ continue;
+ }
+ // We overslept, so this seems like a real alarm.
+ // Watch out for a user that stopped the debugger on a different alarm!
+ {
+ AutoLock static_lock(static_lock_);
+ if (last_debugged_alarm_time_ > watchdog_->start_time_) {
+ // False alarm: we started our clock before the debugger break (last
+ // alarm time).
+ watchdog_->start_time_ += last_debugged_alarm_delay_;
+ if (last_debugged_alarm_time_ > watchdog_->start_time_)
+ // Too many alarms must have taken place.
+ watchdog_->state_ = DISARMED;
+ continue;
}
- watchdog_->state_ = DISARMED; // Only alarm at most once.
- TimeTicks last_alarm_time = TimeTicks::Now();
- watchdog_->Alarm(); // Set a break point here to debug on alarms.
- TimeDelta last_alarm_delay = TimeTicks::Now() - last_alarm_time;
- if (last_alarm_delay > TimeDelta::FromMilliseconds(2)) {
- // Ignore race of two alarms/breaks going off at roughly the same time.
- AutoLock static_lock(static_lock_);
- // This was a real debugger break.
- last_debugged_alarm_time_ = last_alarm_time;
- last_debugged_alarm_delay_ = last_alarm_delay;
- }
}
+ watchdog_->state_ = DISARMED; // Only alarm at most once.
+ TimeTicks last_alarm_time = TimeTicks::Now();
+ watchdog_->Alarm(); // Set a break point here to debug on alarms.
+ TimeDelta last_alarm_delay = TimeTicks::Now() - last_alarm_time;
+ if (last_alarm_delay <= TimeDelta::FromMilliseconds(2))
+ continue;
+ // Ignore race of two alarms/breaks going off at roughly the same time.
+ AutoLock static_lock(static_lock_);
+ // This was a real debugger break.
+ last_debugged_alarm_time_ = last_alarm_time;
+ last_debugged_alarm_delay_ = last_alarm_delay;
}
}
« no previous file with comments | « no previous file | base/watchdog_unittest.cc » ('j') | base/watchdog_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698