| Index: chrome/browser/idle_win.cc
|
| diff --git a/chrome/browser/idle_win.cc b/chrome/browser/idle_win.cc
|
| index 01afca083998508b41f15277970d008063ec1383..712211943e107a2d69e9265787d18a70a87b7900 100644
|
| --- a/chrome/browser/idle_win.cc
|
| +++ b/chrome/browser/idle_win.cc
|
| @@ -18,10 +18,19 @@ IdleState CalculateIdleState(unsigned int idle_threshold) {
|
| last_input_info.cbSize = sizeof(LASTINPUTINFO);
|
| DWORD current_idle_time = 0;
|
| if (::GetLastInputInfo(&last_input_info)) {
|
| - current_idle_time = ::GetTickCount() - last_input_info.dwTime;
|
| - // Will go -ve if we have been idle for a long time (2gb seconds).
|
| - if (current_idle_time < 0)
|
| - current_idle_time = INT_MAX;
|
| + DWORD now = ::GetTickCount();
|
| + if (now < last_input_info.dwTime) {
|
| + // GetTickCount() wraps around every 49.7 days -- assume it wrapped just
|
| + // once.
|
| + const DWORD kMaxDWORD = static_cast<DWORD>(-1);
|
| + DWORD time_before_wrap = kMaxDWORD - last_input_info.dwTime;
|
| + DWORD time_after_wrap = now;
|
| + // The sum is always smaller than kMaxDWORD.
|
| + current_idle_time = time_before_wrap + time_after_wrap;
|
| + } else {
|
| + current_idle_time = now - last_input_info.dwTime;
|
| + }
|
| +
|
| // Convert from ms to seconds.
|
| current_idle_time /= 1000;
|
| }
|
|
|