| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 { | 152 { |
| 153 return !ThreadHeap::willObjectBeLazilySwept(objectPointer); | 153 return !ThreadHeap::willObjectBeLazilySwept(objectPointer); |
| 154 } | 154 } |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 template <typename TimerFiredClass> | 157 template <typename TimerFiredClass> |
| 158 class Timer : public TimerBase { | 158 class Timer : public TimerBase { |
| 159 public: | 159 public: |
| 160 using TimerFiredFunction = void (TimerFiredClass::*)(Timer<TimerFiredClass>*
); | 160 using TimerFiredFunction = void (TimerFiredClass::*)(Timer<TimerFiredClass>*
); |
| 161 | 161 |
| 162 // TODO(dcheng): Consider removing this overload once all timers are using t
he |
| 163 // appropriate task runner. https://crbug.com/624694 |
| 162 Timer(TimerFiredClass* o, TimerFiredFunction f) | 164 Timer(TimerFiredClass* o, TimerFiredFunction f) |
| 163 : m_object(o), m_function(f) | 165 : m_object(o), m_function(f) |
| 164 { | 166 { |
| 165 } | 167 } |
| 166 | 168 |
| 169 Timer(TimerFiredClass* o, TimerFiredFunction f, WebTaskRunner* webTaskRunner
) |
| 170 : TimerBase(webTaskRunner), m_object(o), m_function(f) |
| 171 { |
| 172 } |
| 173 |
| 167 ~Timer() override { } | 174 ~Timer() override { } |
| 168 | 175 |
| 169 protected: | 176 protected: |
| 170 void fired() override | 177 void fired() override |
| 171 { | 178 { |
| 172 (m_object->*m_function)(this); | 179 (m_object->*m_function)(this); |
| 173 } | 180 } |
| 174 | 181 |
| 175 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 182 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 176 bool canFire() const override | 183 bool canFire() const override |
| 177 { | 184 { |
| 178 // Oilpan: if a timer fires while Oilpan heaps are being lazily | 185 // Oilpan: if a timer fires while Oilpan heaps are being lazily |
| 179 // swept, it is not safe to proceed if the object is about to | 186 // swept, it is not safe to proceed if the object is about to |
| 180 // be swept (and this timer will be stopped while doing so.) | 187 // be swept (and this timer will be stopped while doing so.) |
| 181 return TimerIsObjectAliveTrait<TimerFiredClass>::isHeapObjectAlive(m_obj
ect); | 188 return TimerIsObjectAliveTrait<TimerFiredClass>::isHeapObjectAlive(m_obj
ect); |
| 182 } | 189 } |
| 183 | 190 |
| 184 Timer(TimerFiredClass* o, TimerFiredFunction f, WebTaskRunner* webTaskRunner
) | |
| 185 : TimerBase(webTaskRunner), m_object(o), m_function(f) | |
| 186 { | |
| 187 } | |
| 188 | |
| 189 private: | 191 private: |
| 190 // FIXME: Oilpan: TimerBase should be moved to the heap and m_object should
be traced. | 192 // FIXME: Oilpan: TimerBase should be moved to the heap and m_object should
be traced. |
| 191 // This raw pointer is safe as long as Timer<X> is held by the X itself (Tha
t's the case | 193 // This raw pointer is safe as long as Timer<X> is held by the X itself (Tha
t's the case |
| 192 // in the current code base). | 194 // in the current code base). |
| 193 GC_PLUGIN_IGNORE("363031") | 195 GC_PLUGIN_IGNORE("363031") |
| 194 TimerFiredClass* m_object; | 196 TimerFiredClass* m_object; |
| 195 TimerFiredFunction m_function; | 197 TimerFiredFunction m_function; |
| 196 }; | 198 }; |
| 197 | 199 |
| 198 // This subclass of Timer posts its tasks on the current thread's default task r
unner. | 200 // This subclass of Timer posts its tasks on the current thread's default task r
unner. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 213 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 215 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 214 inline bool TimerBase::isActive() const | 216 inline bool TimerBase::isActive() const |
| 215 { | 217 { |
| 216 ASSERT(m_thread == currentThread()); | 218 ASSERT(m_thread == currentThread()); |
| 217 return m_cancellableTimerTask; | 219 return m_cancellableTimerTask; |
| 218 } | 220 } |
| 219 | 221 |
| 220 } // namespace blink | 222 } // namespace blink |
| 221 | 223 |
| 222 #endif // Timer_h | 224 #endif // Timer_h |
| OLD | NEW |