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

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

Issue 14246006: Implementing timeout support for XHR (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@timeoutResourceHandle
Patch Set: 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/WebCore/xml/XMLHttpRequest.cpp
diff --git a/Source/WebCore/xml/XMLHttpRequest.cpp b/Source/WebCore/xml/XMLHttpRequest.cpp
index fcb37f7b614719836525e953aea371fe7cf7d0b1..a326c1dcb98084ca88679230bf0c6b04f85f226b 100644
--- a/Source/WebCore/xml/XMLHttpRequest.cpp
+++ b/Source/WebCore/xml/XMLHttpRequest.cpp
@@ -171,9 +171,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)
@@ -316,7 +314,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
@@ -328,7 +325,6 @@ void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec)
}
m_timeoutMilliseconds = timeout;
}
-#endif
void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode& ec)
{
@@ -506,14 +502,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);
@@ -756,10 +750,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;
@@ -1061,12 +1053,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)
@@ -1192,7 +1182,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.
@@ -1220,7 +1210,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