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

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: Timeout support in DocumentThreadableLoader (speculative bot failure fix) Created 7 years, 6 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') | Source/core/xml/XMLHttpRequest.idl » ('j') | 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 e0b75f2cde862278b550668973b4dbce1d7672fe..e95e0d93a9c0571ba5137d59ada7867e8d0112f8 100644
--- a/Source/core/xml/XMLHttpRequest.cpp
+++ b/Source/core/xml/XMLHttpRequest.cpp
@@ -166,9 +166,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)
@@ -313,7 +311,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
@@ -325,7 +322,6 @@ void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec)
}
m_timeoutMilliseconds = timeout;
}
-#endif
void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode& ec)
{
@@ -497,14 +493,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);
@@ -750,11 +744,7 @@ void XMLHttpRequest::createRequest(ExceptionCode& ec)
options.securityOrigin = securityOrigin();
options.initiator = cachedResourceRequestInitiators().xmlhttprequest;
options.contentSecurityPolicyEnforcement = ContentSecurityPolicy::shouldBypassMainWorld(scriptExecutionContext()) ? DoNotEnforceContentSecurityPolicy : EnforceConnectSrcDirective;
-
-#if ENABLE(XHR_TIMEOUT)
- if (m_timeoutMilliseconds)
- request.setTimeoutInterval(m_timeoutMilliseconds / 1000.0);
-#endif
+ options.timeoutMilliseconds = m_timeoutMilliseconds;
m_exceptionCode = 0;
m_error = false;
@@ -1063,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 +1180,6 @@ 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 +1207,6 @@ void XMLHttpRequest::didTimeout()
}
m_progressEventThrottle.dispatchEventAndLoadEnd(XMLHttpRequestProgressEvent::create(eventNames().timeoutEvent));
}
-#endif
bool XMLHttpRequest::canSuspend() const
{
« no previous file with comments | « Source/core/xml/XMLHttpRequest.h ('k') | Source/core/xml/XMLHttpRequest.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698