diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/xml/XMLHttpRequestProgressEventThrottle.h')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/xml/XMLHttpRequestProgressEventThrottle.h | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/chromium/third_party/WebKit/Source/core/xml/XMLHttpRequestProgressEventThrottle.h b/chromium/third_party/WebKit/Source/core/xml/XMLHttpRequestProgressEventThrottle.h index 36f5e3a3855..06769fbb8f4 100644 --- a/chromium/third_party/WebKit/Source/core/xml/XMLHttpRequestProgressEventThrottle.h +++ b/chromium/third_party/WebKit/Source/core/xml/XMLHttpRequestProgressEventThrottle.h @@ -28,6 +28,7 @@ #define XMLHttpRequestProgressEventThrottle_h #include "platform/Timer.h" +#include "platform/heap/Handle.h" #include "wtf/PassRefPtr.h" #include "wtf/Vector.h" #include "wtf/text/AtomicString.h" @@ -45,39 +46,54 @@ enum ProgressEventAction { // This implements the XHR2 progress event dispatching: "dispatch a progress event called progress // about every 50ms or for every byte received, whichever is least frequent". -class XMLHttpRequestProgressEventThrottle : public TimerBase { +class XMLHttpRequestProgressEventThrottle FINAL : public TimerBase { + DISALLOW_ALLOCATION(); public: explicit XMLHttpRequestProgressEventThrottle(EventTarget*); virtual ~XMLHttpRequestProgressEventThrottle(); - void dispatchProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total); - void dispatchReadyStateChangeEvent(PassRefPtr<Event>, ProgressEventAction = DoNotFlushProgressEvent); - void dispatchEvent(PassRefPtr<Event>); - void dispatchEventAndLoadEnd(const AtomicString&, bool, unsigned long long, unsigned long long); + // Dispatches a ProgressEvent. + // + // Special treatment for events named "progress" is implemented to dispatch + // them at the required frequency. If this object is suspended, the given + // ProgressEvent overwrites the existing. I.e. only the latest one gets + // queued. If the timer is running, this method just updates + // m_lengthComputable, m_loaded and m_total. They'll be used on next + // fired() call. + void dispatchProgressEvent(const AtomicString&, bool lengthComputable, unsigned long long loaded, unsigned long long total); + void dispatchReadyStateChangeEvent(PassRefPtrWillBeRawPtr<Event>, ProgressEventAction = DoNotFlushProgressEvent); void suspend(); void resume(); + void trace(Visitor*); + private: static const double minimumProgressEventDispatchingIntervalInSeconds; - virtual void fired(); + // Dispatches an event. If suspended, just queues the given event. + void dispatchEvent(PassRefPtrWillBeRawPtr<Event>); + + virtual void fired() OVERRIDE; void dispatchDeferredEvents(Timer<XMLHttpRequestProgressEventThrottle>*); bool flushDeferredProgressEvent(); void deliverProgressEvent(); bool hasEventToDispatch() const; - // Weak pointer to our XMLHttpRequest object as it is the one holding us. - EventTarget* m_target; + // Non-Oilpan, keep a weak pointer to our XMLHttpRequest object as it is + // the one holding us. With Oilpan, a simple strong Member can be used - + // this XMLHttpRequestProgressEventThrottle (part) object dies together + // with the XMLHttpRequest object. + RawPtrWillBeMember<EventTarget> m_target; bool m_lengthComputable; unsigned long long m_loaded; unsigned long long m_total; bool m_deferEvents; - RefPtr<Event> m_deferredProgressEvent; - Vector<RefPtr<Event> > m_deferredEvents; + RefPtrWillBeMember<Event> m_deferredProgressEvent; + WillBeHeapVector<RefPtrWillBeMember<Event> > m_deferredEvents; Timer<XMLHttpRequestProgressEventThrottle> m_dispatchDeferredEventsTimer; }; |