OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 void stop(); | 61 void stop(); |
62 bool isActive() const; | 62 bool isActive() const; |
63 const WebTraceLocation& location() const { return m_location; } | 63 const WebTraceLocation& location() const { return m_location; } |
64 | 64 |
65 double nextFireInterval() const; | 65 double nextFireInterval() const; |
66 double repeatInterval() const { return m_repeatInterval; } | 66 double repeatInterval() const { return m_repeatInterval; } |
67 | 67 |
68 void augmentRepeatInterval(double delta) { | 68 void augmentRepeatInterval(double delta) { |
69 double now = monotonicallyIncreasingTime(); | 69 double now = timerMonotonicallyIncreasingTime(); |
70 setNextFireTime(now, m_nextFireTime - now + delta); | 70 setNextFireTime(now, m_nextFireTime - now + delta); |
71 m_repeatInterval += delta; | 71 m_repeatInterval += delta; |
72 } | 72 } |
73 | 73 |
74 struct PLATFORM_EXPORT Comparator { | 74 struct PLATFORM_EXPORT Comparator { |
75 bool operator()(const TimerBase* a, const TimerBase* b) const; | 75 bool operator()(const TimerBase* a, const TimerBase* b) const; |
76 }; | 76 }; |
77 | 77 |
78 protected: | 78 protected: |
79 static WebTaskRunner* UnthrottledWebTaskRunner(); | 79 static WebTaskRunner* UnthrottledWebTaskRunner(); |
80 | 80 |
81 private: | 81 private: |
82 virtual void fired() = 0; | 82 virtual void fired() = 0; |
83 | 83 |
84 virtual WebTaskRunner* timerTaskRunner(); | 84 virtual WebTaskRunner* timerTaskRunner(); |
85 | 85 |
86 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 86 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
87 virtual bool canFire() const { return true; } | 87 virtual bool canFire() const { return true; } |
88 | 88 |
| 89 double timerMonotonicallyIncreasingTime() const |
| 90 { |
| 91 return m_thread->monotonicallyIncreasingVirtualTimeSeconds(); |
| 92 } |
| 93 |
89 void setNextFireTime(double now, double delay); | 94 void setNextFireTime(double now, double delay); |
90 | 95 |
91 void runInternal(); | 96 void runInternal(); |
92 | 97 |
93 class CancellableTimerTask final : public WebTaskRunner::Task { | 98 class CancellableTimerTask final : public WebTaskRunner::Task { |
94 WTF_MAKE_NONCOPYABLE(CancellableTimerTask); | 99 WTF_MAKE_NONCOPYABLE(CancellableTimerTask); |
95 public: | 100 public: |
96 explicit CancellableTimerTask(TimerBase* timer) : m_timer(timer) { } | 101 explicit CancellableTimerTask(TimerBase* timer) : m_timer(timer) { } |
97 | 102 |
98 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 103 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
(...skipping 19 matching lines...) Expand all Loading... |
118 } | 123 } |
119 | 124 |
120 private: | 125 private: |
121 TimerBase* m_timer; // NOT OWNED | 126 TimerBase* m_timer; // NOT OWNED |
122 }; | 127 }; |
123 | 128 |
124 double m_nextFireTime; // 0 if inactive | 129 double m_nextFireTime; // 0 if inactive |
125 double m_repeatInterval; // 0 if not repeating | 130 double m_repeatInterval; // 0 if not repeating |
126 WebTraceLocation m_location; | 131 WebTraceLocation m_location; |
127 CancellableTimerTask* m_cancellableTimerTask; // NOT OWNED | 132 CancellableTimerTask* m_cancellableTimerTask; // NOT OWNED |
128 WebTaskRunner* m_webTaskRunner; // Not owned. | 133 WebThread* m_thread; // NOT OWNED |
129 | 134 WebTaskRunner* m_webTaskRunner; // NOT OWNED |
130 #if ENABLE(ASSERT) | |
131 ThreadIdentifier m_thread; | |
132 #endif | |
133 | 135 |
134 friend class ThreadTimers; | 136 friend class ThreadTimers; |
135 friend class TimerHeapLessThanFunction; | 137 friend class TimerHeapLessThanFunction; |
136 friend class TimerHeapReference; | 138 friend class TimerHeapReference; |
137 }; | 139 }; |
138 | 140 |
139 template<typename T, bool = IsGarbageCollectedType<T>::value> | 141 template<typename T, bool = IsGarbageCollectedType<T>::value> |
140 class TimerIsObjectAliveTrait { | 142 class TimerIsObjectAliveTrait { |
141 public: | 143 public: |
142 static bool isHeapObjectAlive(T*) { return true; } | 144 static bool isHeapObjectAlive(T*) { return true; } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 205 |
204 UnthrottledTimer(TimerFiredClass* timerFiredClass, TimerFiredFunction timerF
iredFunction) | 206 UnthrottledTimer(TimerFiredClass* timerFiredClass, TimerFiredFunction timerF
iredFunction) |
205 : Timer<TimerFiredClass>(timerFiredClass, timerFiredFunction, TimerBase:
:UnthrottledWebTaskRunner()) | 207 : Timer<TimerFiredClass>(timerFiredClass, timerFiredFunction, TimerBase:
:UnthrottledWebTaskRunner()) |
206 { | 208 { |
207 } | 209 } |
208 }; | 210 }; |
209 | 211 |
210 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 212 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
211 inline bool TimerBase::isActive() const | 213 inline bool TimerBase::isActive() const |
212 { | 214 { |
213 ASSERT(m_thread == currentThread()); | 215 ASSERT(m_thread->isCurrentThread()); |
214 return m_cancellableTimerTask; | 216 return m_cancellableTimerTask; |
215 } | 217 } |
216 | 218 |
217 } // namespace blink | 219 } // namespace blink |
218 | 220 |
219 #endif // Timer_h | 221 #endif // Timer_h |
OLD | NEW |