Changeset 56394 in webkit
- Timestamp:
- Mar 23, 2010 8:33:16 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r56393 r56394 1 2010-03-23 Julien Chaffraix <jchaffraix@webkit.org> 2 3 Reviewed by Alexey Proskuryakov. 4 5 [XHR] onProgress event needs to be dispatched according to what the specification states 6 https://bugs.webkit.org/show_bug.cgi?id=18654 7 8 Add a test to check that progress events are really throttled. 9 10 * http/tests/xmlhttprequest/resources/download-with-delay.php: Added. 11 * http/tests/xmlhttprequest/xmlhttprequest-50ms-download-dispatch-expected.txt: Added. 12 * http/tests/xmlhttprequest/xmlhttprequest-50ms-download-dispatch.html: Added. 13 1 14 2010-03-23 Pavel Feldman <pfeldman@chromium.org> 2 15 -
trunk/WebCore/Android.mk
r55821 r56394 897 897 xml/DOMParser.cpp \ 898 898 xml/XMLHttpRequest.cpp \ 899 xml/XMLHttpRequestProgressEventThrottle.cpp \ 899 900 xml/XMLHttpRequestUpload.cpp \ 900 901 xml/XMLSerializer.cpp -
trunk/WebCore/ChangeLog
r56393 r56394 1 2010-03-23 Julien Chaffraix <jchaffraix@webkit.org> 2 3 Reviewed by Alexey Proskuryakov. 4 5 [XHR] onProgress event needs to be dispatched according to what the specification states 6 https://bugs.webkit.org/show_bug.cgi?id=18654 7 8 Test: http/tests/xmlhttprequest/xmlhttprequest-50ms-download-dispatch.html 9 10 * Android.mk: 11 * GNUmakefile.am: 12 * WebCore.gypi: 13 * WebCore.pro: 14 * WebCore.vcproj/WebCore.vcproj: 15 * WebCore.xcodeproj/project.pbxproj: 16 Added XMLHttpRequestProgressEventThrottle to the build systems. 17 18 * xml/XMLHttpRequest.cpp: 19 (WebCore::XMLHttpRequest::XMLHttpRequest): Created the throttle. 20 (WebCore::XMLHttpRequest::callReadyStateChangeListener): The 'readyState' event are 21 dispatched using the XMLHttpRequestProgressEventThrottle now. For the DONE state, we 22 need to flush any pending progress event as we do not want it to be dispatched after 23 the DONE readyState event. 24 (WebCore::XMLHttpRequest::createRequest): Made this event use the 25 XMLHttpRequestProgressEventThrottle for event dispatching. 26 (WebCore::XMLHttpRequest::abort): Ditto. 27 (WebCore::XMLHttpRequest::networkError): Ditto. 28 (WebCore::XMLHttpRequest::abortError): Ditto. 29 (WebCore::XMLHttpRequest::didReceiveData): Ditto. Also fixed a potential warning. 30 (WebCore::XMLHttpRequest::suspend): 31 (WebCore::XMLHttpRequest::resume): Implemented the logic for suspend / resume. 32 * xml/XMLHttpRequest.h: 33 * xml/XMLHttpRequestProgressEventThrottle.cpp: Added. 34 (WebCore::XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle): 35 (WebCore::XMLHttpRequestProgressEventThrottle::~XMLHttpRequestProgressEventThrottle): 36 (WebCore::XMLHttpRequestProgressEventThrottle::dispatchProgressEvent): Implemented the bulk 37 of the event throttling here: we use a timer to do so, as long as the timer is active it means 38 that events are coming faster than the throttling time and we coalesce them. 39 (WebCore::XMLHttpRequestProgressEventThrottle::dispatchEvent): Generic method to dispatch an event. 40 (WebCore::XMLHttpRequestProgressEventThrottle::flushProgressEvent): Called when we want to dispatch 41 any pending events and stopping any further dispatching. 42 (WebCore::XMLHttpRequestProgressEventThrottle::dispatchPausedEvent): Used to dispatch the event 43 that was queued due to the object being suspended. 44 (WebCore::XMLHttpRequestProgressEventThrottle::fired): Used to dispatch any coalesced event. 45 (WebCore::XMLHttpRequestProgressEventThrottle::hasEventToDispatch): Used to check if we have 46 an event to dispatch. 47 (WebCore::XMLHttpRequestProgressEventThrottle::suspend): Marked the object as suspended. 48 (WebCore::XMLHttpRequestProgressEventThrottle::resume): Dispatched the event that was queued. 49 * xml/XMLHttpRequestProgressEventThrottle.h: Added. 50 (WebCore::): 51 (WebCore::XMLHttpRequestProgressEventThrottle::suspended): 52 1 53 2010-03-23 Pavel Feldman <pfeldman@chromium.org> 2 54 -
trunk/WebCore/GNUmakefile.am
r56387 r56394 1984 1984 WebCore/xml/XMLHttpRequestException.h \ 1985 1985 WebCore/xml/XMLHttpRequestProgressEvent.h \ 1986 WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp \ 1987 WebCore/xml/XMLHttpRequestProgressEventThrottle.h \ 1986 1988 WebCore/xml/XMLHttpRequestUpload.cpp \ 1987 1989 WebCore/xml/XMLHttpRequestUpload.h \ -
trunk/WebCore/WebCore.gypi
r56241 r56394 3715 3715 'xml/XMLHttpRequestException.h', 3716 3716 'xml/XMLHttpRequestProgressEvent.h', 3717 'xml/XMLHttpRequestProgressEventThrottle.cpp', 3718 'xml/XMLHttpRequestProgressEventThrottle.h', 3717 3719 'xml/XMLHttpRequestUpload.cpp', 3718 3720 'xml/XMLHttpRequestUpload.h', -
trunk/WebCore/WebCore.pro
r56386 r56394 989 989 xml/DOMParser.cpp \ 990 990 xml/XMLHttpRequest.cpp \ 991 xml/XMLHttpRequestProgressEventThrottle.cpp \ 991 992 xml/XMLHttpRequestUpload.cpp \ 992 993 xml/XMLSerializer.cpp -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r56256 r56394 28460 28460 </File> 28461 28461 <File 28462 RelativePath="..\xml\XMLHttpRequestProgressEventThrottle.cpp" 28463 > 28464 </File> 28465 <File 28466 RelativePath="..\xml\XMLHttpRequestProgressEventThrottle.h" 28467 > 28468 </File> 28469 <File 28462 28470 RelativePath="..\xml\XMLHttpRequestUpload.cpp" 28463 28471 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r56361 r56394 4396 4396 BC772C460C4EB2C60083285F /* XMLHttpRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC772C440C4EB2C60083285F /* XMLHttpRequest.cpp */; }; 4397 4397 BC772C470C4EB2C60083285F /* XMLHttpRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = BC772C450C4EB2C60083285F /* XMLHttpRequest.h */; }; 4398 A136A00C1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */; }; 4399 A136A00D1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h in Headers */ = {isa = PBXBuildFile; fileRef = A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */; }; 4398 4400 BC772C4E0C4EB3040083285F /* MIMETypeRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC772C4C0C4EB3040083285F /* MIMETypeRegistry.cpp */; }; 4399 4401 BC772C4F0C4EB3040083285F /* MIMETypeRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = BC772C4D0C4EB3040083285F /* MIMETypeRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 7898 7900 9F72304D11184B4100AD0126 /* ScriptProfiler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptProfiler.cpp; sourceTree = "<group>"; }; 7899 7901 9F72304E11184B4100AD0126 /* ScriptProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptProfiler.h; sourceTree = "<group>"; }; 7902 A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLHttpRequestProgressEventThrottle.cpp; sourceTree = "<group>"; }; 7903 A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLHttpRequestProgressEventThrottle.h; sourceTree = "<group>"; }; 7900 7904 A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLElementFactory.cpp; sourceTree = "<group>"; }; 7901 7905 A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLElementFactory.h; sourceTree = "<group>"; }; … … 15455 15459 F9F0ED770DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h */, 15456 15460 F9F0ED780DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.idl */, 15461 A136A00A1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp */, 15462 A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */, 15457 15463 BCDFD48D0E305290009D10AD /* XMLHttpRequestUpload.cpp */, 15458 15464 BCDFD48C0E305290009D10AD /* XMLHttpRequestUpload.h */, … … 18705 18711 BC60D9C90D2A29E500B9918F /* XMLHttpRequestException.h in Headers */, 18706 18712 F9F0ED7A0DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h in Headers */, 18713 A136A00D1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h in Headers */, 18707 18714 BCDFD48E0E305290009D10AD /* XMLHttpRequestUpload.h in Headers */, 18708 18715 A833C80D0A2CF25600D57664 /* XMLNames.h in Headers */, … … 20918 20925 BC772C460C4EB2C60083285F /* XMLHttpRequest.cpp in Sources */, 20919 20926 BCDFD48F0E305290009D10AD /* XMLHttpRequestUpload.cpp in Sources */, 20927 A136A00C1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp in Sources */, 20920 20928 A833C80C0A2CF25600D57664 /* XMLNames.cpp in Sources */, 20921 20929 E15A36D91104572700B7B639 /* XMLNSNames.cpp in Sources */, -
trunk/WebCore/xml/XMLHttpRequest.cpp
r55821 r56394 159 159 , m_lastSendLineNumber(0) 160 160 , m_exceptionCode(0) 161 , m_progressEventThrottle(this) 161 162 { 162 163 initializeXMLHttpRequestStaticData(); … … 260 261 #endif 261 262 262 dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().readystatechangeEvent));263 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().readystatechangeEvent), m_state == DONE ? FlushProgressEvent : DoNotFlushProgressEvent); 263 264 264 265 #if ENABLE(INSPECTOR) … … 275 276 #endif 276 277 277 dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadEvent));278 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadEvent)); 278 279 279 280 #if ENABLE(INSPECTOR) … … 487 488 bool forcePreflight = false; 488 489 if (m_async) { 489 dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadstartEvent));490 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().loadstartEvent)); 490 491 if (m_requestEntityBody && m_upload) { 491 492 forcePreflight = m_upload->hasEventListeners(); … … 579 580 } 580 581 581 dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));582 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().abortEvent)); 582 583 if (!m_uploadComplete) { 583 584 m_uploadComplete = true; … … 633 634 { 634 635 genericError(); 635 dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().errorEvent));636 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().errorEvent)); 636 637 if (!m_uploadComplete) { 637 638 m_uploadComplete = true; … … 645 646 { 646 647 genericError(); 647 dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().abortEvent));648 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().abortEvent)); 648 649 if (!m_uploadComplete) { 649 650 m_uploadComplete = true; … … 948 949 m_receivedLength += len; 949 950 950 // FIXME: the spec requires that we dispatch the event according to the least 951 // frequent method between every 350ms (+/-200ms) and for every byte received. 952 dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, expectedLength && m_receivedLength <= expectedLength, static_cast<unsigned>(m_receivedLength), static_cast<unsigned>(expectedLength))); 951 bool lengthComputable = expectedLength && m_receivedLength <= expectedLength; 952 m_progressEventThrottle.dispatchProgressEvent(lengthComputable, static_cast<unsigned>(m_receivedLength), static_cast<unsigned>(expectedLength)); 953 953 954 954 if (m_state != LOADING) … … 965 965 } 966 966 967 void XMLHttpRequest::suspend() 968 { 969 m_progressEventThrottle.suspend(); 970 } 971 972 void XMLHttpRequest::resume() 973 { 974 m_progressEventThrottle.resume(); 975 } 976 967 977 void XMLHttpRequest::stop() 968 978 { -
trunk/WebCore/xml/XMLHttpRequest.h
r55821 r56394 30 30 #include "ScriptString.h" 31 31 #include "ThreadableLoaderClient.h" 32 #include "XMLHttpRequestProgressEventThrottle.h" 32 33 #include <wtf/OwnPtr.h> 33 34 … … 59 60 virtual void contextDestroyed(); 60 61 virtual bool canSuspend() const; 62 virtual void suspend(); 63 virtual void resume(); 61 64 virtual void stop(); 62 65 … … 188 191 189 192 EventTargetData m_eventTargetData; 193 194 XMLHttpRequestProgressEventThrottle m_progressEventThrottle; 190 195 }; 191 196
Note: See TracChangeset
for help on using the changeset viewer.