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

Unified Diff: base/message_loop/message_pump_win.cc

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 11 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 | « base/message_loop/message_pump_perftest.cc ('k') | base/numerics/safe_numerics_unittest.cc » ('j') | 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 a219aa6b79255de7fb6e3027b0512407b730a8ff..75702abec19249b7476d8659724f36bb591c592b 100644
--- a/base/message_loop/message_pump_win.cc
+++ b/base/message_loop/message_pump_win.cc
@@ -4,6 +4,7 @@
#include "base/message_loop/message_pump_win.h"
+#include <limits>
#include <math.h>
#include "base/debug/trace_event.h"
@@ -70,12 +71,13 @@ int MessagePumpWin::GetCurrentDelay() const {
double timeout =
ceil((delayed_work_time_ - TimeTicks::Now()).InMillisecondsF());
- // If this value is negative, then we need to run delayed work soon.
- int delay = static_cast<int>(timeout);
- if (delay < 0)
- delay = 0;
-
- return delay;
+ // Range check the |timeout| while converting to an integer. If the |timeout|
+ // is negative, then we need to run delayed work soon. If the |timeout| is
+ // "overflowingly" large, that means a delayed task was posted with a
+ // super-long delay.
+ return timeout < 0 ? 0 :
+ (timeout > std::numeric_limits<int>::max() ?
+ std::numeric_limits<int>::max() : static_cast<int>(timeout));
}
//-----------------------------------------------------------------------------
« no previous file with comments | « base/message_loop/message_pump_perftest.cc ('k') | base/numerics/safe_numerics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698