Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: Source/core/xml/XMLHttpRequestUpload.cpp

Issue 79953004: Improve fidelity of XHR progress events. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Avoid now-unnecessary argument defaulting Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/xml/XMLHttpRequestUpload.cpp
diff --git a/Source/core/xml/XMLHttpRequestUpload.cpp b/Source/core/xml/XMLHttpRequestUpload.cpp
index c6bfde05d9f20536e017908ae72127d8e2bff0c7..af0814bb6301b3feab6ae8451d2401d379f1b5e5 100644
--- a/Source/core/xml/XMLHttpRequestUpload.cpp
+++ b/Source/core/xml/XMLHttpRequestUpload.cpp
@@ -60,18 +60,18 @@ void XMLHttpRequestUpload::dispatchProgressEvent(unsigned long long bytesSent, u
dispatchEvent(XMLHttpRequestProgressEvent::create(EventTypeNames::progress, true, bytesSent, totalBytesToBeSent));
}
-void XMLHttpRequestUpload::dispatchEventAndLoadEnd(PassRefPtr<Event> event)
+void XMLHttpRequestUpload::dispatchEventAndLoadEnd(const AtomicString& type, bool lengthComputable, unsigned long long bytesSent, unsigned long long total)
{
- ASSERT(event->type() == EventTypeNames::load || event->type() == EventTypeNames::abort || event->type() == EventTypeNames::error || event->type() == EventTypeNames::timeout);
-
- dispatchEvent(event);
- dispatchEvent(XMLHttpRequestProgressEvent::create(EventTypeNames::loadend));
+ ASSERT(type == EventTypeNames::load || type == EventTypeNames::abort || type == EventTypeNames::error || type == EventTypeNames::timeout);
+ dispatchEvent(XMLHttpRequestProgressEvent::create(type, lengthComputable, bytesSent, total));
+ dispatchEvent(XMLHttpRequestProgressEvent::create(EventTypeNames::loadend, lengthComputable, bytesSent, total));
}
void XMLHttpRequestUpload::handleRequestError(const AtomicString& type)
{
- dispatchEvent(XMLHttpRequestProgressEvent::create(EventTypeNames::progress, true, m_lastBytesSent, m_lastTotalBytesToBeSent));
- dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(type));
+ bool lengthComputable = m_lastTotalBytesToBeSent > 0 && m_lastBytesSent <= m_lastTotalBytesToBeSent;
tyoshino (SeeGerritForStatus) 2013/11/25 12:35:33 yeah. it's fine to determine lengthComputable from
sof 2013/11/25 13:30:38 Does that matter, practically? if we haven't gotte
tyoshino (SeeGerritForStatus) 2013/11/25 13:39:14 Ah,... right. And, if dispatchEventAndLoadEnd is c
+ dispatchEvent(XMLHttpRequestProgressEvent::create(EventTypeNames::progress, lengthComputable, m_lastBytesSent, m_lastTotalBytesToBeSent));
+ dispatchEventAndLoadEnd(type, true, m_lastBytesSent, m_lastTotalBytesToBeSent);
tyoshino (SeeGerritForStatus) 2013/11/25 12:35:33 true -> lengthComputable?
sof 2013/11/25 15:28:18 Done.
}
} // namespace WebCore
« Source/core/xml/XMLHttpRequest.cpp ('K') | « Source/core/xml/XMLHttpRequestUpload.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698