Changeset 189445 in webkit
- Timestamp:
- Sep 6, 2015 11:40:21 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r189440 r189445 1 2015-09-06 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 XHR2 timeout property should allow late updates 4 https://bugs.webkit.org/show_bug.cgi?id=98156 5 6 Reviewed by Darin Adler. 7 8 Activating test checking that timeout can be updated after request is sent. 9 10 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overrides-expected.txt: 11 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overrides.js: 12 * http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-overrides-expected.txt: 13 1 14 2015-09-04 Jon Honeycutt <jhoneycutt@apple.com> 2 15 -
trunk/LayoutTests/http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overrides-expected.txt
r150973 r189445 6 6 PASS XHR2 Timeout Property Tests 7 7 PASS XHR2 Timeout Property Tests 1 8 PASS XHR2 Timeout Property Tests 2 8 9 -
trunk/LayoutTests/http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-overrides.js
r150973 r189445 3 3 4 4 runTestRequests([ new RequestTracker(true, "timeout disabled after initially set", TIME_NORMAL_LOAD, TIME_REGULAR_TIMEOUT, 0), 5 //new RequestTracker(true, "timeout overrides load after a delay", TIME_NORMAL_LOAD, TIME_DELAY, TIME_REGULAR_TIMEOUT),5 new RequestTracker(true, "timeout overrides load after a delay", TIME_NORMAL_LOAD, TIME_DELAY, TIME_REGULAR_TIMEOUT), 6 6 new RequestTracker(true, "timeout enabled after initially disabled", 0, TIME_REGULAR_TIMEOUT, TIME_NORMAL_LOAD) ]); -
trunk/LayoutTests/http/tests/xmlhttprequest/timeout/xmlhttprequest-timeout-worker-overrides-expected.txt
r150973 r189445 6 6 PASS XHR2 Timeout Property Tests in Worker 7 7 PASS XHR2 Timeout Property Tests in Worker 1 8 PASS XHR2 Timeout Property Tests in Worker 2 8 9 -
trunk/Source/WebCore/ChangeLog
r189441 r189445 1 2015-09-06 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 3 XHR2 timeout property should allow late updates 4 https://bugs.webkit.org/show_bug.cgi?id=98156 5 6 Reviewed by Darin Adler. 7 8 Adding a timer within XMLHttpRequest to handle timeouts for asynchronous requests. 9 This allows easy update of the timeout even after request is sent. 10 Timeout is still handled by the network backend for synchronous requests (Web worker context). 11 12 Covered by updated tests. 13 14 * xml/XMLHttpRequest.cpp: 15 (WebCore::XMLHttpRequest::XMLHttpRequest): Adding timeout timer initialization. 16 (WebCore::XMLHttpRequest::setTimeout): Updating timeout timer state if request is sent. 17 (WebCore::XMLHttpRequest::createRequest): Starting timeout timer if needed. 18 (WebCore::XMLHttpRequest::internalAbort): Stopping timeout timer if needed. 19 (WebCore::XMLHttpRequest::didFail): Adding comment. 20 (WebCore::XMLHttpRequest::didFinishLoading): Stopping timeout timer if needed. 21 * xml/XMLHttpRequest.h: 22 1 23 2015-09-05 Jaehun Lim <ljaehun.lim@samsung.com> 2 24 -
trunk/Source/WebCore/xml/XMLHttpRequest.cpp
r188333 r189445 121 121 , m_async(true) 122 122 , m_includeCredentials(false) 123 #if ENABLE(XHR_TIMEOUT)124 , m_timeoutMilliseconds(0)125 #endif126 123 , m_state(UNSENT) 127 124 , m_createdDocument(false) … … 139 136 , m_resumeTimer(*this, &XMLHttpRequest::resumeTimerFired) 140 137 , m_dispatchErrorOnResuming(false) 138 #if ENABLE(XHR_TIMEOUT) 139 , m_timeoutTimer(*this, &XMLHttpRequest::didTimeout) 140 #endif 141 141 { 142 142 #ifndef NDEBUG … … 273 273 274 274 #if ENABLE(XHR_TIMEOUT) 275 void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionCode& ec) 276 { 277 // FIXME: Need to trigger or update the timeout Timer here, if needed. http://webkit.org/b/98156 278 // XHR2 spec, 4.7.3. "This implies that the timeout attribute can be set while fetching is in progress. If that occurs it will still be measured relative to the start of fetching." 275 void XMLHttpRequest::setTimeout(unsigned timeout, ExceptionCode& ec) 276 { 279 277 if (scriptExecutionContext()->isDocument() && !m_async) { 280 278 logConsoleError(scriptExecutionContext(), "XMLHttpRequest.timeout cannot be set for synchronous HTTP(S) requests made from the window context."); … … 283 281 } 284 282 m_timeoutMilliseconds = timeout; 283 if (!m_timeoutTimer.isActive()) 284 return; 285 if (!m_timeoutMilliseconds) { 286 m_timeoutTimer.stop(); 287 return; 288 } 289 std::chrono::duration<double> interval = std::chrono::milliseconds { m_timeoutMilliseconds } - (std::chrono::steady_clock::now() - m_sendingTime); 290 m_timeoutTimer.startOneShot(std::max(0.0, interval.count())); 285 291 } 286 292 #endif … … 768 774 769 775 #if ENABLE(XHR_TIMEOUT) 770 if (m_timeoutMilliseconds) 771 request.setTimeoutInterval(m_timeoutMilliseconds / 1000.0); 776 if (m_timeoutMilliseconds) { 777 if (!m_async) 778 request.setTimeoutInterval(m_timeoutMilliseconds / 1000.0); 779 else { 780 m_sendingTime = std::chrono::steady_clock::now(); 781 m_timeoutTimer.startOneShot(std::chrono::milliseconds { m_timeoutMilliseconds }); 782 } 783 } 772 784 #endif 773 785 … … 835 847 836 848 m_decoder = nullptr; 849 850 #if ENABLE(XHR_TIMEOUT) 851 if (m_timeoutTimer.isActive()) 852 m_timeoutTimer.stop(); 853 #endif 837 854 838 855 if (!m_loader) … … 1079 1096 1080 1097 #if ENABLE(XHR_TIMEOUT) 1098 // In case of worker sync timeouts. 1081 1099 if (error.isTimeout()) { 1082 1100 didTimeout(); … … 1119 1137 m_responseEncoding = String(); 1120 1138 m_decoder = nullptr; 1139 1140 #if ENABLE(XHR_TIMEOUT) 1141 if (m_timeoutTimer.isActive()) 1142 m_timeoutTimer.stop(); 1143 #endif 1121 1144 1122 1145 if (hadLoader) -
trunk/Source/WebCore/xml/XMLHttpRequest.h
r182544 r189445 115 115 Blob* optionalResponseBlob() const { return m_responseBlob.get(); } 116 116 #if ENABLE(XHR_TIMEOUT) 117 unsigned longtimeout() const { return m_timeoutMilliseconds; }118 void setTimeout(unsigned longtimeout, ExceptionCode&);117 unsigned timeout() const { return m_timeoutMilliseconds; } 118 void setTimeout(unsigned timeout, ExceptionCode&); 119 119 #endif 120 120 … … 217 217 bool m_async; 218 218 bool m_includeCredentials; 219 #if ENABLE(XHR_TIMEOUT)220 unsigned long m_timeoutMilliseconds;221 #endif222 219 RefPtr<Blob> m_responseBlob; 223 220 … … 260 257 Timer m_resumeTimer; 261 258 bool m_dispatchErrorOnResuming; 259 260 #if ENABLE(XHR_TIMEOUT) 261 unsigned m_timeoutMilliseconds { 0 }; 262 std::chrono::steady_clock::time_point m_sendingTime; 263 Timer m_timeoutTimer; 264 #endif 262 265 }; 263 266
Note: See TracChangeset
for help on using the changeset viewer.