Changeset 161668 in webkit


Ignore:
Timestamp:
Jan 10, 2014 1:22:18 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Source/WebCore: Correctly set XHR loadend attributes (loaded and total).
https://bugs.webkit.org/show_bug.cgi?id=120828

Patch by Youenn Fablet <youennf@gmail.com> on 2014-01-10
Reviewed by Alexey Proskuryakov.

Added correct initialization of lengthComputable, loaded and total attributes
to XHR ProgressEvent events (load, loadstart, loadend, abort, error and timeout).

XMLHttpRequestProgressEventThrottle and XMLHttpRequestUpload now keep persistent knowledge
of m_loaded and m_total values with this patch.

Code refactoring to handle event dispatching in case of error in a single manner.
XMLHttpRequestProgressEventThrottle::dispatchProgressEvent is renamed as dispatchThrottledProgressEvent
XMLHttpRequestProgressEventThrottle::dispatchEventAndLoadend is replaced by dispatchProgressEvent(const AtomicString&)

Fixed assertion issues over bug 120828 patch

Tests: http/tests/xmlhttprequest/loadstart-event-init.html

http/tests/xmlhttprequest/onabort-progressevent-attributes.html
http/tests/xmlhttprequest/onload-progressevent-attributes.html
http/tests/xmlhttprequest/upload-onabort-progressevent-attributes.html
http/tests/xmlhttprequest/upload-onload-progressevent-attributes.html

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::callReadyStateChangeListener): changed readystatechange event from ProgressEvent to Event (not cancellable, not bubblable) to better match the spec
(WebCore::XMLHttpRequest::createRequest):
(WebCore::XMLHttpRequest::abort): code refactoring to handle error event dispatching in a single way
(WebCore::XMLHttpRequest::networkError): code refactoring to handle error event dispatching in a single way
(WebCore::XMLHttpRequest::abortError): code refactoring to handle error event dispatching in a single way
(WebCore::XMLHttpRequest::didSendData):
(WebCore::XMLHttpRequest::didReceiveData):
(WebCore::XMLHttpRequest::dispatchErrorEvents): dispatch progress events in case of error
(WebCore::XMLHttpRequest::didTimeout): code refactoring to handle error event dispatching in a single way

  • xml/XMLHttpRequest.h:
  • xml/XMLHttpRequestProgressEventThrottle.cpp: before the patch, the fact that a progress event is being throttled is stored indirectly (m_loaded or m_total not equal to zero). With the patch, this information is stored in m_hasThrottledProgressEvent. The m_loaded and m_total values are no longer set back to zero after a progress event is dispatched. This allows using these values to correctly initialize other ProgressEvent events (in particular loadend, abort, timeout...)

(WebCore::XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle):
(WebCore::XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent): always update the new m_loaded and m_total values. If progress event is not sent as part of the function call, store the fact that a progress event is being throttled through m_hasThrottledProgressEvent.
(WebCore::XMLHttpRequestProgressEventThrottle::dispatchProgressEvent): used to send any ProgressEvent event that is not be throttled
(WebCore::XMLHttpRequestProgressEventThrottle::flushProgressEvent): after the call, no progress event is throttled anymore
(WebCore::XMLHttpRequestProgressEventThrottle::fired): after the call, no progress event is throttled anymore
(WebCore::XMLHttpRequestProgressEventThrottle::hasEventToDispatch):
(WebCore::XMLHttpRequestProgressEventThrottle::suspend):

  • xml/XMLHttpRequestProgressEventThrottle.h: introduced m_hasThrottledProgressEvent which stores whether a progress event is being throttled and m_computableLength which is used to initialize ProgressEvent computableLength
  • xml/XMLHttpRequestUpload.cpp:

(WebCore::XMLHttpRequestUpload::XMLHttpRequestUpload):
(WebCore::XMLHttpRequestUpload::dispatchProgressEvent):

  • xml/XMLHttpRequestUpload.h: introduced m_loaded, m_total and m_lengthComputable, similarly to XMLHttpRequestProgressEventThrottle

