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 12 matching lines...) Expand all Loading... |
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #ifndef XMLHttpRequestProgressEventThrottle_h | 27 #ifndef XMLHttpRequestProgressEventThrottle_h |
28 #define XMLHttpRequestProgressEventThrottle_h | 28 #define XMLHttpRequestProgressEventThrottle_h |
29 | 29 |
30 #include "platform/Timer.h" | 30 #include "platform/Timer.h" |
31 #include "wtf/PassRefPtr.h" | 31 #include "wtf/PassRefPtr.h" |
32 #include "wtf/Vector.h" | 32 #include "wtf/Vector.h" |
| 33 #include "wtf/text/AtomicString.h" |
33 | 34 |
34 namespace WebCore { | 35 namespace WebCore { |
35 | 36 |
36 class Event; | 37 class Event; |
37 class EventTarget; | 38 class EventTarget; |
38 | 39 |
39 enum ProgressEventAction { | 40 enum ProgressEventAction { |
40 DoNotFlushProgressEvent, | 41 DoNotFlushProgressEvent, |
41 FlushDeferredProgressEvent, | 42 FlushDeferredProgressEvent, |
42 FlushProgressEvent | 43 FlushProgressEvent |
43 }; | 44 }; |
44 | 45 |
45 // 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 |
46 // 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". |
47 class XMLHttpRequestProgressEventThrottle : public TimerBase { | 48 class XMLHttpRequestProgressEventThrottle : public TimerBase { |
48 public: | 49 public: |
49 explicit XMLHttpRequestProgressEventThrottle(EventTarget*); | 50 explicit XMLHttpRequestProgressEventThrottle(EventTarget*); |
50 virtual ~XMLHttpRequestProgressEventThrottle(); | 51 virtual ~XMLHttpRequestProgressEventThrottle(); |
51 | 52 |
52 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); |
53 void dispatchReadyStateChangeEvent(PassRefPtr<Event>, ProgressEventAction =
DoNotFlushProgressEvent); | 54 void dispatchReadyStateChangeEvent(PassRefPtr<Event>, ProgressEventAction =
DoNotFlushProgressEvent); |
54 void dispatchEvent(PassRefPtr<Event>); | 55 void dispatchEvent(PassRefPtr<Event>); |
55 void dispatchEventAndLoadEnd(PassRefPtr<Event>); | 56 void dispatchEventAndLoadEnd(const AtomicString&, bool, unsigned long long,
unsigned long long); |
56 | 57 |
57 void suspend(); | 58 void suspend(); |
58 void resume(); | 59 void resume(); |
59 | 60 |
60 private: | 61 private: |
61 static const double minimumProgressEventDispatchingIntervalInSeconds; | 62 static const double minimumProgressEventDispatchingIntervalInSeconds; |
62 | 63 |
63 virtual void fired(); | 64 virtual void fired(); |
64 void dispatchDeferredEvents(Timer<XMLHttpRequestProgressEventThrottle>*); | 65 void dispatchDeferredEvents(Timer<XMLHttpRequestProgressEventThrottle>*); |
65 bool flushDeferredProgressEvent(); | 66 bool flushDeferredProgressEvent(); |
(...skipping 10 matching lines...) Expand all Loading... |
76 | 77 |
77 bool m_deferEvents; | 78 bool m_deferEvents; |
78 RefPtr<Event> m_deferredProgressEvent; | 79 RefPtr<Event> m_deferredProgressEvent; |
79 Vector<RefPtr<Event> > m_deferredEvents; | 80 Vector<RefPtr<Event> > m_deferredEvents; |
80 Timer<XMLHttpRequestProgressEventThrottle> m_dispatchDeferredEventsTimer; | 81 Timer<XMLHttpRequestProgressEventThrottle> m_dispatchDeferredEventsTimer; |
81 }; | 82 }; |
82 | 83 |
83 } // namespace WebCore | 84 } // namespace WebCore |
84 | 85 |
85 #endif // XMLHttpRequestProgressEventThrottle_h | 86 #endif // XMLHttpRequestProgressEventThrottle_h |
OLD | NEW |