Index: Source/core/xml/XMLHttpRequest.cpp |
diff --git a/Source/core/xml/XMLHttpRequest.cpp b/Source/core/xml/XMLHttpRequest.cpp |
index 3e6bf6c9ed6e875d727eb210fdd20f233c178433..1de94d71a06e7e49a0f7ab301a77c8880d9dd2cb 100644 |
--- a/Source/core/xml/XMLHttpRequest.cpp |
+++ b/Source/core/xml/XMLHttpRequest.cpp |
@@ -58,12 +58,19 @@ |
#include "wtf/ArrayBuffer.h" |
#include "wtf/ArrayBufferView.h" |
#include "wtf/Assertions.h" |
+#include "wtf/CurrentTime.h" |
#include "wtf/RefCountedLeakCounter.h" |
#include "wtf/StdLibExtras.h" |
#include "wtf/text/CString.h" |
namespace blink { |
+namespace { |
+ |
+const double readyStateChangeFireInterval = 0.05; // 0.05s |
+ |
+} // namespace |
+ |
DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, xmlHttpRequestCounter, ("XMLHttpRequest")); |
struct XMLHttpRequestStaticData { |
@@ -169,6 +176,7 @@ XMLHttpRequest::XMLHttpRequest(ExecutionContext* context, PassRefPtr<SecurityOri |
, m_progressEventThrottle(this) |
, m_responseTypeCode(ResponseTypeDefault) |
, m_securityOrigin(securityOrigin) |
+ , m_previousReadyStateChangeFireTime(0) |
, m_async(true) |
, m_includeCredentials(false) |
, m_createdDocument(false) |
@@ -420,12 +428,14 @@ void XMLHttpRequest::trackProgress(int length) |
if (m_state != LOADING) { |
changeState(LOADING); |
} else { |
- // Firefox calls readyStateChanged every time it receives data. Do |
- // the same to align with Firefox. |
- // |
// FIXME: Make our implementation and the spec consistent. This |
// behavior was needed when the progress event was not available. |
tyoshino (SeeGerritForStatus)
2014/07/30 08:44:07
Please replace
"This behavior" with
"This extra in
yhirano
2014/07/30 10:22:09
Done.
|
- dispatchReadyStateChangeEvent(); |
+ double now = monotonicallyIncreasingTime(); |
+ bool shouldFire = now - m_previousReadyStateChangeFireTime >= readyStateChangeFireInterval; |
+ if (shouldFire) { |
+ m_previousReadyStateChangeFireTime = now; |
+ dispatchReadyStateChangeEvent(); |
+ } |
} |
} |