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 ae022bf0957f48be47ad16c77b0f0d99693add21..56288f20f24a6ecaf2316f84594956956c89dcbb 100644 |
--- a/base/message_loop/message_pump_win.cc |
+++ b/base/message_loop/message_pump_win.cc |
@@ -269,6 +269,13 @@ void MessagePumpForUI::WaitForWork() { |
if (delay < 0) // Negative value means no timers waiting. |
delay = INFINITE; |
+ // The delegate will crank the systemwide timer resolution if needed. |
+ // Note that the |delay| value is not enough of an indicator if we need to |
+ // to so. For example, imagine a 30 seconds delayed task that we only get |
+ // arround to service 5ms before the deadline. Should we crank up the |
+ // systemwide timer? no. A 30s timer can be fired 15ms later. |
+ state_->delegate->UpdateTimerGranularity(); |
+ |
DWORD result; |
result = MsgWaitForMultipleObjectsEx(0, NULL, delay, QS_ALLINPUT, |
MWMO_INPUTAVAILABLE); |
@@ -529,6 +536,9 @@ void MessagePumpForIO::WaitForWork() { |
// recursion problems. |
DCHECK_EQ(1, state_->run_depth) << "Cannot nest an IO message loop!"; |
+ // See the comment in MessagePumpForUI::WaitForWork(). |
+ state_->delegate->UpdateTimerGranularity(); |
+ |
int timeout = GetCurrentDelay(); |
if (timeout < 0) // Negative value means no timers waiting. |
timeout = INFINITE; |