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

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

Issue 490083002: [XHR] Move the code to clear variables to internalAbort() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 3 months 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 7315dd9326803e09632506d68e222b40475c8194..33fd353d5e6a797203455aa87463056e65d56b60 100644
--- a/Source/core/xml/XMLHttpRequest.cpp
+++ b/Source/core/xml/XMLHttpRequest.cpp
@@ -543,12 +543,6 @@ void XMLHttpRequest::open(const AtomicString& method, const KURL& url, bool asyn
m_error = false;
m_uploadComplete = false;
- // clear stuff from possible previous load
- clearResponse();
- clearRequest();
-
- ASSERT(m_state == UNSENT);
-
if (!isValidHTTPToken(method)) {
exceptionState.throwDOMException(SyntaxError, "'" + method + "' is not a valid HTTP method.");
return;
@@ -896,11 +890,6 @@ void XMLHttpRequest::abort()
if (!internalAbort())
return;
- clearResponse();
-
- // Clear headers as required by the spec
- m_requestHeaders.clear();
-
if (!((m_state <= OPENED && !sendFlag) || m_state == DONE)) {
ASSERT(!m_loader);
handleRequestError(0, EventTypeNames::abort, receivedLength, expectedLength);
@@ -944,6 +933,9 @@ bool XMLHttpRequest::internalAbort()
m_responseStream->error(DOMException::create(!m_async && m_exceptionCode ? m_exceptionCode : AbortError, "XMLHttpRequest::abort"));
}
+ clearResponse();
+ clearRequest();
+
if (!m_loader)
return true;
@@ -998,14 +990,6 @@ void XMLHttpRequest::clearRequest()
m_requestHeaders.clear();
}
-void XMLHttpRequest::handleDidFailGeneric()
-{
- clearResponse();
- clearRequest();
-
- m_error = true;
-}
-
void XMLHttpRequest::dispatchProgressEvent(const AtomicString& type, long long receivedLength, long long expectedLength)
{
bool lengthComputable = expectedLength > 0 && receivedLength <= expectedLength;
@@ -1034,7 +1018,6 @@ void XMLHttpRequest::handleNetworkError()
if (!internalAbort())
return;
- handleDidFailGeneric();
handleRequestError(NetworkError, EventTypeNames::error, receivedLength, expectedLength);
}
@@ -1046,7 +1029,9 @@ void XMLHttpRequest::handleDidCancel()
long long expectedLength = m_response.expectedContentLength();
long long receivedLength = m_receivedLength;
- handleDidFailGeneric();
+ if (!internalAbort())
+ return;
+
handleRequestError(AbortError, EventTypeNames::abort, receivedLength, expectedLength);
}
@@ -1497,7 +1482,6 @@ void XMLHttpRequest::handleDidTimeout()
if (!internalAbort())
return;
- handleDidFailGeneric();
handleRequestError(TimeoutError, EventTypeNames::timeout, receivedLength, expectedLength);
}
« 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