| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> All right reserv
ed. | 2 * Copyright (C) 2010 Julien Chaffraix <jchaffraix@webkit.org> All right reserv
ed. |
| 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 // The timer is already active so minimumProgressEventDispatchingIntervalInS
econds is the least frequent event. | 72 // The timer is already active so minimumProgressEventDispatchingIntervalInS
econds is the least frequent event. |
| 73 m_lengthComputable = lengthComputable; | 73 m_lengthComputable = lengthComputable; |
| 74 m_loaded = loaded; | 74 m_loaded = loaded; |
| 75 m_total = total; | 75 m_total = total; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(PassRefP
tr<Event> event, ProgressEventAction progressEventAction) | 78 void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(PassRefP
tr<Event> event, ProgressEventAction progressEventAction) |
| 79 { | 79 { |
| 80 if (progressEventAction == FlushProgressEvent) | 80 if (progressEventAction == FlushProgressEvent || progressEventAction == Flus
hDeferredProgressEvent) { |
| 81 flushProgressEvent(); | 81 if (!flushDeferredProgressEvent() && progressEventAction == FlushProgres
sEvent) |
| 82 deliverProgressEvent(); |
| 83 } |
| 82 | 84 |
| 83 dispatchEvent(event); | 85 dispatchEvent(event); |
| 84 } | 86 } |
| 85 | 87 |
| 86 void XMLHttpRequestProgressEventThrottle::dispatchEvent(PassRefPtr<Event> event) | 88 void XMLHttpRequestProgressEventThrottle::dispatchEvent(PassRefPtr<Event> event) |
| 87 { | 89 { |
| 88 ASSERT(event); | 90 ASSERT(event); |
| 89 if (m_deferEvents) { | 91 if (m_deferEvents) { |
| 90 if (m_deferredEvents.size() > 1 && event->type() == EventTypeNames::read
ystatechange && event->type() == m_deferredEvents.last()->type()) { | 92 if (m_deferredEvents.size() > 1 && event->type() == EventTypeNames::read
ystatechange && event->type() == m_deferredEvents.last()->type()) { |
| 91 // Readystatechange events are state-less so avoid repeating two ide
ntical events in a row on resume. | 93 // Readystatechange events are state-less so avoid repeating two ide
ntical events in a row on resume. |
| 92 return; | 94 return; |
| 93 } | 95 } |
| 94 m_deferredEvents.append(event); | 96 m_deferredEvents.append(event); |
| 95 } else | 97 } else |
| 96 m_target->dispatchEvent(event); | 98 m_target->dispatchEvent(event); |
| 97 } | 99 } |
| 98 | 100 |
| 99 void XMLHttpRequestProgressEventThrottle::dispatchEventAndLoadEnd(PassRefPtr<Eve
nt> event) | 101 void XMLHttpRequestProgressEventThrottle::dispatchEventAndLoadEnd(PassRefPtr<Eve
nt> event) |
| 100 { | 102 { |
| 101 ASSERT(event->type() == EventTypeNames::load || event->type() == EventTypeNa
mes::abort || event->type() == EventTypeNames::error || event->type() == EventTy
peNames::timeout); | 103 ASSERT(event->type() == EventTypeNames::load || event->type() == EventTypeNa
mes::abort || event->type() == EventTypeNames::error || event->type() == EventTy
peNames::timeout); |
| 102 | 104 |
| 103 dispatchEvent(event); | 105 dispatchEvent(event); |
| 104 dispatchEvent(XMLHttpRequestProgressEvent::create(EventTypeNames::loadend)); | 106 dispatchEvent(XMLHttpRequestProgressEvent::create(EventTypeNames::loadend)); |
| 105 } | 107 } |
| 106 | 108 |
| 107 void XMLHttpRequestProgressEventThrottle::flushProgressEvent() | 109 bool XMLHttpRequestProgressEventThrottle::flushDeferredProgressEvent() |
| 108 { | 110 { |
| 109 if (m_deferEvents && m_deferredProgressEvent) { | 111 if (m_deferEvents && m_deferredProgressEvent) { |
| 110 // Move the progress event to the queue, to get it in the right order on
resume. | 112 // Move the progress event to the queue, to get it in the right order on
resume. |
| 111 m_deferredEvents.append(m_deferredProgressEvent); | 113 m_deferredEvents.append(m_deferredProgressEvent); |
| 112 m_deferredProgressEvent = 0; | 114 m_deferredProgressEvent = 0; |
| 113 return; | 115 return true; |
| 114 } | 116 } |
| 117 return false; |
| 118 } |
| 115 | 119 |
| 120 void XMLHttpRequestProgressEventThrottle::deliverProgressEvent() |
| 121 { |
| 116 if (!hasEventToDispatch()) | 122 if (!hasEventToDispatch()) |
| 117 return; | 123 return; |
| 118 | 124 |
| 119 PassRefPtr<Event> event = XMLHttpRequestProgressEvent::create(EventTypeNames
::progress, m_lengthComputable, m_loaded, m_total); | 125 PassRefPtr<Event> event = XMLHttpRequestProgressEvent::create(EventTypeNames
::progress, m_lengthComputable, m_loaded, m_total); |
| 120 m_loaded = 0; | 126 m_loaded = 0; |
| 121 m_total = 0; | 127 m_total = 0; |
| 122 | 128 |
| 123 // We stop the timer as this is called when no more events are supposed to o
ccur. | 129 // We stop the timer as this is called when no more events are supposed to o
ccur. |
| 124 stop(); | 130 stop(); |
| 125 | 131 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 210 } |
| 205 | 211 |
| 206 // Do not dispatch events inline here, since ExecutionContext is iterating o
ver | 212 // Do not dispatch events inline here, since ExecutionContext is iterating o
ver |
| 207 // the list of active DOM objects to resume them, and any activated JS event
-handler | 213 // the list of active DOM objects to resume them, and any activated JS event
-handler |
| 208 // could insert new active DOM objects to the list. | 214 // could insert new active DOM objects to the list. |
| 209 // m_deferEvents is kept true until all deferred events have been dispatched
. | 215 // m_deferEvents is kept true until all deferred events have been dispatched
. |
| 210 m_dispatchDeferredEventsTimer.startOneShot(0); | 216 m_dispatchDeferredEventsTimer.startOneShot(0); |
| 211 } | 217 } |
| 212 | 218 |
| 213 } // namespace WebCore | 219 } // namespace WebCore |
| OLD | NEW |