| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 double TimerBase::nextFireInterval() const { | 80 double TimerBase::nextFireInterval() const { |
| 81 ASSERT(isActive()); | 81 ASSERT(isActive()); |
| 82 double current = timerMonotonicallyIncreasingTime(); | 82 double current = timerMonotonicallyIncreasingTime(); |
| 83 if (m_nextFireTime < current) | 83 if (m_nextFireTime < current) |
| 84 return 0; | 84 return 0; |
| 85 return m_nextFireTime - current; | 85 return m_nextFireTime - current; |
| 86 } | 86 } |
| 87 | 87 |
| 88 void TimerBase::moveToNewTaskRunner(WebTaskRunner* taskRunner) { |
| 89 #if DCHECK_IS_ON() |
| 90 DCHECK_EQ(m_thread, currentThread()); |
| 91 DCHECK(taskRunner->runsTasksOnCurrentThread()); |
| 92 #endif |
| 93 // If the underlying task runner stays the same, ignore it. |
| 94 if (m_webTaskRunner->toSingleThreadTaskRunner() == |
| 95 taskRunner->toSingleThreadTaskRunner()) { |
| 96 return; |
| 97 } |
| 98 |
| 99 m_weakPtrFactory.revokeAll(); |
| 100 |
| 101 m_webTaskRunner = taskRunner->clone(); |
| 102 |
| 103 double now = timerMonotonicallyIncreasingTime(); |
| 104 double nextFireTime = m_nextFireTime; |
| 105 m_nextFireTime = 0; |
| 106 |
| 107 setNextFireTime(now, nextFireTime - now); |
| 108 } |
| 109 |
| 88 // static | 110 // static |
| 89 WebTaskRunner* TimerBase::getTimerTaskRunner() { | 111 WebTaskRunner* TimerBase::getTimerTaskRunner() { |
| 90 return Platform::current()->currentThread()->scheduler()->timerTaskRunner(); | 112 return Platform::current()->currentThread()->scheduler()->timerTaskRunner(); |
| 91 } | 113 } |
| 92 | 114 |
| 93 // static | 115 // static |
| 94 WebTaskRunner* TimerBase::getUnthrottledTaskRunner() { | 116 WebTaskRunner* TimerBase::getUnthrottledTaskRunner() { |
| 95 return Platform::current()->currentThread()->getWebTaskRunner(); | 117 return Platform::current()->currentThread()->getWebTaskRunner(); |
| 96 } | 118 } |
| 97 | 119 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 const TimerBase* b) const { | 175 const TimerBase* b) const { |
| 154 return a->m_nextFireTime < b->m_nextFireTime; | 176 return a->m_nextFireTime < b->m_nextFireTime; |
| 155 } | 177 } |
| 156 | 178 |
| 157 // static | 179 // static |
| 158 double TimerBase::timerMonotonicallyIncreasingTime() const { | 180 double TimerBase::timerMonotonicallyIncreasingTime() const { |
| 159 return timerTaskRunner()->monotonicallyIncreasingVirtualTimeSeconds(); | 181 return timerTaskRunner()->monotonicallyIncreasingVirtualTimeSeconds(); |
| 160 } | 182 } |
| 161 | 183 |
| 162 } // namespace blink | 184 } // namespace blink |
| OLD | NEW |