LayoutTests: Correctly set XHR loadend event attributes (loaded and total).
https://bugs.webkit.org/show_bug.cgi?id=120828

Patch by Youenn Fablet <youennf@gmail.com> on 2014-01-10
Reviewed by Alexey Proskuryakov.

Tests for abort, load, loadstart and loadend ProgressEvent events for XMLHttpRequest and XMLHttpRequestUpload

  • fast/xmlhttprequest/xmlhttprequest-get-expected.txt: Changed to correct event values
  • http/tests/xmlhttprequest/loadstart-event-init-expected.txt: Added.
  • http/tests/xmlhttprequest/loadstart-event-init.html: Added.
  • http/tests/xmlhttprequest/onabort-progressevent-attributes-expected.txt: Added.
  • http/tests/xmlhttprequest/onabort-progressevent-attributes.html: Added.
  • http/tests/xmlhttprequest/onload-progressevent-attributes-expected.txt: Added.
  • http/tests/xmlhttprequest/onload-progressevent-attributes.html: Added.
  • http/tests/xmlhttprequest/upload-onabort-progressevent-attributes-expected.txt: Added.
  • http/tests/xmlhttprequest/upload-onabort-progressevent-attributes.html: Added.
  • http/tests/xmlhttprequest/upload-onload-progressevent-attributes-expected.txt: Added.
  • http/tests/xmlhttprequest/upload-onload-progressevent-attributes.html: Added.
