diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-30 00:22:48 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-30 00:22:48 +0000 |
commit | 9bcbf478c173d91958cdabc8a8902619392b7f1f (patch) | |
tree | bad2b3022719370e6eb01a66f94924a1f848a968 /base/timer.cc | |
parent | 3f9f500b82c82402d9eef92606ebd149762e9f0c (diff) | |
download | chromium_src-9bcbf478c173d91958cdabc8a8902619392b7f1f.zip chromium_src-9bcbf478c173d91958cdabc8a8902619392b7f1f.tar.gz chromium_src-9bcbf478c173d91958cdabc8a8902619392b7f1f.tar.bz2 |
Switch SharedTimerWin over to using PostDelayedTask. I made some tweaks to the
PostDelayedTask implementation to ensure that perf is still good. This
involved recording the intended fire time of PostDelayedTask on the Task object
so that it can be used to properly determine the delay passed to the StartTimer
call. With this change, I am able to service timers (call DoDelayedWork) more
often from within the MessagePump implementations.
R=mbelshe
BUG=1346553
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/timer.cc')
-rw-r--r-- | base/timer.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/base/timer.cc b/base/timer.cc index 09a13f6..5cf6002 100644 --- a/base/timer.cc +++ b/base/timer.cc @@ -32,6 +32,19 @@ Timer::Timer(int delay, Task* task, bool repeating) Reset(); } +Timer::Timer(Time fire_time, Task* task) + : task_(task), + fire_time_(fire_time), + repeating_(false) { + timer_id_ = timer_id_counter_.GetNext(); + + // TODO(darin): kill off this stuff + creation_time_ = Time::Now(); + delay_ = static_cast<int>((fire_time_ - creation_time_).InMilliseconds()); + DCHECK(delay_ >= 0); + DHISTOGRAM_COUNTS(L"Timer.Durations", delay_); +} + void Timer::Reset() { creation_time_ = Time::Now(); fire_time_ = creation_time_ + TimeDelta::FromMilliseconds(delay_); @@ -144,7 +157,7 @@ bool TimerManager::RunSomePendingTimers() { // now (i.e., current task needs to be reentrant). // TODO(jar): We may block tasks that we can queue from being popped. if (!message_loop_->NestableTasksAllowed() && - !pending->task()->is_owned_by_message_loop()) + !pending->task()->owned_by_message_loop_) break; timers_.pop(); |