Chromium Code Reviews| Index: base/message_loop/message_pump_win.cc |
| diff --git a/base/message_loop/message_pump_win.cc b/base/message_loop/message_pump_win.cc |
| index 27b47e1a0f878cfceef3c04b2364116ca64ac4c8..f3faccfee810c0e6e2ac91db75f0f791304a87cd 100644 |
| --- a/base/message_loop/message_pump_win.cc |
| +++ b/base/message_loop/message_pump_win.cc |
| @@ -146,20 +146,24 @@ void MessagePumpForUI::ScheduleDelayedWork(const TimeTicks& delayed_work_time) { |
| int delay_msec = GetCurrentDelay(); |
| DCHECK_GE(delay_msec, 0); |
| - if (delay_msec < USER_TIMER_MINIMUM) |
| - delay_msec = USER_TIMER_MINIMUM; |
| - |
| - // Create a WM_TIMER event that will wake us up to check for any pending |
| - // timers (in case we are running within a nested, external sub-pump). |
| - BOOL ret = SetTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this), |
| - delay_msec, NULL); |
| - if (ret) |
| - return; |
| - // If we can't set timers, we are in big trouble... but cross our fingers for |
| - // now. |
| - // TODO(jar): If we don't see this error, use a CHECK() here instead. |
| - UMA_HISTOGRAM_ENUMERATION("Chrome.MessageLoopProblem", SET_TIMER_ERROR, |
| - MESSAGE_LOOP_PROBLEM_MAX); |
| + if (delay_msec == 0) { |
| + ScheduleWork(); |
| + } else { |
| + if (delay_msec < USER_TIMER_MINIMUM) |
| + delay_msec = USER_TIMER_MINIMUM; |
| + |
| + // Create a WM_TIMER event that will wake us up to check for any pending |
| + // timers (in case we are running within a nested, external sub-pump). |
| + BOOL ret = SetTimer(message_hwnd_, reinterpret_cast<UINT_PTR>(this), |
| + delay_msec, NULL); |
| + if (ret) |
| + return; |
| + // If we can't set timers, we are in big trouble... but cross our fingers |
| + // for now. |
| + // TODO(jar): If we don't see this error, use a CHECK() here instead. |
| + UMA_HISTOGRAM_ENUMERATION("Chrome.MessageLoopProblem", SET_TIMER_ERROR, |
| + MESSAGE_LOOP_PROBLEM_MAX); |
| + } |
| } |
| //----------------------------------------------------------------------------- |
| @@ -318,6 +322,11 @@ void MessagePumpForUI::HandleWorkMessage() { |
| // needs to do more work. |
| if (state_->delegate->DoWork()) |
| ScheduleWork(); |
| + state_->delegate->DoDelayedWork(&delayed_work_time_); |
|
jar (doing other things)
2015/05/13 20:01:21
Note that you *might* effectively double the amoun
|
| + if (!delayed_work_time_.is_null()) { |
| + // A bit gratuitous to set delayed_work_time_ again, but oh well. |
| + ScheduleDelayedWork(delayed_work_time_); |
| + } |
| } |
| void MessagePumpForUI::HandleTimerMessage() { |