diff options
-rw-r--r-- | base/watchdog.cc | 5 | ||||
-rw-r--r-- | base/watchdog.h | 5 |
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. |