summaryrefslogtreecommitdiffstats
path: root/base/waitable_event_win.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/waitable_event_win.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/waitable_event_win.cc')
-rw-r--r--base/waitable_event_win.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/base/waitable_event_win.cc b/base/waitable_event_win.cc
index da2d2d8..e23eea0 100644
--- a/base/waitable_event_win.cc
+++ b/base/waitable_event_win.cc
@@ -29,6 +29,7 @@
#include "base/waitable_event.h"
+#include <math.h>
#include <windows.h>
#include "base/logging.h"
@@ -68,8 +69,12 @@ bool WaitableEvent::Wait() {
}
bool WaitableEvent::TimedWait(const TimeDelta& max_time) {
- int32 timeout = static_cast<int32>(max_time.InMilliseconds());
- DWORD result = WaitForSingleObject(event_, timeout);
+ DCHECK(max_time >= TimeDelta::FromMicroseconds(0));
+ // Be careful here. TimeDelta has 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 returning too early.
+ double timeout = ceil(max_time.InMillisecondsF());
+ DWORD result = WaitForSingleObject(event_, static_cast<DWORD>(timeout));
switch (result) {
case WAIT_OBJECT_0:
return true;