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

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

Issue 14246006: Implementing timeout support for XHR (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@timeoutResourceHandle
Patch Set: Rebased patch Created 7 years, 8 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
Index: Source/core/xml/XMLHttpRequest.cpp
diff --git a/Source/core/xml/XMLHttpRequest.cpp b/Source/core/xml/XMLHttpRequest.cpp
index 7ac3d25f622e78d82bc500de0708943fcbcb96b6..beba0a46b3ac44e5477adbc68df6d90db4114e1c 100644
--- a/Source/core/xml/XMLHttpRequest.cpp
+++ b/Source/core/xml/XMLHttpRequest.cpp
@@ -172,9 +172,7 @@ XMLHttpRequest::XMLHttpRequest(ScriptExecutionContext* context, PassRefPtr<Secur
: ActiveDOMObject(context)
, m_async(true)
, m_includeCredentials(false)
-#if ENABLE(XHR_TIMEOUT)
, m_timeoutMilliseconds(0)
-#endif
, m_state(UNSENT)
, m_createdDocument(false)
, m_error(false)
@@ -317,7 +315,6 @@ ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionCode& ec)
return m_responseArrayBuffer.get();
}
-#if ENABLE(XHR_TIMEOUT)
void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec)
{
// FIXME: Need to trigger or update the timeout Timer here, if needed. http://webkit.org/b/98156
@@ -329,7 +326,6 @@ void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec)
}
m_timeoutMilliseconds = timeout;
}
-#endif
void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode& ec)
{
@@ -508,14 +504,12 @@ void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc
return;
}
-#if ENABLE(XHR_TIMEOUT)
// Similarly, timeouts are disabled for synchronous requests as well.
if (m_timeoutMilliseconds > 0) {
logConsoleError(scriptExecutionContext(), "Synchronous XMLHttpRequests must not have a timeout value set.");
ec = INVALID_ACCESS_ERR;
return;
}
-#endif
}
m_method = uppercaseKnownHTTPMethod(method);
@@ -758,10 +752,8 @@ void XMLHttpRequest::createRequest(ExceptionCode& ec)
options.securityOrigin = securityOrigin();
options.initiator = cachedResourceRequestInitiators().xmlhttprequest;
-#if ENABLE(XHR_TIMEOUT)
if (m_timeoutMilliseconds)
request.setTimeoutInterval(m_timeoutMilliseconds / 1000.0);
-#endif
m_exceptionCode = 0;
m_error = false;
@@ -1063,12 +1055,10 @@ void XMLHttpRequest::didFail(const ResourceError& error)
return;
}
-#if ENABLE(XHR_TIMEOUT)
if (error.isTimeout()) {
didTimeout();
return;
}
-#endif
// Network failures are already reported to Web Inspector by ResourceLoader.
if (error.domain() == errorDomainWebKitInternal)
@@ -1194,7 +1184,7 @@ void XMLHttpRequest::didReceiveData(const char* data, int len)
}
}
-#if ENABLE(XHR_TIMEOUT)
+
void XMLHttpRequest::didTimeout()
{
// internalAbort() calls dropProtection(), which may release the last reference.
@@ -1222,7 +1212,6 @@ void XMLHttpRequest::didTimeout()
}
m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().timeoutEvent));
}
-#endif
bool XMLHttpRequest::canSuspend() const
{

Powered by Google App Engine
This is Rietveld 408576698