Location:
trunk
Files:
10 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r161666 r161668  
     12014-01-10  Youenn Fablet  <youennf@gmail.com>
     2
     3        Correctly set XHR loadend event attributes (loaded and total).
     4        https://bugs.webkit.org/show_bug.cgi?id=120828
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Tests for abort, load, loadstart and loadend ProgressEvent events for XMLHttpRequest and XMLHttpRequestUpload
     9
     10        * fast/xmlhttprequest/xmlhttprequest-get-expected.txt: Changed to correct event values
     11        * http/tests/xmlhttprequest/loadstart-event-init-expected.txt: Added.
     12        * http/tests/xmlhttprequest/loadstart-event-init.html: Added.
     13        * http/tests/xmlhttprequest/onabort-progressevent-attributes-expected.txt: Added.
     14        * http/tests/xmlhttprequest/onabort-progressevent-attributes.html: Added.
     15        * http/tests/xmlhttprequest/onload-progressevent-attributes-expected.txt: Added.
     16        * http/tests/xmlhttprequest/onload-progressevent-attributes.html: Added.
     17        * http/tests/xmlhttprequest/upload-onabort-progressevent-attributes-expected.txt: Added.
     18        * http/tests/xmlhttprequest/upload-onabort-progressevent-attributes.html: Added.
     19        * http/tests/xmlhttprequest/upload-onload-progressevent-attributes-expected.txt: Added.
     20        * http/tests/xmlhttprequest/upload-onload-progressevent-attributes.html: Added.
     21
    1222014-01-10  Mario Sanchez Prada  <mario.prada@samsung.com>
    223
  • trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-get-expected.txt

    r161541 r161668  
    5454    [native code]
    5555}'
    56 lengthComputable : 'false'
    57 loaded : '0'
    58 position : '0'
     56lengthComputable : 'true'
     57loaded : '174'
     58position : '174'
    5959preventDefault : 'function preventDefault() {
    6060    [native code]
     
    6969}'
    7070target : '[object XMLHttpRequest]'
    71 total : '0'
    72 totalSize : '0'
     71total : '174'
     72totalSize : '174'
    7373type : 'load'
    7474
  • trunk/Source/WebCore/ChangeLog

    r161667 r161668  
     12014-01-10  Youenn Fablet  <youennf@gmail.com>
     2
     3
     4        Correctly set XHR loadend attributes (loaded and total).
     5        https://bugs.webkit.org/show_bug.cgi?id=120828
     6
     7        Reviewed by Alexey Proskuryakov.
     8       
     9        Added correct initialization of lengthComputable, loaded and total attributes
     10        to XHR ProgressEvent events (load, loadstart, loadend, abort, error and timeout).
     11
     12        XMLHttpRequestProgressEventThrottle and XMLHttpRequestUpload now keep persistent knowledge
     13        of m_loaded and m_total values with this patch.
     14       
     15        Code refactoring to handle event dispatching in case of error in a single manner.
     16        XMLHttpRequestProgressEventThrottle::dispatchProgressEvent is renamed as dispatchThrottledProgressEvent
     17        XMLHttpRequestProgressEventThrottle::dispatchEventAndLoadend is replaced by dispatchProgressEvent(const AtomicString&)
     18       
     19        Fixed assertion issues over bug 120828 patch
     20
     21        Tests: http/tests/xmlhttprequest/loadstart-event-init.html
     22               http/tests/xmlhttprequest/onabort-progressevent-attributes.html
     23               http/tests/xmlhttprequest/onload-progressevent-attributes.html
     24               http/tests/xmlhttprequest/upload-onabort-progressevent-attributes.html
     25               http/tests/xmlhttprequest/upload-onload-progressevent-attributes.html
     26
     27        * xml/XMLHttpRequest.cpp:
     28        (WebCore::XMLHttpRequest::callReadyStateChangeListener): changed readystatechange event from ProgressEvent to Event (not cancellable, not bubblable) to better match the spec
     29        (WebCore::XMLHttpRequest::createRequest):
     30        (WebCore::XMLHttpRequest::abort): code refactoring to handle error event dispatching in a single way
     31        (WebCore::XMLHttpRequest::networkError): code refactoring to handle error event dispatching in a single way
     32        (WebCore::XMLHttpRequest::abortError): code refactoring to handle error event dispatching in a single way
     33        (WebCore::XMLHttpRequest::didSendData):
     34        (WebCore::XMLHttpRequest::didReceiveData):
     35        (WebCore::XMLHttpRequest::dispatchErrorEvents): dispatch progress events in case of error
     36        (WebCore::XMLHttpRequest::didTimeout): code refactoring to handle error event dispatching in a single way
     37        * xml/XMLHttpRequest.h:
     38        * xml/XMLHttpRequestProgressEventThrottle.cpp: before the patch, the fact that a progress event is being throttled is stored indirectly (m_loaded or m_total not equal to zero). With the patch, this information is stored in m_hasThrottledProgressEvent. The m_loaded and m_total values are no longer set back to zero after a progress event is dispatched. This allows using these values to correctly initialize other ProgressEvent events (in particular loadend, abort, timeout...)
     39        (WebCore::XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle):
     40        (WebCore::XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent): always update the new m_loaded and m_total values. If progress event is not sent as part of the function call, store the fact that a progress event is being throttled through m_hasThrottledProgressEvent.
     41        (WebCore::XMLHttpRequestProgressEventThrottle::dispatchProgressEvent): used to send any ProgressEvent event that is not be throttled
     42        (WebCore::XMLHttpRequestProgressEventThrottle::flushProgressEvent): after the call, no progress event is throttled anymore
     43        (WebCore::XMLHttpRequestProgressEventThrottle::fired): after the call, no progress event is throttled anymore
     44        (WebCore::XMLHttpRequestProgressEventThrottle::hasEventToDispatch):
     45        (WebCore::XMLHttpRequestProgressEventThrottle::suspend):
     46        * xml/XMLHttpRequestProgressEventThrottle.h: introduced m_hasThrottledProgressEvent which stores whether a progress event is being throttled and m_computableLength which is used to initialize ProgressEvent computableLength
     47        * xml/XMLHttpRequestUpload.cpp:
     48        (WebCore::XMLHttpRequestUpload::XMLHttpRequestUpload):
     49        (WebCore::XMLHttpRequestUpload::dispatchProgressEvent):
     50        * xml/XMLHttpRequestUpload.h: introduced m_loaded, m_total and m_lengthComputable, similarly to XMLHttpRequestProgressEventThrottle
     51
    1522014-01-10  Bear Travis  <betravis@adobe.com>
    253
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r161662 r161668  
    431431
    432432    if (m_async || (m_state <= OPENED || m_state == DONE))
    433         m_progressEventThrottle.dispatchReadyStateChangeEvent(XMLHttpRequestProgressEvent::create(eventNames().readystatechangeEvent), m_state == DONE ? FlushProgressEvent : DoNotFlushProgressEvent);
     433        m_progressEventThrottle.dispatchReadyStateChangeEvent(Event::create(eventNames().readystatechangeEvent, false, false), m_state == DONE ? FlushProgressEvent : DoNotFlushProgressEvent);
    434434
    435435    InspectorInstrumentation::didDispatchXHRReadyStateChangeEvent(cookie);
    436436    if (m_state == DONE && !m_error) {
    437437        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willDispatchXHRLoadEvent(scriptExecutionContext(), this);
    438         m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadEvent));
     438        m_progressEventThrottle.dispatchProgressEvent(eventNames().loadEvent);
    439439        InspectorInstrumentation::didDispatchXHRLoadEvent(cookie);
    440         m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadendEvent));
     440        m_progressEventThrottle.dispatchProgressEvent(eventNames().loadendEvent);
    441441    }
    442442}
     
    766766    bool uploadEvents = false;
    767767    if (m_async) {
    768         m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadstartEvent));
     768        m_progressEventThrottle.dispatchProgressEvent(eventNames().loadstartEvent);
    769769        if (m_requestEntityBody && m_upload) {
    770770            uploadEvents = m_upload->hasEventListeners();
    771             m_upload->dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadstartEvent));
     771            m_upload->dispatchProgressEvent(eventNames().loadstartEvent);
    772772        }
    773773    }
     
    860860    }
    861861
    862     m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
    863     if (!m_uploadComplete) {
    864         m_uploadComplete = true;
    865         if (m_upload && m_uploadEventsAllowed)
    866             m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
    867     }
     862    dispatchErrorEvents(eventNames().abortEvent);
    868863}
    869864
     
    926921{
    927922    genericError();
    928     if (!m_uploadComplete) {
    929         m_uploadComplete = true;
    930         if (m_upload && m_uploadEventsAllowed)
    931             m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().errorEvent));
    932     }
    933     m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().errorEvent));
     923    dispatchErrorEvents(eventNames().errorEvent);
    934924    internalAbort();
    935925}
     
    938928{
    939929    genericError();
    940     if (!m_uploadComplete) {
    941         m_uploadComplete = true;
    942         if (m_upload && m_uploadEventsAllowed)
    943             m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
    944     }
    945     m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
     930    dispatchErrorEvents(eventNames().abortEvent);
    946931}
    947932
     
    11771162
    11781163    if (m_uploadEventsAllowed)
    1179         m_upload->dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, true, bytesSent, totalBytesToBeSent));
    1180 
     1164        m_upload->dispatchThrottledProgressEvent(true, bytesSent, totalBytesToBeSent);
    11811165    if (bytesSent == totalBytesToBeSent && !m_uploadComplete) {
    11821166        m_uploadComplete = true;
    1183         if (m_uploadEventsAllowed)
    1184             m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().loadEvent));
     1167        if (m_uploadEventsAllowed) {
     1168            m_upload->dispatchProgressEvent(eventNames().loadEvent);
     1169            m_upload->dispatchProgressEvent(eventNames().loadendEvent);
     1170        }
    11851171    }
    11861172}
     
    12401226
    12411227    if (!m_error) {
    1242         long long expectedLength = m_response.expectedContentLength();
    12431228        m_receivedLength += len;
    12441229
    12451230        if (m_async) {
     1231            long long expectedLength = m_response.expectedContentLength();
    12461232            bool lengthComputable = expectedLength > 0 && m_receivedLength <= expectedLength;
    12471233            unsigned long long total = lengthComputable ? expectedLength : 0;
    1248             m_progressEventThrottle.dispatchProgressEvent(lengthComputable, m_receivedLength, total);
     1234            m_progressEventThrottle.dispatchThrottledProgressEvent(lengthComputable, m_receivedLength, total);
    12491235        }
    12501236
     
    12571243}
    12581244
     1245void XMLHttpRequest::dispatchErrorEvents(const AtomicString& type)
     1246{
     1247    if (!m_uploadComplete) {
     1248        m_uploadComplete = true;
     1249        if (m_upload && m_uploadEventsAllowed) {
     1250            m_upload->dispatchProgressEvent(type);
     1251            m_upload->dispatchProgressEvent(eventNames().loadendEvent);
     1252        }
     1253    }
     1254    m_progressEventThrottle.dispatchProgressEvent(type);
     1255    m_progressEventThrottle.dispatchProgressEvent(eventNames().loadendEvent);
     1256}
     1257
    12591258#if ENABLE(XHR_TIMEOUT)
    12601259void XMLHttpRequest::didTimeout()
     
    12781277    changeState(DONE);
    12791278
    1280     if (!m_uploadComplete) {
    1281         m_uploadComplete = true;
    1282         if (m_upload && m_uploadEventsAllowed)
    1283             m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().timeoutEvent));
    1284     }
    1285     m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().timeoutEvent));
     1279    dispatchErrorEvents(eventNames().timeoutEvent);
    12861280}
    12871281#endif
  • trunk/Source/WebCore/xml/XMLHttpRequest.h

    r161541 r161668  
    209209    bool shouldDecodeResponse() const { return m_responseTypeCode < FirstBinaryResponseType; }
    210210
     211    void dispatchErrorEvents(const AtomicString&);
     212
    211213    std::unique_ptr<XMLHttpRequestUpload> m_upload;
    212214
  • trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp

    r161541 r161668  
    3737XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle(EventTarget* target)
    3838    : m_target(target)
     39    , m_hasThrottledProgressEvent(false)
     40    , m_lengthComputable(false)
    3941    , m_loaded(0)
    4042    , m_total(0)
     
    4951}
    5052
    51 void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total)
    52 {
     53void 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   
    5359    if (m_deferEvents) {
    5460        // Only store the latest progress event while suspended.
     
    6167        // Just go ahead and dispatch the event.
    6268
    63         // We should not have any pending loaded & total information from a previous run.
    64         ASSERT(!m_loaded);
    65         ASSERT(!m_total);
     69        // We should not have any throttled progress event.
     70        ASSERT(!m_hasThrottledProgressEvent);
    6671
    6772        dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, lengthComputable, loaded, total));
    6873        startRepeating(minimumProgressEventDispatchingIntervalInSeconds);
     74        m_hasThrottledProgressEvent = false;
    6975        return;
    7076    }
    7177
    7278    // The timer is already active so minimumProgressEventDispatchingIntervalInSeconds is the least frequent event.
    73     m_lengthComputable = lengthComputable;
    74     m_loaded = loaded;
    75     m_total = total;
     79    m_hasThrottledProgressEvent = true;
    7680}
    7781
     
    97101}
    98102
    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));
     103void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(const AtomicString &type)
     104{
     105    ASSERT(type == eventNames().loadEvent || type == eventNames().loadendEvent || type == eventNames().loadstartEvent || type == eventNames().abortEvent || type == eventNames().errorEvent || type == eventNames().timeoutEvent);
     106
     107    if (type == eventNames().loadstartEvent) {
     108        m_lengthComputable = false;
     109        m_loaded = 0;
     110        m_total = 0;
     111    }
     112
     113    dispatchEvent(XMLHttpRequestProgressEvent::create(type, m_lengthComputable, m_loaded, m_total));
    105114}
    106115
     
    116125    if (!hasEventToDispatch())
    117126        return;
    118 
    119127    PassRefPtr<Event> event = XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total);
    120     m_loaded = 0;
    121     m_total = 0;
     128    m_hasThrottledProgressEvent = false;
    122129
    123130    // We stop the timer as this is called when no more events are supposed to occur.
     
    161168
    162169    dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total));
    163     m_total = 0;
    164     m_loaded = 0;
     170    m_hasThrottledProgressEvent = false;
    165171}
    166172
    167173bool XMLHttpRequestProgressEventThrottle::hasEventToDispatch() const
    168174{
    169     return (m_total || m_loaded) && isActive();
     175    return m_hasThrottledProgressEvent && isActive();
    170176}
    171177
     
    188194    if (hasEventToDispatch()) {
    189195        m_deferredProgressEvent = XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total);
    190         m_total = 0;
    191         m_loaded = 0;
     196        m_hasThrottledProgressEvent = false;
    192197    }
    193198    stop();
     
    196201void XMLHttpRequestProgressEventThrottle::resume()
    197202{
    198     ASSERT(!m_loaded);
    199     ASSERT(!m_total);
     203    ASSERT(!m_hasThrottledProgressEvent);
    200204
    201205    if (m_deferredEvents.isEmpty() && !m_deferredProgressEvent) {
  • trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.h

    r161541 r161668  
    3131#include "wtf/PassRefPtr.h"
    3232#include "wtf/Vector.h"
     33#include <wtf/Forward.h>
    3334
    3435namespace WebCore {
     
    4950    virtual ~XMLHttpRequestProgressEventThrottle();
    5051
    51     void dispatchProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total);
     52    void dispatchThrottledProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total);
    5253    void dispatchReadyStateChangeEvent(PassRefPtr<Event>, ProgressEventAction = DoNotFlushProgressEvent);
    5354    void dispatchEvent(PassRefPtr<Event>);
    54     void dispatchEventAndLoadEnd(PassRefPtr<Event>);
     55    void dispatchProgressEvent(const AtomicString&);
    5556
    5657    void suspend();
     
    6970    EventTarget* m_target;
    7071
     72    bool m_hasThrottledProgressEvent;
    7173    bool m_lengthComputable;
    7274    unsigned long long m_loaded;
  • trunk/Source/WebCore/xml/XMLHttpRequestUpload.cpp

    r161541 r161668  
    3737XMLHttpRequestUpload::XMLHttpRequestUpload(XMLHttpRequest* xmlHttpRequest)
    3838    : m_xmlHttpRequest(xmlHttpRequest)
     39    , m_lengthComputable(false)
     40    , m_loaded(0)
     41    , m_total(0)
    3942{
    4043}
    4144
    42 void XMLHttpRequestUpload::dispatchEventAndLoadEnd(PassRefPtr<Event> event)
     45void XMLHttpRequestUpload::dispatchThrottledProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total)
    4346{
    44     ASSERT(event->type() == eventNames().loadEvent || event->type() == eventNames().abortEvent || event->type() == eventNames().errorEvent || event->type() == eventNames().timeoutEvent);
     47    m_lengthComputable = lengthComputable;
     48    m_loaded = loaded;
     49    m_total = total;
    4550
    46     dispatchEvent(event);
    47     dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadendEvent));
     51    dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, lengthComputable, loaded, total));
     52}
     53
     54void XMLHttpRequestUpload::dispatchProgressEvent(const AtomicString &type)
     55{
     56    ASSERT(type == eventNames().loadEvent || type == eventNames().loadendEvent || type == eventNames().loadstartEvent || type == eventNames().abortEvent || type == eventNames().errorEvent || type == eventNames().timeoutEvent);
     57
     58    if (type == eventNames().loadstartEvent) {
     59        m_lengthComputable = false;
     60        m_loaded = 0;
     61        m_total = 0;
     62    }
     63
     64    dispatchEvent(XMLHttpRequestProgressEvent::create(type, m_lengthComputable, m_loaded, m_total));
    4865}
    4966
    5067
    51 
    5268} // namespace WebCore
  • trunk/Source/WebCore/xml/XMLHttpRequestUpload.h

    r161541 r161668  
    5656        DEFINE_ATTRIBUTE_EVENT_LISTENER(progress);
    5757
    58         void dispatchEventAndLoadEnd(PassRefPtr<Event>);
     58        void dispatchThrottledProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total);
     59        void dispatchProgressEvent(const AtomicString &type);
    5960
    6061    private:
     
    6364
    6465        XMLHttpRequest* m_xmlHttpRequest;
     66        bool m_lengthComputable;
     67        unsigned long long m_loaded;
     68        unsigned long long m_total;
    6569    };
    6670   
Note: See TracChangeset for help on using the changeset viewer.