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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 void stop(); | 62 void stop(); |
63 bool isActive() const; | 63 bool isActive() const; |
64 const WebTraceLocation& location() const { return m_location; } | 64 const WebTraceLocation& location() const { return m_location; } |
65 | 65 |
66 double nextFireInterval() const; | 66 double nextFireInterval() const; |
67 double repeatInterval() const { return m_repeatInterval; } | 67 double repeatInterval() const { return m_repeatInterval; } |
68 | 68 |
69 void augmentRepeatInterval(double delta) { | 69 void augmentRepeatInterval(double delta) { |
70 double now = monotonicallyIncreasingTime(); | 70 double now = timerMonotonicallyIncreasingTime(); |
71 setNextFireTime(now, m_nextFireTime - now + delta); | 71 setNextFireTime(now, m_nextFireTime - now + delta); |
72 m_repeatInterval += delta; | 72 m_repeatInterval += delta; |
73 } | 73 } |
74 | 74 |
75 struct PLATFORM_EXPORT Comparator { | 75 struct PLATFORM_EXPORT Comparator { |
76 bool operator()(const TimerBase* a, const TimerBase* b) const; | 76 bool operator()(const TimerBase* a, const TimerBase* b) const; |
77 }; | 77 }; |
78 | 78 |
79 protected: | 79 protected: |
80 static WebTaskRunner* UnthrottledWebTaskRunner(); | 80 static WebTaskRunner* UnthrottledWebTaskRunner(); |
81 | 81 |
82 private: | 82 private: |
83 virtual void fired() = 0; | 83 virtual void fired() = 0; |
84 | 84 |
85 virtual WebTaskRunner* timerTaskRunner(); | 85 virtual WebTaskRunner* timerTaskRunner() const; |
86 | 86 |
87 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 87 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
88 virtual bool canFire() const { return true; } | 88 virtual bool canFire() const { return true; } |
89 | 89 |
| 90 double timerMonotonicallyIncreasingTime() const; |
| 91 |
90 void setNextFireTime(double now, double delay); | 92 void setNextFireTime(double now, double delay); |
91 | 93 |
92 void runInternal(); | 94 void runInternal(); |
93 | 95 |
94 class CancellableTimerTask final : public WebTaskRunner::Task { | 96 class CancellableTimerTask final : public WebTaskRunner::Task { |
95 WTF_MAKE_NONCOPYABLE(CancellableTimerTask); | 97 WTF_MAKE_NONCOPYABLE(CancellableTimerTask); |
96 public: | 98 public: |
97 explicit CancellableTimerTask(TimerBase* timer) : m_timer(timer) { } | 99 explicit CancellableTimerTask(TimerBase* timer) : m_timer(timer) { } |
98 | 100 |
99 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 101 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 213 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
212 inline bool TimerBase::isActive() const | 214 inline bool TimerBase::isActive() const |
213 { | 215 { |
214 ASSERT(m_thread == currentThread()); | 216 ASSERT(m_thread == currentThread()); |
215 return m_cancellableTimerTask; | 217 return m_cancellableTimerTask; |
216 } | 218 } |
217 | 219 |
218 } // namespace blink | 220 } // namespace blink |
219 | 221 |
220 #endif // Timer_h | 222 #endif // Timer_h |
OLD | NEW |