| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include <limits> | 39 #include <limits> |
| 40 #include <math.h> | 40 #include <math.h> |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 TimerBase::TimerBase() | 44 TimerBase::TimerBase() |
| 45 : m_nextFireTime(0) | 45 : m_nextFireTime(0) |
| 46 , m_unalignedNextFireTime(0) | 46 , m_unalignedNextFireTime(0) |
| 47 , m_repeatInterval(0) | 47 , m_repeatInterval(0) |
| 48 , m_cancellableTimerTask(nullptr) | 48 , m_cancellableTimerTask(nullptr) |
| 49 , m_webScheduler(Platform::current()->currentThread()->scheduler()) | 49 , m_webScheduler(Platform::current()->currentThread() ? Platform::current()-
>currentThread()->scheduler() : nullptr) |
| 50 #if ENABLE(ASSERT) | 50 #if ENABLE(ASSERT) |
| 51 , m_thread(currentThread()) | 51 , m_thread(currentThread()) |
| 52 #endif | 52 #endif |
| 53 { | 53 { |
| 54 } | 54 } |
| 55 | 55 |
| 56 TimerBase::~TimerBase() | 56 TimerBase::~TimerBase() |
| 57 { | 57 { |
| 58 stop(); | 58 stop(); |
| 59 } | 59 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 if (m_nextFireTime != newTime) { | 97 if (m_nextFireTime != newTime) { |
| 98 m_nextFireTime = newTime; | 98 m_nextFireTime = newTime; |
| 99 // Round the delay up to the nearest millisecond to be consistant with t
he | 99 // Round the delay up to the nearest millisecond to be consistant with t
he |
| 100 // previous behavior of BlinkPlatformImpl::setSharedTimerFireInterval. | 100 // previous behavior of BlinkPlatformImpl::setSharedTimerFireInterval. |
| 101 long long delayMs = static_cast<long long>(ceil((newTime - now) * 1000.0
)); | 101 long long delayMs = static_cast<long long>(ceil((newTime - now) * 1000.0
)); |
| 102 if (delayMs < 0) | 102 if (delayMs < 0) |
| 103 delayMs = 0; | 103 delayMs = 0; |
| 104 if (m_cancellableTimerTask) | 104 if (m_cancellableTimerTask) |
| 105 m_cancellableTimerTask->cancel(); | 105 m_cancellableTimerTask->cancel(); |
| 106 m_cancellableTimerTask = new CancellableTimerTask(this); | 106 m_cancellableTimerTask = new CancellableTimerTask(this); |
| 107 m_webScheduler->postTimerTask(m_location, m_cancellableTimerTask, delayM
s); | 107 if (m_webScheduler) |
| 108 m_webScheduler->postTimerTask(m_location, m_cancellableTimerTask, de
layMs); |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 | 111 |
| 111 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 112 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 112 void TimerBase::runInternal() | 113 void TimerBase::runInternal() |
| 113 { | 114 { |
| 114 if (!canFire()) | 115 if (!canFire()) |
| 115 return; | 116 return; |
| 116 | 117 |
| 117 TRACE_EVENT0("blink", "TimerBase::run"); | 118 TRACE_EVENT0("blink", "TimerBase::run"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 132 setNextFireTime(now, m_unalignedNextFireTime - now); | 133 setNextFireTime(now, m_unalignedNextFireTime - now); |
| 133 } | 134 } |
| 134 | 135 |
| 135 double TimerBase::nextUnalignedFireInterval() const | 136 double TimerBase::nextUnalignedFireInterval() const |
| 136 { | 137 { |
| 137 ASSERT(isActive()); | 138 ASSERT(isActive()); |
| 138 return std::max(m_unalignedNextFireTime - monotonicallyIncreasingTime(), 0.0
); | 139 return std::max(m_unalignedNextFireTime - monotonicallyIncreasingTime(), 0.0
); |
| 139 } | 140 } |
| 140 | 141 |
| 141 } // namespace blink | 142 } // namespace blink |
| OLD | NEW |