Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Unified Diff: base/message_loop/message_pump_win.cc

Issue 918473002: Process pending delayed tasks in kMsgHaveWork (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698