| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> | 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> |
| 3 * All right reserved. | 3 * All right reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 class EventTarget; | 38 class EventTarget; |
| 39 | 39 |
| 40 enum ProgressEventAction { | 40 enum ProgressEventAction { |
| 41 DoNotFlushProgressEvent, | 41 DoNotFlushProgressEvent, |
| 42 FlushDeferredProgressEvent, | 42 FlushDeferredProgressEvent, |
| 43 FlushProgressEvent | 43 FlushProgressEvent |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // This implements the XHR2 progress event dispatching: "dispatch a progress eve
nt called progress | 46 // This implements the XHR2 progress event dispatching: "dispatch a progress eve
nt called progress |
| 47 // about every 50ms or for every byte received, whichever is least frequent". | 47 // about every 50ms or for every byte received, whichever is least frequent". |
| 48 class XMLHttpRequestProgressEventThrottle : public TimerBase { | 48 class XMLHttpRequestProgressEventThrottle FINAL : public TimerBase { |
| 49 public: | 49 public: |
| 50 explicit XMLHttpRequestProgressEventThrottle(EventTarget*); | 50 explicit XMLHttpRequestProgressEventThrottle(EventTarget*); |
| 51 virtual ~XMLHttpRequestProgressEventThrottle(); | 51 virtual ~XMLHttpRequestProgressEventThrottle(); |
| 52 | 52 |
| 53 void dispatchProgressEvent(bool lengthComputable, unsigned long long loaded,
unsigned long long total); | 53 void dispatchProgressEvent(bool lengthComputable, unsigned long long loaded,
unsigned long long total); |
| 54 void dispatchReadyStateChangeEvent(PassRefPtr<Event>, ProgressEventAction =
DoNotFlushProgressEvent); | 54 void dispatchReadyStateChangeEvent(PassRefPtr<Event>, ProgressEventAction =
DoNotFlushProgressEvent); |
| 55 void dispatchEvent(PassRefPtr<Event>); | 55 void dispatchEvent(PassRefPtr<Event>); |
| 56 void dispatchEventAndLoadEnd(const AtomicString&, bool, unsigned long long,
unsigned long long); | 56 void dispatchEventAndLoadEnd(const AtomicString&, bool, unsigned long long,
unsigned long long); |
| 57 | 57 |
| 58 void suspend(); | 58 void suspend(); |
| 59 void resume(); | 59 void resume(); |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 static const double minimumProgressEventDispatchingIntervalInSeconds; | 62 static const double minimumProgressEventDispatchingIntervalInSeconds; |
| 63 | 63 |
| 64 virtual void fired(); | 64 virtual void fired() OVERRIDE; |
| 65 void dispatchDeferredEvents(Timer<XMLHttpRequestProgressEventThrottle>*); | 65 void dispatchDeferredEvents(Timer<XMLHttpRequestProgressEventThrottle>*); |
| 66 bool flushDeferredProgressEvent(); | 66 bool flushDeferredProgressEvent(); |
| 67 void deliverProgressEvent(); | 67 void deliverProgressEvent(); |
| 68 | 68 |
| 69 bool hasEventToDispatch() const; | 69 bool hasEventToDispatch() const; |
| 70 | 70 |
| 71 // Weak pointer to our XMLHttpRequest object as it is the one holding us. | 71 // Weak pointer to our XMLHttpRequest object as it is the one holding us. |
| 72 EventTarget* m_target; | 72 EventTarget* m_target; |
| 73 | 73 |
| 74 bool m_lengthComputable; | 74 bool m_lengthComputable; |
| 75 unsigned long long m_loaded; | 75 unsigned long long m_loaded; |
| 76 unsigned long long m_total; | 76 unsigned long long m_total; |
| 77 | 77 |
| 78 bool m_deferEvents; | 78 bool m_deferEvents; |
| 79 RefPtr<Event> m_deferredProgressEvent; | 79 RefPtr<Event> m_deferredProgressEvent; |
| 80 Vector<RefPtr<Event> > m_deferredEvents; | 80 Vector<RefPtr<Event> > m_deferredEvents; |
| 81 Timer<XMLHttpRequestProgressEventThrottle> m_dispatchDeferredEventsTimer; | 81 Timer<XMLHttpRequestProgressEventThrottle> m_dispatchDeferredEventsTimer; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace WebCore | 84 } // namespace WebCore |
| 85 | 85 |
| 86 #endif // XMLHttpRequestProgressEventThrottle_h | 86 #endif // XMLHttpRequestProgressEventThrottle_h |
| OLD | NEW |