| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 DCHECK(context); | 48 DCHECK(context); |
| 49 } | 49 } |
| 50 | 50 |
| 51 SuspendableTimer::~SuspendableTimer() {} | 51 SuspendableTimer::~SuspendableTimer() {} |
| 52 | 52 |
| 53 void SuspendableTimer::stop() { | 53 void SuspendableTimer::stop() { |
| 54 m_nextFireInterval = kNextFireIntervalInvalid; | 54 m_nextFireInterval = kNextFireIntervalInvalid; |
| 55 TimerBase::stop(); | 55 TimerBase::stop(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void SuspendableTimer::contextDestroyed() { |
| 59 stop(); |
| 60 } |
| 61 |
| 58 void SuspendableTimer::suspend() { | 62 void SuspendableTimer::suspend() { |
| 59 #if ENABLE(ASSERT) | 63 #if ENABLE(ASSERT) |
| 60 ASSERT(!m_suspended); | 64 ASSERT(!m_suspended); |
| 61 m_suspended = true; | 65 m_suspended = true; |
| 62 #endif | 66 #endif |
| 63 if (isActive()) { | 67 if (isActive()) { |
| 64 m_nextFireInterval = nextFireInterval(); | 68 m_nextFireInterval = nextFireInterval(); |
| 65 ASSERT(m_nextFireInterval >= 0.0); | 69 ASSERT(m_nextFireInterval >= 0.0); |
| 66 m_repeatInterval = repeatInterval(); | 70 m_repeatInterval = repeatInterval(); |
| 67 TimerBase::stop(); | 71 TimerBase::stop(); |
| 68 } | 72 } |
| 69 } | 73 } |
| 70 | 74 |
| 71 void SuspendableTimer::resume() { | 75 void SuspendableTimer::resume() { |
| 72 #if ENABLE(ASSERT) | 76 #if ENABLE(ASSERT) |
| 73 ASSERT(m_suspended); | 77 ASSERT(m_suspended); |
| 74 m_suspended = false; | 78 m_suspended = false; |
| 75 #endif | 79 #endif |
| 76 if (m_nextFireInterval >= 0.0) { | 80 if (m_nextFireInterval >= 0.0) { |
| 77 // start() was called before, therefore location() is already set. | 81 // start() was called before, therefore location() is already set. |
| 78 // m_nextFireInterval is only set in suspend() if the Timer was active. | 82 // m_nextFireInterval is only set in suspend() if the Timer was active. |
| 79 start(m_nextFireInterval, m_repeatInterval, location()); | 83 start(m_nextFireInterval, m_repeatInterval, location()); |
| 80 m_nextFireInterval = kNextFireIntervalInvalid; | 84 m_nextFireInterval = kNextFireIntervalInvalid; |
| 81 } | 85 } |
| 82 } | 86 } |
| 83 | 87 |
| 84 } // namespace blink | 88 } // namespace blink |
| OLD | NEW |