Index: Source/core/loader/DocumentThreadableLoader.cpp |
diff --git a/Source/core/loader/DocumentThreadableLoader.cpp b/Source/core/loader/DocumentThreadableLoader.cpp |
index 2840dce77f4d9e26c4eae1e3c59f20864f715df6..f104e3a706623f5266d03d428001712625972b63 100644 |
--- a/Source/core/loader/DocumentThreadableLoader.cpp |
+++ b/Source/core/loader/DocumentThreadableLoader.cpp |
@@ -76,6 +76,7 @@ DocumentThreadableLoader::DocumentThreadableLoader(Document& document, Threadabl |
, m_simpleRequest(true) |
, m_async(blockingBehavior == LoadAsynchronously) |
, m_timeoutTimer(this, &DocumentThreadableLoader::didTimeout) |
+ , m_requestStarted(0.0) |
{ |
ASSERT(client); |
// Setting an outgoing referer is only supported in the async code path. |
@@ -138,6 +139,26 @@ DocumentThreadableLoader::~DocumentThreadableLoader() |
{ |
} |
+void DocumentThreadableLoader::overrideTimeout(unsigned long timeoutMilliseconds) |
+{ |
+ if (!m_async) |
+ return; |
+ m_timeoutTimer.stop(); |
+ // At the time of this method's implementation, it is only ever called by |
+ // XMLHttpRequest, when the timeout attribute is set after sending the |
+ // request. |
+ // |
+ // The XHR request says to resolve the time relative to when the request |
+ // was initially sent, however other uses of this method may need to |
+ // behave differently, in which case this should be re-arranged somehow. |
+ if (timeoutMilliseconds) { |
+ double elapsedTime = monotonicallyIncreasingTime() - m_requestStarted; |
+ double nextFire = timeoutMilliseconds / 1000.0; |
+ double resolvedTime = nextFire > elapsedTime ? nextFire - elapsedTime : 0.0; |
+ m_timeoutTimer.startOneShot(resolvedTime, FROM_HERE); |
tyoshino (SeeGerritForStatus)
2014/05/15 09:15:43
We should start the timer only when there's active
caitp (gmail)
2014/05/15 11:51:03
What about just `m_requestStarted > 0.0` ? It gets
tyoshino (SeeGerritForStatus)
2014/05/15 12:33:42
Sounds fine as far as well commented.
|
+ } |
+} |
+ |
void DocumentThreadableLoader::cancel() |
{ |
cancelWithError(ResourceError()); |
@@ -396,6 +417,7 @@ void DocumentThreadableLoader::loadRequest(const ResourceRequest& request) |
if (m_options.timeoutMilliseconds > 0) |
m_timeoutTimer.startOneShot(m_options.timeoutMilliseconds / 1000.0, FROM_HERE); |
+ m_requestStarted = monotonicallyIncreasingTime(); |
FetchRequest newRequest(request, m_options.initiator, options); |
ASSERT(!resource()); |