| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/message_loop/message_pump_win.h" | 5 #include "base/message_loop/message_pump_win.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <math.h> | 8 #include <math.h> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 // To provide sub-10ms timers, we process timers directly from our run loop. | 312 // To provide sub-10ms timers, we process timers directly from our run loop. |
| 313 // For the common case, timers will be processed there as the run loop does | 313 // For the common case, timers will be processed there as the run loop does |
| 314 // its normal work. However, we *also* set the system timer so that WM_TIMER | 314 // its normal work. However, we *also* set the system timer so that WM_TIMER |
| 315 // events fire. This mops up the case of timers not being able to work in | 315 // events fire. This mops up the case of timers not being able to work in |
| 316 // modal message loops. It is possible for the SetTimer to pop and have no | 316 // modal message loops. It is possible for the SetTimer to pop and have no |
| 317 // pending timers, because they could have already been processed by the | 317 // pending timers, because they could have already been processed by the |
| 318 // run loop itself. | 318 // run loop itself. |
| 319 // | 319 // |
| 320 // We use a single SetTimer corresponding to the timer that will expire | 320 // We use a single SetTimer corresponding to the timer that will expire |
| 321 // soonest. As new timers are created and destroyed, we update SetTimer. | 321 // soonest. As new timers are created and destroyed, we update SetTimer. |
| 322 // Getting a spurrious SetTimer event firing is benign, as we'll just be | 322 // Getting a spurious SetTimer event firing is benign, as we'll just be |
| 323 // processing an empty timer queue. | 323 // processing an empty timer queue. |
| 324 // | 324 // |
| 325 int delay_msec = GetCurrentDelay(); | 325 int delay_msec = GetCurrentDelay(); |
| 326 DCHECK_GE(delay_msec, 0); | 326 DCHECK_GE(delay_msec, 0); |
| 327 if (delay_msec == 0) { | 327 if (delay_msec == 0) { |
| 328 ScheduleWork(); | 328 ScheduleWork(); |
| 329 } else { | 329 } else { |
| 330 if (delay_msec < USER_TIMER_MINIMUM) | 330 if (delay_msec < USER_TIMER_MINIMUM) |
| 331 delay_msec = USER_TIMER_MINIMUM; | 331 delay_msec = USER_TIMER_MINIMUM; |
| 332 | 332 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 | 672 |
| 673 // static | 673 // static |
| 674 MessagePumpForIO::IOHandler* MessagePumpForIO::KeyToHandler( | 674 MessagePumpForIO::IOHandler* MessagePumpForIO::KeyToHandler( |
| 675 ULONG_PTR key, | 675 ULONG_PTR key, |
| 676 bool* has_valid_io_context) { | 676 bool* has_valid_io_context) { |
| 677 *has_valid_io_context = ((key & 1) == 0); | 677 *has_valid_io_context = ((key & 1) == 0); |
| 678 return reinterpret_cast<IOHandler*>(key & ~static_cast<ULONG_PTR>(1)); | 678 return reinterpret_cast<IOHandler*>(key & ~static_cast<ULONG_PTR>(1)); |
| 679 } | 679 } |
| 680 | 680 |
| 681 } // namespace base | 681 } // namespace base |
| OLD | NEW |