I copied and pasted some code from GraphicsContextCG into GeneratorGeneratedImage, and I shouldn't have. We should move this code to somewhere more generic so that it can be reused, especially as it's particularly useful for clearing caches! DeferrableOneShotTimer is a timer which takes a class+method to call (as Timer does), and a delay. It exposes restart(), stop(), and isActive(), and none of the rest of the TimerBase interface. On restart(), the timer is started with the given delay, unless it's already running, in which case a flag is set to automatically restart the timer when it fires instead of calling the given method. This provides a low-overhead way to implement a deferrable timer. This will be used to clear GraphicsContextCG's subimage cache and GeneratorGeneratedImage's generated image cache. I have a patch. I'm also open to better names and/or moving it into its own header if needed.
Created attachment 144724 [details] patch
Comment on attachment 144724 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=144724&action=review Nice. > Source/WebCore/platform/Timer.h:127 > + // again, which might result in rescheduling the system timer and that s/and that/which > Source/WebCore/platform/Timer.h:155 > + bool m_shouldRestartWhenTimerFires; > + double m_delay; Putting the bool last might get you better packing and a smaller object.
http://trac.webkit.org/changeset/118942
Comment on attachment 144724 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=144724&action=review >> Source/WebCore/platform/Timer.h:127 >> + // again, which might result in rescheduling the system timer and that > > s/and that/which I don’t agree. That goes against my elementary school training about the use of which vs. that.