Skip to content

Commit

Permalink
Revert of [XHR] Reduce 'readystatechange' event firing. (patchset #9 of
Browse files Browse the repository at this point in the history
https://codereview.chromium.org/428473005/)

Reason for revert:
This change breaks legacy applications.

Original issue's description:
> [XHR] Reduce 'readystatechange' event firing.
> 
> Currently too many readystatechange events are fired and
> it hurts performance.
> 
> BUG=336066
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=179381

Review URL: https://codereview.chromium.org/486133002

git-svn-id: svn://svn.chromium.org/blink/trunk@180554 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
[email protected] committed Aug 19, 2014
1 parent 3983cd9 commit c5eb8a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
27 changes: 6 additions & 21 deletions Source/core/xml/XMLHttpRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,12 @@
#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 {

// To throttle readystatechange event fired when readystatechange is not
// changed, we don't dispatch the event within 50ms.
// As dispatching readystatechange when readystatechange is NOT changed is not
// specified, 50ms is not specified, too.
// We choose this value because progress event is dispatched every 50ms, but
// actually this value doesn't have to equal to the interval.
// Note: When readystate is actually changed readystatechange event must be
// dispatched no matter how recently dispatched the event was.
const double readyStateChangeFireInterval = 0.05;

DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, xmlHttpRequestCounter, ("XMLHttpRequest"));

static bool isSetCookieHeader(const AtomicString& name)
Expand Down Expand Up @@ -162,7 +151,6 @@ 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_parsedResponse(false)
Expand Down Expand Up @@ -452,15 +440,12 @@ void XMLHttpRequest::trackProgress(int length)
if (m_state != LOADING) {
changeState(LOADING);
} else {
// FIXME: Make our implementation and the spec consistent. This extra
// invocation of readystatechange event in LOADING state was needed
// when the progress event was not available.
double now = monotonicallyIncreasingTime();
bool shouldFire = now - m_previousReadyStateChangeFireTime >= readyStateChangeFireInterval;
if (shouldFire) {
m_previousReadyStateChangeFireTime = now;
dispatchReadyStateChangeEvent();
}
// 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.
dispatchReadyStateChangeEvent();
}
}

Expand Down
2 changes: 0 additions & 2 deletions Source/core/xml/XMLHttpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ class XMLHttpRequest FINAL
ResponseTypeCode m_responseTypeCode;
RefPtr<SecurityOrigin> m_securityOrigin;

double m_previousReadyStateChangeFireTime;

bool m_async;
bool m_includeCredentials;
// Used to skip m_responseDocument creation if it's done previously. We need
Expand Down

0 comments on commit c5eb8a9

Please sign in to comment.