OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/frame/DOMTimerCoordinator.h" | 5 #include "core/frame/DOMTimerCoordinator.h" |
6 | 6 |
7 #include "core/dom/ExecutionContext.h" | 7 #include "core/dom/ExecutionContext.h" |
8 #include "core/frame/DOMTimer.h" | 8 #include "core/frame/DOMTimer.h" |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 26 matching lines...) Expand all Loading... |
37 if (timeoutID <= 0) | 37 if (timeoutID <= 0) |
38 return nullptr; | 38 return nullptr; |
39 | 39 |
40 DOMTimer* removedTimer = m_timers.take(timeoutID); | 40 DOMTimer* removedTimer = m_timers.take(timeoutID); |
41 if (removedTimer) | 41 if (removedTimer) |
42 removedTimer->disposeTimer(); | 42 removedTimer->disposeTimer(); |
43 | 43 |
44 return removedTimer; | 44 return removedTimer; |
45 } | 45 } |
46 | 46 |
| 47 bool DOMTimerCoordinator::hasInstalledTimeout() const |
| 48 { |
| 49 return !m_timers.isEmpty(); |
| 50 } |
| 51 |
47 DEFINE_TRACE(DOMTimerCoordinator) | 52 DEFINE_TRACE(DOMTimerCoordinator) |
48 { | 53 { |
49 visitor->trace(m_timers); | 54 visitor->trace(m_timers); |
50 } | 55 } |
51 | 56 |
52 int DOMTimerCoordinator::nextID() | 57 int DOMTimerCoordinator::nextID() |
53 { | 58 { |
54 while (true) { | 59 while (true) { |
55 ++m_circularSequentialID; | 60 ++m_circularSequentialID; |
56 | 61 |
57 if (m_circularSequentialID <= 0) | 62 if (m_circularSequentialID <= 0) |
58 m_circularSequentialID = 1; | 63 m_circularSequentialID = 1; |
59 | 64 |
60 if (!m_timers.contains(m_circularSequentialID)) | 65 if (!m_timers.contains(m_circularSequentialID)) |
61 return m_circularSequentialID; | 66 return m_circularSequentialID; |
62 } | 67 } |
63 } | 68 } |
64 | 69 |
65 void DOMTimerCoordinator::setTimerTaskRunner(std::unique_ptr<WebTaskRunner> time
rTaskRunner) | 70 void DOMTimerCoordinator::setTimerTaskRunner(std::unique_ptr<WebTaskRunner> time
rTaskRunner) |
66 { | 71 { |
67 m_timerTaskRunner = std::move(timerTaskRunner); | 72 m_timerTaskRunner = std::move(timerTaskRunner); |
68 } | 73 } |
69 | 74 |
70 } // namespace blink | 75 } // namespace blink |
OLD | NEW |