Changeset 161532 in webkit


Ignore:
Timestamp:
Jan 8, 2014 6:11:59 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-08
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&)

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-08
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

    r161521 r161532  
     12014-01-08  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-07  Myles C. Maxfield  <mmaxfield@apple.com>
    223
  • trunk/LayoutTests/fast/xmlhttprequest/xmlhttprequest-get-expected.txt

    r150949 r161532  
    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

    r161530 r161532  
     12014-01-08  Youenn Fablet  <youennf@gmail.com>
     2
     3        Correctly set XHR loadend attributes (loaded and total).
     4        https://bugs.webkit.org/show_bug.cgi?id=120828
     5
     6        Reviewed by Alexey Proskuryakov.
     7       
     8        Added correct initialization of lengthComputable, loaded and total attributes
     9        to XHR ProgressEvent events (load, loadstart, loadend, abort, error and timeout).
     10
     11        XMLHttpRequestProgressEventThrottle and XMLHttpRequestUpload now keep persistent knowledge
     12        of m_loaded and m_total values with this patch.
     13       
     14        Code refactoring to handle event dispatching in case of error in a single manner.
     15        XMLHttpRequestProgressEventThrottle::dispatchProgressEvent is renamed as dispatchThrottledProgressEvent
     16        XMLHttpRequestProgressEventThrottle::dispatchEventAndLoadend is replaced by dispatchProgressEvent(const AtomicString&)
     17
     18        Tests: http/tests/xmlhttprequest/loadstart-event-init.html
     19               http/tests/xmlhttprequest/onabort-progressevent-attributes.html
     20               http/tests/xmlhttprequest/onload-progressevent-attributes.html
     21               http/tests/xmlhttprequest/upload-onabort-progressevent-attributes.html
     22               http/tests/xmlhttprequest/upload-onload-progressevent-attributes.html
     23
     24        * xml/XMLHttpRequest.cpp:
     25        (WebCore::XMLHttpRequest::callReadyStateChangeListener): changed readystatechange event from ProgressEvent to Event (not cancellable, not bubblable) to better match the spec
     26        (WebCore::XMLHttpRequest::createRequest):
     27        (WebCore::XMLHttpRequest::abort): code refactoring to handle error event dispatching in a single way
     28        (WebCore::XMLHttpRequest::networkError): code refactoring to handle error event dispatching in a single way
     29        (WebCore::XMLHttpRequest::abortError): code refactoring to handle error event dispatching in a single way
     30        (WebCore::XMLHttpRequest::didSendData):
     31        (WebCore::XMLHttpRequest::didReceiveData):
     32        (WebCore::XMLHttpRequest::dispatchErrorEvents): dispatch progress events in case of error
     33        (WebCore::XMLHttpRequest::didTimeout): code refactoring to handle error event dispatching in a single way
     34        * xml/XMLHttpRequest.h:
     35        * 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...)
     36        (WebCore::XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle):
     37        (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.
     38        (WebCore::XMLHttpRequestProgressEventThrottle::dispatchProgressEvent): used to send any ProgressEvent event that is not be throttled
     39        (WebCore::XMLHttpRequestProgressEventThrottle::flushProgressEvent): after the call, no progress event is throttled anymore
     40        (WebCore::XMLHttpRequestProgressEventThrottle::fired): after the call, no progress event is throttled anymore
     41        (WebCore::XMLHttpRequestProgressEventThrottle::hasEventToDispatch):
     42        (WebCore::XMLHttpRequestProgressEventThrottle::suspend):
     43        * 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
     44        * xml/XMLHttpRequestUpload.cpp:
     45        (WebCore::XMLHttpRequestUpload::XMLHttpRequestUpload):
     46        (WebCore::XMLHttpRequestUpload::dispatchProgressEvent):
     47        * xml/XMLHttpRequestUpload.h: introduced m_loaded, m_total and m_lengthComputable, similarly to XMLHttpRequestProgressEventThrottle
     48
    1492014-01-08  Tim Horton  <timothy_horton@apple.com>
    250
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r161425 r161532  
    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    }
     
    863863    }
    864864
    865     m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
    866     if (!m_uploadComplete) {
    867         m_uploadComplete = true;
    868         if (m_upload && m_uploadEventsAllowed)
    869             m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
    870     }
     865    dispatchErrorEvents(eventNames().abortEvent);
    871866}
    872867
     
    929924{
    930925    genericError();
    931     if (!m_uploadComplete) {
    932         m_uploadComplete = true;
    933         if (m_upload && m_uploadEventsAllowed)
    934             m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().errorEvent));
    935     }
    936     m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().errorEvent));
     926    dispatchErrorEvents(eventNames().errorEvent);
    937927    internalAbort();
    938928}
     
    941931{
    942932    genericError();
    943     if (!m_uploadComplete) {
    944         m_uploadComplete = true;
    945         if (m_upload && m_uploadEventsAllowed)
    946             m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
    947     }
    948     m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));
     933    dispatchErrorEvents(eventNames().abortEvent);
    949934}
    950935
     
    11801165
    11811166    if (m_uploadEventsAllowed)
    1182         m_upload->dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, true, bytesSent, totalBytesToBeSent));
    1183 
     1167        m_upload->dispatchThrottledProgressEvent(true, bytesSent, totalBytesToBeSent);
    11841168    if (bytesSent == totalBytesToBeSent && !m_uploadComplete) {
    11851169        m_uploadComplete = true;
    1186         if (m_uploadEventsAllowed)
    1187             m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().loadEvent));
     1170        if (m_uploadEventsAllowed) {
     1171            m_upload->dispatchProgressEvent(eventNames().loadEvent);
     1172            m_upload->dispatchProgressEvent(eventNames().loadendEvent);
     1173        }
    11881174    }
    11891175}
     
    12431229
    12441230    if (!m_error) {
    1245         long long expectedLength = m_response.expectedContentLength();
    12461231        m_receivedLength += len;
    12471232
    12481233        if (m_async) {
     1234            long long expectedLength = m_response.expectedContentLength();
    12491235            bool lengthComputable = expectedLength > 0 && m_receivedLength <= expectedLength;
    12501236            unsigned long long total = lengthComputable ? expectedLength : 0;
    1251             m_progressEventThrottle.dispatchProgressEvent(lengthComputable, m_receivedLength, total);
     1237            m_progressEventThrottle.dispatchThrottledProgressEvent(lengthComputable, m_receivedLength, total);
    12521238        }
    12531239
     
    12601246}
    12611247
     1248void XMLHttpRequest::dispatchErrorEvents(const AtomicString& type)
     1249{
     1250    if (!m_uploadComplete) {
     1251        m_uploadComplete = true;
     1252        if (m_upload && m_uploadEventsAllowed) {
     1253            m_upload->dispatchProgressEvent(type);
     1254            m_upload->dispatchProgressEvent(eventNames().loadendEvent);
     1255        }
     1256    }
     1257    m_progressEventThrottle.dispatchProgressEvent(type);
     1258    m_progressEventThrottle.dispatchProgressEvent(eventNames().loadendEvent);
     1259}
     1260
    12621261#if ENABLE(XHR_TIMEOUT)
    12631262void XMLHttpRequest::didTimeout()
     
    12811280    changeState(DONE);
    12821281
    1283     if (!m_uploadComplete) {
    1284         m_uploadComplete = true;
    1285         if (m_upload && m_uploadEventsAllowed)
    1286             m_upload->dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().timeoutEvent));
    1287     }
    1288     m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().timeoutEvent));
     1282    dispatchErrorEvents(eventNames().timeoutEvent);
    12891283}
    12901284#endif
  • trunk/Source/WebCore/xml/XMLHttpRequest.h

    r161058 r161532  
    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

    r157653 r161532  
    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.
     
    6773        dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, lengthComputable, loaded, total));
    6874        startRepeating(minimumProgressEventDispatchingIntervalInSeconds);
     75        m_hasThrottledProgressEvent = false;
    6976        return;
    7077    }
    7178
    7279    // 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;
    7681}
    7782
     
    97102}
    98103
    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));
     104void 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));
    105115}
    106116
     
    116126    if (!hasEventToDispatch())
    117127        return;
    118 
    119128    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;
    122130
    123131    // We stop the timer as this is called when no more events are supposed to occur.
     
    161169
    162170    dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total));
    163     m_total = 0;
    164     m_loaded = 0;
     171    m_hasThrottledProgressEvent = false;
    165172}
    166173
    167174bool XMLHttpRequestProgressEventThrottle::hasEventToDispatch() const
    168175{
    169     return (m_total || m_loaded) && isActive();
     176    return m_hasThrottledProgressEvent && isActive();
    170177}
    171178
     
    188195    if (hasEventToDispatch()) {
    189196        m_deferredProgressEvent = XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total);
    190         m_total = 0;
    191         m_loaded = 0;
     197        m_hasThrottledProgressEvent = false;
    192198    }
    193199    stop();
  • trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.h

    r157653 r161532  
    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

    r161425 r161532  
    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().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

    r161425 r161532  
    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.