Unreviewed, rolling out r243551.
[WebKit-https.git] / Source / WebCore / xml / XMLHttpRequestUpload.cpp
index 18c994a..8c06583 100644 (file)
 #include "config.h"
 #include "XMLHttpRequestUpload.h"
 
-#include "Event.h"
-#include "EventException.h"
 #include "EventNames.h"
-#include "XMLHttpRequest.h"
 #include "XMLHttpRequestProgressEvent.h"
 #include <wtf/Assertions.h>
 #include <wtf/text/AtomicString.h>
 
 namespace WebCore {
 
-XMLHttpRequestUpload::XMLHttpRequestUpload(XMLHttpRequest* xmlHttpRequest)
-    : m_xmlHttpRequest(xmlHttpRequest)
+XMLHttpRequestUpload::XMLHttpRequestUpload(XMLHttpRequest& request)
+    : m_request(request)
 {
 }
 
-void XMLHttpRequestUpload::dispatchEventAndLoadEnd(PassRefPtr<Event> event)
+void XMLHttpRequestUpload::dispatchThrottledProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total)
 {
-    ASSERT(event->type() == eventNames().loadEvent || event->type() == eventNames().abortEvent || event->type() == eventNames().errorEvent || event->type() == eventNames().timeoutEvent);
+    m_lengthComputable = lengthComputable;
+    m_loaded = loaded;
+    m_total = total;
 
-    dispatchEvent(event);
-    dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadendEvent));
+    dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, lengthComputable, loaded, total));
 }
 
+void XMLHttpRequestUpload::dispatchProgressEvent(const AtomicString& type)
+{
+    ASSERT(type == eventNames().loadstartEvent || type == eventNames().progressEvent || type == eventNames().loadEvent || type == eventNames().loadendEvent || type == eventNames().abortEvent || type == eventNames().errorEvent || type == eventNames().timeoutEvent);
+
+    if (type == eventNames().loadstartEvent) {
+        m_lengthComputable = false;
+        m_loaded = 0;
+        m_total = 0;
+    }
 
+    dispatchEvent(XMLHttpRequestProgressEvent::create(type, m_lengthComputable, m_loaded, m_total));
+}
 
 } // namespace WebCore