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

Unified Diff: base/message_loop/message_pump_win.cc

Issue 395913006: High resolution timer fix for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more cleanup Created 6 years, 5 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
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;

Powered by Google App Engine
This is Rietveld 408576698