summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 12:11:18 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 12:11:18 +0000
commit04c8f4e473a35eac3be2f34ca3971eb950f20fba (patch)
treec0537c64a855db7a06378225b8e93cca458827fe
parentbb23ae41ecdea50de1a00ddf6bd58f78e5ffb3b5 (diff)
downloadchromium_src-04c8f4e473a35eac3be2f34ca3971eb950f20fba.zip
chromium_src-04c8f4e473a35eac3be2f34ca3971eb950f20fba.tar.gz
chromium_src-04c8f4e473a35eac3be2f34ca3971eb950f20fba.tar.bz2
Cleanup base/watchdog thread delegate.
Review URL: http://codereview.chromium.org/17038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7585 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/watchdog.cc5
-rw-r--r--base/watchdog.h5
2 files changed, 5 insertions, 5 deletions
diff --git a/base/watchdog.cc b/base/watchdog.cc
index 0049fec..76662b2 100644
--- a/base/watchdog.cc
+++ b/base/watchdog.cc
@@ -21,8 +21,9 @@ Watchdog::Watchdog(const TimeDelta& duration,
lock_(),
condition_variable_(&lock_),
state_(DISARMED),
+ duration_(duration),
thread_watched_name_(thread_watched_name),
- ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this, duration)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)) {
if (!enabled)
return; // Don't start thread, or doing anything really.
init_successful_ = PlatformThread::Create(0, // Default stack size.
@@ -84,7 +85,7 @@ void Watchdog::ThreadDelegate::ThreadMain() {
if (SHUTDOWN == watchdog_->state_)
return;
DCHECK(ARMED == watchdog_->state_);
- remaining_duration = duration_ -
+ remaining_duration = watchdog_->duration_ -
(TimeTicks::Now() - watchdog_->start_time_);
if (remaining_duration.InMilliseconds() > 0) {
// Spurios wake? Timer drifts? Go back to sleep for remaining time.
diff --git a/base/watchdog.h b/base/watchdog.h
index 63c0612..d8123bb 100644
--- a/base/watchdog.h
+++ b/base/watchdog.h
@@ -50,13 +50,11 @@ class Watchdog {
private:
class ThreadDelegate : public PlatformThread::Delegate {
public:
- explicit ThreadDelegate(Watchdog* watchdog, const base::TimeDelta& duration)
- : watchdog_(watchdog), duration_(duration) {
+ explicit ThreadDelegate(Watchdog* watchdog) : watchdog_(watchdog) {
}
virtual void ThreadMain();
private:
Watchdog* watchdog_;
- const base::TimeDelta duration_; // How long after start_time_ do we alarm?
void SetThreadName() const;
};
@@ -68,6 +66,7 @@ class Watchdog {
Lock lock_; // Mutex for state_.
ConditionVariable condition_variable_;
State state_;
+ const base::TimeDelta duration_; // How long after start_time_ do we alarm?
const std::string thread_watched_name_;
PlatformThreadHandle handle_;
ThreadDelegate delegate_; // Store it, because it must outlive the thread.