XMLHttpRequestUpload.cpp [plain text]
#include "config.h"
#include "XMLHttpRequestUpload.h"
#include "Event.h"
#include "EventNames.h"
#include "XMLHttpRequestProgressEvent.h"
#include <wtf/Assertions.h>
#include <wtf/text/AtomicString.h>
namespace WebCore {
XMLHttpRequestUpload::XMLHttpRequestUpload(XMLHttpRequest* xmlHttpRequest)
: m_xmlHttpRequest(xmlHttpRequest)
, m_lengthComputable(false)
, m_loaded(0)
, m_total(0)
{
}
void XMLHttpRequestUpload::dispatchThrottledProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total)
{
m_lengthComputable = lengthComputable;
m_loaded = loaded;
m_total = total;
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));
}
}