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

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

Issue 75103006: Factor out delivery of throttled progress event. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « Source/core/xml/XMLHttpRequest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/xml/XMLHttpRequest.cpp
diff --git a/Source/core/xml/XMLHttpRequest.cpp b/Source/core/xml/XMLHttpRequest.cpp
index 2aa1a4c2553ad34a26eb31a3f5404708b4d3c8e7..a006abd2cec3c89b58d5d641e23786bfc95e481b 100644
--- a/Source/core/xml/XMLHttpRequest.cpp
+++ b/Source/core/xml/XMLHttpRequest.cpp
@@ -965,6 +965,15 @@ void XMLHttpRequest::dispatchEventAndLoadEnd(const AtomicString& type)
m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(type));
}
+void XMLHttpRequest::dispatchThrottledProgressEvent()
+{
+ long long expectedLength = m_response.expectedContentLength();
+ bool lengthComputable = expectedLength > 0 && m_receivedLength <= expectedLength;
+ unsigned long long total = lengthComputable ? expectedLength : 0;
+
+ m_progressEventThrottle.dispatchProgressEvent(lengthComputable, m_receivedLength, total);
+}
+
void XMLHttpRequest::handleNetworkError()
{
LOG(Network, "XMLHttpRequest %p handleNetworkError()", this);
@@ -1298,13 +1307,8 @@ void XMLHttpRequest::didReceiveData(const char* data, int len)
m_receivedLength += len;
- if (m_async) {
- long long expectedLength = m_response.expectedContentLength();
- bool lengthComputable = expectedLength > 0 && m_receivedLength <= expectedLength;
- unsigned long long total = lengthComputable ? expectedLength : 0;
-
- m_progressEventThrottle.dispatchProgressEvent(lengthComputable, m_receivedLength, total);
- }
+ if (m_async)
+ dispatchThrottledProgressEvent();
if (m_state != LOADING) {
changeState(LOADING);
« no previous file with comments | « Source/core/xml/XMLHttpRequest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698