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 00:25:57 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-20 00:25:57 +0000
commit1a2bfdd793e88a64f78b38d23303550cfd0703eb (patch)
tree90ef0670a00f72c3e0cc2499866d5627511a4867 /base/timer.cc
parent7759c9a7b587662988fa1357c17c273ee64fb3bd (diff)
downloadchromium_src-1a2bfdd793e88a64f78b38d23303550cfd0703eb.zip
chromium_src-1a2bfdd793e88a64f78b38d23303550cfd0703eb.tar.gz
chromium_src-1a2bfdd793e88a64f78b38d23303550cfd0703eb.tar.bz2
Eliminate TimerManager::GetCurrentDelay in favor of always referring to the fire time of the next timer. I changed the MessagePump API to refer to a delayed_work_time instead of a delay.
I moved the ceil-based rounding code into the Window's implementations of WaitableEvent and MessagePump. R=jar git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1075 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() {