| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 namespace { | 33 namespace { |
| 34 // The lowest value returned by TimerBase::nextUnalignedFireInterval is 0.0 | 34 // The lowest value returned by TimerBase::nextUnalignedFireInterval is 0.0 |
| 35 const double kNextFireIntervalInvalid = -1.0; | 35 const double kNextFireIntervalInvalid = -1.0; |
| 36 } | 36 } |
| 37 | 37 |
| 38 SuspendableTimer::SuspendableTimer(ExecutionContext* context) | 38 SuspendableTimer::SuspendableTimer(ExecutionContext* context) |
| 39 : TimerBase(TaskRunnerHelper::get(TaskType::Timer, context)), | 39 : TimerBase(TaskRunnerHelper::get(TaskType::Timer, context)), |
| 40 SuspendableObject(context), | 40 SuspendableObject(context), |
| 41 m_nextFireInterval(kNextFireIntervalInvalid), | 41 m_nextFireInterval(kNextFireIntervalInvalid), |
| 42 m_repeatInterval(0) | 42 m_repeatInterval(0) |
| 43 #if ENABLE(ASSERT) | |
| 44 , | |
| 45 m_suspended(false) | |
| 46 #endif | |
| 47 { | 43 { |
| 48 DCHECK(context); | 44 DCHECK(context); |
| 49 } | 45 } |
| 50 | 46 |
| 51 SuspendableTimer::~SuspendableTimer() {} | 47 SuspendableTimer::~SuspendableTimer() {} |
| 52 | 48 |
| 53 void SuspendableTimer::stop() { | 49 void SuspendableTimer::stop() { |
| 54 m_nextFireInterval = kNextFireIntervalInvalid; | 50 m_nextFireInterval = kNextFireIntervalInvalid; |
| 55 TimerBase::stop(); | 51 TimerBase::stop(); |
| 56 } | 52 } |
| 57 | 53 |
| 58 void SuspendableTimer::contextDestroyed(ExecutionContext*) { | 54 void SuspendableTimer::contextDestroyed(ExecutionContext*) { |
| 59 stop(); | 55 stop(); |
| 60 } | 56 } |
| 61 | 57 |
| 62 void SuspendableTimer::suspend() { | 58 void SuspendableTimer::suspend() { |
| 63 #if ENABLE(ASSERT) | 59 #if DCHECK_IS_ON() |
| 64 ASSERT(!m_suspended); | 60 ASSERT(!m_suspended); |
| 65 m_suspended = true; | 61 m_suspended = true; |
| 66 #endif | 62 #endif |
| 67 if (isActive()) { | 63 if (isActive()) { |
| 68 m_nextFireInterval = nextFireInterval(); | 64 m_nextFireInterval = nextFireInterval(); |
| 69 ASSERT(m_nextFireInterval >= 0.0); | 65 ASSERT(m_nextFireInterval >= 0.0); |
| 70 m_repeatInterval = repeatInterval(); | 66 m_repeatInterval = repeatInterval(); |
| 71 TimerBase::stop(); | 67 TimerBase::stop(); |
| 72 } | 68 } |
| 73 } | 69 } |
| 74 | 70 |
| 75 void SuspendableTimer::resume() { | 71 void SuspendableTimer::resume() { |
| 76 #if ENABLE(ASSERT) | 72 #if DCHECK_IS_ON() |
| 77 ASSERT(m_suspended); | 73 ASSERT(m_suspended); |
| 78 m_suspended = false; | 74 m_suspended = false; |
| 79 #endif | 75 #endif |
| 80 if (m_nextFireInterval >= 0.0) { | 76 if (m_nextFireInterval >= 0.0) { |
| 81 // start() was called before, therefore location() is already set. | 77 // start() was called before, therefore location() is already set. |
| 82 // m_nextFireInterval is only set in suspend() if the Timer was active. | 78 // m_nextFireInterval is only set in suspend() if the Timer was active. |
| 83 start(m_nextFireInterval, m_repeatInterval, location()); | 79 start(m_nextFireInterval, m_repeatInterval, location()); |
| 84 m_nextFireInterval = kNextFireIntervalInvalid; | 80 m_nextFireInterval = kNextFireIntervalInvalid; |
| 85 } | 81 } |
| 86 } | 82 } |
| 87 | 83 |
| 88 } // namespace blink | 84 } // namespace blink |
| OLD | NEW |