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 29 matching lines...) Expand all Loading... |
40 | 40 |
41 enum ProgressEventAction { | 41 enum ProgressEventAction { |
42 DoNotFlushProgressEvent, | 42 DoNotFlushProgressEvent, |
43 FlushDeferredProgressEvent, | 43 FlushDeferredProgressEvent, |
44 FlushProgressEvent | 44 FlushProgressEvent |
45 }; | 45 }; |
46 | 46 |
47 // This implements the XHR2 progress event dispatching: "dispatch a progress eve
nt called progress | 47 // This implements the XHR2 progress event dispatching: "dispatch a progress eve
nt called progress |
48 // about every 50ms or for every byte received, whichever is least frequent". | 48 // about every 50ms or for every byte received, whichever is least frequent". |
49 class XMLHttpRequestProgressEventThrottle FINAL : public TimerBase { | 49 class XMLHttpRequestProgressEventThrottle FINAL : public TimerBase { |
| 50 DISALLOW_ALLOCATION(); |
50 public: | 51 public: |
51 explicit XMLHttpRequestProgressEventThrottle(EventTarget*); | 52 explicit XMLHttpRequestProgressEventThrottle(EventTarget*); |
52 virtual ~XMLHttpRequestProgressEventThrottle(); | 53 virtual ~XMLHttpRequestProgressEventThrottle(); |
53 | 54 |
54 void dispatchProgressEvent(bool lengthComputable, unsigned long long loaded,
unsigned long long total); | 55 void dispatchProgressEvent(bool lengthComputable, unsigned long long loaded,
unsigned long long total); |
55 void dispatchReadyStateChangeEvent(PassRefPtrWillBeRawPtr<Event>, ProgressEv
entAction = DoNotFlushProgressEvent); | 56 void dispatchReadyStateChangeEvent(PassRefPtrWillBeRawPtr<Event>, ProgressEv
entAction = DoNotFlushProgressEvent); |
56 void dispatchEvent(PassRefPtrWillBeRawPtr<Event>); | 57 void dispatchEvent(PassRefPtrWillBeRawPtr<Event>); |
57 void dispatchEventAndLoadEnd(const AtomicString&, bool, unsigned long long,
unsigned long long); | 58 void dispatchEventAndLoadEnd(const AtomicString&, bool, unsigned long long,
unsigned long long); |
58 | 59 |
59 void suspend(); | 60 void suspend(); |
60 void resume(); | 61 void resume(); |
61 | 62 |
| 63 void trace(Visitor*); |
| 64 |
62 private: | 65 private: |
63 static const double minimumProgressEventDispatchingIntervalInSeconds; | 66 static const double minimumProgressEventDispatchingIntervalInSeconds; |
64 | 67 |
65 virtual void fired() OVERRIDE; | 68 virtual void fired() OVERRIDE; |
66 void dispatchDeferredEvents(Timer<XMLHttpRequestProgressEventThrottle>*); | 69 void dispatchDeferredEvents(Timer<XMLHttpRequestProgressEventThrottle>*); |
67 bool flushDeferredProgressEvent(); | 70 bool flushDeferredProgressEvent(); |
68 void deliverProgressEvent(); | 71 void deliverProgressEvent(); |
69 | 72 |
70 bool hasEventToDispatch() const; | 73 bool hasEventToDispatch() const; |
71 | 74 |
72 // Weak pointer to our XMLHttpRequest object as it is the one holding us. | 75 // Weak pointer to our XMLHttpRequest object as it is the one holding us. |
73 EventTarget* m_target; | 76 EventTarget* m_target; |
74 | 77 |
75 bool m_lengthComputable; | 78 bool m_lengthComputable; |
76 unsigned long long m_loaded; | 79 unsigned long long m_loaded; |
77 unsigned long long m_total; | 80 unsigned long long m_total; |
78 | 81 |
79 bool m_deferEvents; | 82 bool m_deferEvents; |
80 RefPtrWillBePersistent<Event> m_deferredProgressEvent; | 83 RefPtrWillBeMember<Event> m_deferredProgressEvent; |
81 WillBePersistentHeapVector<RefPtrWillBeMember<Event> > m_deferredEvents; | 84 WillBeHeapVector<RefPtrWillBeMember<Event> > m_deferredEvents; |
82 Timer<XMLHttpRequestProgressEventThrottle> m_dispatchDeferredEventsTimer; | 85 Timer<XMLHttpRequestProgressEventThrottle> m_dispatchDeferredEventsTimer; |
83 }; | 86 }; |
84 | 87 |
85 } // namespace WebCore | 88 } // namespace WebCore |
86 | 89 |
87 #endif // XMLHttpRequestProgressEventThrottle_h | 90 #endif // XMLHttpRequestProgressEventThrottle_h |
OLD | NEW |