Changeset 161532 in webkit for trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp
- Timestamp:
- Jan 8, 2014, 6:11:59 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp
r157653 r161532 37 37 XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle(EventTarget* target) 38 38 : m_target(target) 39 , m_hasThrottledProgressEvent(false) 40 , m_lengthComputable(false) 39 41 , m_loaded(0) 40 42 , m_total(0) … … 49 51 } 50 52 51 void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total) 52 { 53 void XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total) 54 { 55 m_lengthComputable = lengthComputable; 56 m_loaded = loaded; 57 m_total = total; 58 53 59 if (m_deferEvents) { 54 60 // Only store the latest progress event while suspended. … … 67 73 dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, lengthComputable, loaded, total)); 68 74 startRepeating(minimumProgressEventDispatchingIntervalInSeconds); 75 m_hasThrottledProgressEvent = false; 69 76 return; 70 77 } 71 78 72 79 // The timer is already active so minimumProgressEventDispatchingIntervalInSeconds is the least frequent event. 73 m_lengthComputable = lengthComputable; 74 m_loaded = loaded; 75 m_total = total; 80 m_hasThrottledProgressEvent = true; 76 81 } 77 82 … … 97 102 } 98 103 99 void XMLHttpRequestProgressEventThrottle::dispatchEventAndLoadEnd(PassRefPtr<Event> event) 100 { 101 ASSERT(event->type() == eventNames().loadEvent || event->type() == eventNames().abortEvent || event->type() == eventNames().errorEvent || event->type() == eventNames().timeoutEvent); 102 103 dispatchEvent(event); 104 dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadendEvent)); 104 void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(const AtomicString &type) 105 { 106 ASSERT(type == eventNames().loadEvent || type == eventNames().loadstartEvent || type == eventNames().abortEvent || type == eventNames().errorEvent || type == eventNames().timeoutEvent); 107 108 if (type == eventNames().loadstartEvent) { 109 m_lengthComputable = false; 110 m_loaded = 0; 111 m_total = 0; 112 } 113 114 dispatchEvent(XMLHttpRequestProgressEvent::create(type, m_lengthComputable, m_loaded, m_total)); 105 115 } 106 116 … … 116 126 if (!hasEventToDispatch()) 117 127 return; 118 119 128 PassRefPtr<Event> event = XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total); 120 m_loaded = 0; 121 m_total = 0; 129 m_hasThrottledProgressEvent = false; 122 130 123 131 // We stop the timer as this is called when no more events are supposed to occur. … … 161 169 162 170 dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total)); 163 m_total = 0; 164 m_loaded = 0; 171 m_hasThrottledProgressEvent = false; 165 172 } 166 173 167 174 bool XMLHttpRequestProgressEventThrottle::hasEventToDispatch() const 168 175 { 169 return (m_total || m_loaded)&& isActive();176 return m_hasThrottledProgressEvent && isActive(); 170 177 } 171 178 … … 188 195 if (hasEventToDispatch()) { 189 196 m_deferredProgressEvent = XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total); 190 m_total = 0; 191 m_loaded = 0; 197 m_hasThrottledProgressEvent = false; 192 198 } 193 199 stop();
Note:
See TracChangeset
for help on using the changeset viewer.