diff options
author | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-16 03:09:05 +0000 |
---|---|---|
committer | darin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-16 03:09:05 +0000 |
commit | fc7fb6e30c5c3574dfade2803f1793b9110d1370 (patch) | |
tree | 0ac30f51beace4b794501ad120f437f9149c65fb /base/message_pump_win.cc | |
parent | 3705baeff3bc0c1f63d2376e16c427df18c7564a (diff) | |
download | chromium_src-fc7fb6e30c5c3574dfade2803f1793b9110d1370.zip chromium_src-fc7fb6e30c5c3574dfade2803f1793b9110d1370.tar.gz chromium_src-fc7fb6e30c5c3574dfade2803f1793b9110d1370.tar.bz2 |
Take 2 at the new MessageLoop implementation.
R=jar
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@973 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_pump_win.cc')
-rw-r--r-- | base/message_pump_win.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/base/message_pump_win.cc b/base/message_pump_win.cc index d07b4f7..f290e44 100644 --- a/base/message_pump_win.cc +++ b/base/message_pump_win.cc @@ -182,6 +182,7 @@ void MessagePumpWin::ScheduleDelayedWork(const TimeDelta& delay) { // processing an empty timer queue. // int delay_msec = static_cast<int>(delay.InMilliseconds()); + DCHECK(delay_msec >= 0); if (delay_msec < USER_TIMER_MINIMUM) delay_msec = USER_TIMER_MINIMUM; @@ -249,7 +250,10 @@ void MessagePumpWin::HandleTimerMessage() { if (!state_) return; - state_->delegate->DoDelayedWork(); + TimeDelta next_delay; + state_->delegate->DoDelayedWork(&next_delay); + if (next_delay >= TimeDelta::FromMilliseconds(0)) + ScheduleDelayedWork(next_delay); } void MessagePumpWin::DoRunLoop() { @@ -291,7 +295,15 @@ void MessagePumpWin::DoRunLoop() { if (more_work_is_plausible) continue; - more_work_is_plausible = state_->delegate->DoDelayedWork(); + TimeDelta next_delay; + more_work_is_plausible = state_->delegate->DoDelayedWork(&next_delay); + // If we did not process any delayed work, then we can assume that our + // existing WM_TIMER if any will fire when delayed work should run. We + // don't want to disturb that timer if it is already in flight. However, + // if we did do all remaining delayed work, then lets kill the WM_TIMER. + if (more_work_is_plausible && + next_delay < TimeDelta::FromMilliseconds(0)) + KillTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this)); if (state_->should_quit) break; |