summaryrefslogtreecommitdiffstats
path: root/base/timer.cc
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-20 06:30:58 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-20 06:30:58 +0000
commitb24250fc9857d219ad617e2a14e145b65724cb61 (patch)
tree858c55a80b23d0e8e62d1f9d4c4b724c6c924860 /base/timer.cc
parent099cec761ad00232f5ce8483a163356b06065980 (diff)
downloadchromium_src-b24250fc9857d219ad617e2a14e145b65724cb61.zip
chromium_src-b24250fc9857d219ad617e2a14e145b65724cb61.tar.gz
chromium_src-b24250fc9857d219ad617e2a14e145b65724cb61.tar.bz2
reland r1075 w/ tweak to fix test failures
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/timer.cc')
-rw-r--r--base/timer.cc20
1 files changed, 5 insertions, 15 deletions
diff --git a/base/timer.cc b/base/timer.cc
index 46fae6e..aced8cb 100644
--- a/base/timer.cc
+++ b/base/timer.cc
@@ -55,14 +55,6 @@ Timer::Timer(int delay, Task* task, bool repeating)
Reset();
}
-int Timer::GetCurrentDelay() const {
- // Be careful here. Timers have a precision of microseconds, but this API is
- // in milliseconds. If there are 5.5ms left, should the delay be 5 or 6? It
- // should be 6 to avoid timers firing early.
- double delay = ceil((fire_time_ - Time::Now()).InMillisecondsF());
- return static_cast<int>(delay);
-}
-
void Timer::Reset() {
creation_time_ = Time::Now();
fire_time_ = creation_time_ + TimeDelta::FromMilliseconds(delay_);
@@ -163,7 +155,7 @@ bool TimerManager::RunSomePendingTimers() {
// timers have been set.
const int kMaxTimersPerCall = 2;
for (int i = 0; i < kMaxTimersPerCall; ++i) {
- if (timers_.empty() || GetCurrentDelay() > 0)
+ if (timers_.empty() || timers_.top()->fire_time() > Time::Now())
break;
// Get a pending timer. Deal with updating the timers_ queue and setting
@@ -211,13 +203,11 @@ void TimerManager::StartTimer(Timer* timer) {
DidChangeNextTimer();
}
-int TimerManager::GetCurrentDelay() {
+Time TimerManager::GetNextFireTime() const {
if (timers_.empty())
- return -1;
- int delay = timers_.top()->GetCurrentDelay();
- if (delay < 0)
- delay = 0;
- return delay;
+ return Time();
+
+ return timers_.top()->fire_time();
}
void TimerManager::DidChangeNextTimer() {