RESOLVED FIXED 23025
Simplifying DOMTimer lifetime management code
https://bugs.webkit.org/show_bug.cgi?id=23025
Summary Simplifying DOMTimer lifetime management code
Dmitry Titov
Reported 2008-12-29 14:22:02 PST
Following IRC discussion... DOMTimer lifetime is a bit confusing - it is created from DOMTimer::install() but then destroyed sometimes by direct 'delete' (when Document is destroyed) and sometimes as a side-effect (in Document::removeTimeout which should only remove an ID from the Document's timeout map). Proposed change makes this code a bit more straightforward. The timeoutMap methods on the Document now do not delete the timers, they only add/remove/find timers in the map. The timers are added to the map in their constructor and removed from the map in their destructor, so consistency is guaranteed. Timers are destroyed by directly calling 'delete' in 3 places: - when Document is destroyed while timers are still alive, in DOMTimer::contextDestroyed() - when single-shot timer fired, in DOMTimer::fired() - when JS calls clearTimer, in DOMTimer::removeById()
Attachments
Proposed patch (3.78 KB, patch)
2008-12-29 14:35 PST, Dmitry Titov
darin: review+
Patch with changes after review (3.51 KB, patch)
2009-01-02 17:11 PST, Dmitry Titov
no flags
Dmitry Titov
Comment 1 2008-12-29 14:35:40 PST
Created attachment 26300 [details] Proposed patch
Darin Adler
Comment 2 2009-01-02 10:58:55 PST
Comment on attachment 26300 [details] Proposed patch > - static_cast<Document*>(context)->removeTimeout(timeoutId); > + DOMTimer* timer = static_cast<Document*>(context)->findTimeout(timeoutId); > + delete timer; I personally would like this to just be a one liner without a local variable. > - ActiveDOMObject::contextDestroyed(); > + ActiveDOMObject::contextDestroyed(); // Clears m_scriptExecutionContext. Is adding this comment really an improvement? Normally we use one space before the "//". r=me
Dmitry Titov
Comment 3 2009-01-02 17:11:59 PST
Created attachment 26387 [details] Patch with changes after review Thanks Darin!! All comments addressed. Seems ready to be landed.
Darin Adler
Comment 4 2009-01-02 18:27:48 PST
Note You need to log in before you can comment on or make changes to this bug.