source: webkit/trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp

Last change on this file was 282860, checked in by Chris Dumez, 4 years ago

Reduce use of makeRef() and use Ref { } instead
https://bugs.webkit.org/show_bug.cgi?id=230585

Reviewed by Alex Christensen.

Source/JavaScriptCore:

  • debugger/Debugger.cpp:

(JSC::Debugger::setBreakpoint):
(JSC::Debugger::schedulePauseForSpecialBreakpoint):

  • llint/LLIntEntrypoint.cpp:

(JSC::LLInt::setFunctionEntrypoint):
(JSC::LLInt::setEvalEntrypoint):
(JSC::LLInt::setProgramEntrypoint):
(JSC::LLInt::setModuleProgramEntrypoint):

  • runtime/JSString.cpp:

(JSC::JSRopeString::resolveRopeToExistingAtomString const):

  • runtime/VM.cpp:

(JSC::jitCodeForCallTrampoline):
(JSC::jitCodeForConstructTrampoline):

  • wasm/WasmCodeBlock.cpp:

(JSC::Wasm::CodeBlock::CodeBlock):

  • wasm/WasmOMGForOSREntryPlan.cpp:

(JSC::Wasm::OMGForOSREntryPlan::OMGForOSREntryPlan):

  • wasm/WasmOMGPlan.cpp:

(JSC::Wasm::OMGPlan::OMGPlan):

  • wasm/WasmSignature.cpp:

(JSC::Wasm::SignatureInformation::signatureFor):

  • wasm/WasmSignatureInlines.h:

(JSC::Wasm::SignatureInformation::get):

  • wasm/WasmSlowPaths.cpp:

(JSC::LLInt::jitCompileAndSetHeuristics):

  • wasm/js/JSWebAssemblyInstance.h:

Source/WebCore:

  • Modules/async-clipboard/ClipboardItemBindingsDataSource.cpp:

(WebCore::ClipboardItemBindingsDataSource::collectDataForWriting):

  • Modules/cache/DOMCache.cpp:

(WebCore::DOMCache::addAll):

  • Modules/cache/WorkerCacheStorageConnection.cpp:

(WebCore::WorkerCacheStorageConnection::create):
(WebCore::WorkerCacheStorageConnection::open):
(WebCore::WorkerCacheStorageConnection::remove):
(WebCore::WorkerCacheStorageConnection::retrieveCaches):
(WebCore::WorkerCacheStorageConnection::retrieveRecords):
(WebCore::WorkerCacheStorageConnection::batchDeleteOperation):
(WebCore::WorkerCacheStorageConnection::batchPutOperation):

  • Modules/entriesapi/DOMFileSystem.cpp:

(WebCore::DOMFileSystem::listDirectory):
(WebCore::DOMFileSystem::getParent):
(WebCore::DOMFileSystem::getEntry):
(WebCore::DOMFileSystem::getFile):

  • Modules/entriesapi/FileSystemDirectoryReader.cpp:

(WebCore::FileSystemDirectoryReader::readEntries):

  • Modules/fetch/FetchBody.cpp:

(WebCore::FetchBody::bodyAsFormData const):

  • Modules/indexeddb/IDBTransaction.cpp:

(WebCore::IDBTransaction::objectStore):
(WebCore::IDBTransaction::iterateCursor):
(WebCore::IDBTransaction::requestPutOrAdd):

  • Modules/mediasession/MediaSessionCoordinator.cpp:

(WebCore::MediaSessionCoordinator::MediaSessionCoordinator):

  • Modules/mediastream/PeerConnectionBackend.cpp:

(WebCore::PeerConnectionBackend::newDataChannel):

  • Modules/mediastream/RTCRtpSFrameTransform.cpp:

(WebCore::RTCRtpSFrameTransform::initializeTransformer):

  • Modules/mediastream/RTCRtpScriptTransform.cpp:

(WebCore::RTCRtpScriptTransform::create):
(WebCore::RTCRtpScriptTransform::initializeTransformer):

  • Modules/mediastream/RTCRtpScriptTransformer.cpp:

(WebCore::RTCRtpScriptTransformer::writable):
(WebCore::RTCRtpScriptTransformer::start):

  • Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:

(WebCore::LibWebRTCDataChannelHandler::checkState):
(WebCore::LibWebRTCDataChannelHandler::OnMessage):
(WebCore::LibWebRTCDataChannelHandler::OnBufferedAmountChange):

  • Modules/mediastream/libwebrtc/LibWebRTCDtlsTransportBackend.cpp:

(WebCore::LibWebRTCDtlsTransportBackendObserver::start):
(WebCore::LibWebRTCDtlsTransportBackendObserver::stop):
(WebCore::LibWebRTCDtlsTransportBackendObserver::OnStateChange):
(WebCore::LibWebRTCDtlsTransportBackendObserver::OnError):

  • Modules/mediastream/libwebrtc/LibWebRTCIceTransportBackend.cpp:

(WebCore::LibWebRTCIceTransportBackendObserver::start):
(WebCore::LibWebRTCIceTransportBackendObserver::stop):
(WebCore::LibWebRTCIceTransportBackendObserver::onIceTransportStateChanged):
(WebCore::LibWebRTCIceTransportBackendObserver::onGatheringStateChanged):

  • Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:

(WebCore::LibWebRTCMediaEndpoint::addPendingTrackEvent):
(WebCore::LibWebRTCMediaEndpoint::newTransceiver):

  • Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:

(WebCore::findExistingSender):
(WebCore::LibWebRTCPeerConnectionBackend::addTrack):

  • Modules/mediastream/libwebrtc/LibWebRTCSctpTransportBackend.cpp:

(WebCore::LibWebRTCSctpTransportBackendObserver::start):
(WebCore::LibWebRTCSctpTransportBackendObserver::stop):
(WebCore::LibWebRTCSctpTransportBackendObserver::OnStateChange):

  • Modules/notifications/Notification.cpp:

(WebCore::Notification::requestPermission):

  • Modules/speech/SpeechRecognitionResultList.cpp:

(WebCore::SpeechRecognitionResultList::add):

  • Modules/webaudio/AsyncAudioDecoder.cpp:

(WebCore::AsyncAudioDecoder::DecodingTask::notifyComplete):

  • Modules/webaudio/AudioNode.cpp:

(WebCore::AudioNode::toWeakOrStrongContext):

  • Modules/webaudio/AudioWorklet.cpp:

(WebCore::AudioWorklet::createProcessor):

  • Modules/webaudio/DefaultAudioDestinationNode.cpp:

(WebCore::Function<void):

  • Modules/webdatabase/Database.cpp:

(WebCore::Database::runTransaction):

  • Modules/webxr/WebXRInputSourceArray.cpp:

(WebCore::WebXRInputSourceArray::update):

  • Modules/webxr/WebXRSystem.cpp:

(WebCore::WebXRSystem::requestSession):

  • accessibility/AXObjectCache.cpp:

(WebCore::AXObjectCache::getOrCreate):

  • animation/DocumentTimelinesController.cpp:

(WebCore::DocumentTimelinesController::updateAnimationsAndSendEvents):

  • bindings/js/JSEventListener.h:

(WebCore::JSEventListener::ensureJSFunction const):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneSerializer::dumpIfTerminal):

  • crypto/SubtleCrypto.cpp:

(WebCore::SubtleCrypto::wrapKey):

  • css/CSSFontFaceSet.cpp:

(WebCore::CSSFontFaceSet::remove):

  • css/CSSFontSelector.cpp:

(WebCore::CSSFontSelector::CSSFontSelector):

  • css/DOMCSSPaintWorklet.cpp:

(WebCore::PaintWorklet::addModule):

  • css/typedom/CSSNumericValue.cpp:

(WebCore::CSSNumericValue::add):
(WebCore::CSSNumericValue::sub):
(WebCore::CSSNumericValue::mul):
(WebCore::CSSNumericValue::div):
(WebCore::CSSNumericValue::min):
(WebCore::CSSNumericValue::max):

  • css/typedom/CSSStyleValueFactory.cpp:

(WebCore::CSSStyleValueFactory::reifyValue):

  • css/typedom/StylePropertyMapReadOnly.cpp:

(WebCore::StylePropertyMapReadOnly::reifyValue):

  • dom/ActiveDOMObject.cpp:

(WebCore::ActiveDOMObject::queueTaskToDispatchEventInternal):
(WebCore::ActiveDOMObject::queueCancellableTaskToDispatchEventInternal):

  • dom/ActiveDOMObject.h:
  • dom/DeviceOrientationAndMotionAccessController.cpp:

(WebCore::DeviceOrientationAndMotionAccessController::shouldAllowAccess):

  • dom/Document.cpp:

(WebCore::Document::forEachMediaElement):
(WebCore::command):

  • dom/Element.cpp:

(WebCore::Element::focus):

  • dom/IdleCallbackController.cpp:

(WebCore::IdleCallbackController::queueTaskToStartIdlePeriod):
(WebCore::IdleCallbackController::queueTaskToInvokeIdleCallbacks):

  • dom/Microtasks.cpp:

(WebCore::MicrotaskQueue::MicrotaskQueue):

  • dom/MutationObserver.cpp:

(WebCore::MutationObserver::enqueueMutationRecord):
(WebCore::MutationObserver::enqueueSlotChangeEvent):
(WebCore::MutationObserver::setHasTransientRegistration):

  • dom/ScriptElement.cpp:

(WebCore::ScriptElement::requestModuleScript):

  • editing/AlternativeTextController.cpp:

(WebCore::AlternativeTextController::applyAlternativeTextToRange):

  • editing/DeleteSelectionCommand.cpp:

(WebCore::DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss):

  • editing/Editor.cpp:

(WebCore::Editor::appliedEditing):
(WebCore::Editor::markAllMisspellingsAndBadGrammarInRanges):
(WebCore::correctSpellcheckingPreservingTextCheckingParagraph):
(WebCore::scanForTelephoneNumbers):

  • editing/ReplaceSelectionCommand.cpp:

(WebCore::ReplacementFragment::removeContentsWithSideEffects):
(WebCore::ReplacementFragment::insertFragmentForTestRendering):
(WebCore::ReplaceSelectionCommand::mergeTextNodesAroundPosition):
(WebCore::ReplaceSelectionCommand::performTrivialReplace):

  • editing/TextIterator.cpp:

(WebCore::plainText):

  • editing/VisibleSelection.cpp:

(WebCore::VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries):

  • editing/cocoa/WebContentReaderCocoa.mm:

(WebCore::attachmentForFilePath):
(WebCore::attachmentForData):
(WebCore::WebContentReader::readURL):

  • editing/markup.cpp:

(WebCore::createFragmentForMarkup):

  • history/CachedFrame.cpp:

(WebCore::CachedFrameBase::restore):

  • html/HTMLBodyElement.cpp:

(WebCore::HTMLBodyElement::didFinishInsertingNode):

  • html/HTMLElement.cpp:

(WebCore::HTMLElement::updateWithTextRecognitionResult):

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::forgetResourceSpecificTracks):

  • html/OffscreenCanvas.cpp:

(WebCore::OffscreenCanvas::create):
(WebCore::OffscreenCanvas::pushBufferToPlaceholder):

  • html/ValidationMessage.cpp:

(WebCore::ValidationMessage::buildBubbleTree):

  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::makeXRCompatible):

  • html/track/VTTCue.cpp:

(WebCore::VTTCueBox::applyCSSProperties):

  • inspector/InspectorFrontendAPIDispatcher.cpp:

(WebCore::InspectorFrontendAPIDispatcher::evaluateOrQueueExpression):

  • loader/DocumentLoader.cpp:

(WebCore::DocumentLoader::willSendRequest):
(WebCore::computeResponseOriginAndCOOP):

  • loader/DocumentWriter.cpp:

(WebCore::DocumentWriter::begin):

  • loader/FrameLoadRequest.cpp:

(WebCore::FrameLoadRequest::FrameLoadRequest):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::receivedFirstData):
(WebCore::FrameLoader::loadFrameRequest):
(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::loadWithDocumentLoader):
(WebCore::FrameLoader::open):
(WebCore::FrameLoader::loadPostRequest):
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):

  • loader/NavigationScheduler.cpp:

(WebCore::ScheduledURLNavigation::ScheduledURLNavigation):

  • loader/PingLoader.cpp:

(WebCore::PingLoader::startPingLoad):

  • loader/PolicyChecker.cpp:

(WebCore::FrameLoader::PolicyChecker::checkNewWindowPolicy):

  • loader/SubframeLoader.cpp:

(WebCore::FrameLoader::SubframeLoader::requestFrame):
(WebCore::FrameLoader::SubframeLoader::loadSubframe):

  • loader/WorkerThreadableLoader.cpp:

(WebCore::WorkerThreadableLoader::MainThreadBridge::notifyIsDone):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didSendData):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveResponse):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didReceiveData):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishLoading):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFail):
(WebCore::WorkerThreadableLoader::MainThreadBridge::didFinishTiming):

  • loader/cache/CachedResource.cpp:

(WebCore::CachedResource::load):

  • loader/ios/LegacyPreviewLoader.mm:

(WebCore::LegacyPreviewLoader::previewConverterDidStartConverting):

  • page/DOMWindowExtension.cpp:

(WebCore::DOMWindowExtension::suspendForBackForwardCache):

  • page/EventHandler.cpp:

(WebCore::EventHandler::defaultWheelEventHandler):

  • page/Frame.cpp:

(WebCore::Frame::addUserScriptAwaitingNotification):

  • page/FrameView.cpp:

(WebCore::FrameView::didLayout):

  • page/Page.cpp:

(WebCore::Page::didFinishLoadingImageForElement):

  • page/PrintContext.cpp:

(WebCore::PrintContext::begin):

  • page/ios/EventHandlerIOS.mm:

(WebCore::EventHandler::mouseMoved):

  • page/mac/ImageOverlayControllerMac.mm:

(WebCore::ImageOverlayController::updateDataDetectorHighlights):
(WebCore::ImageOverlayController::elementUnderMouseDidChange):

  • page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:

(WebCore::ScrollingTreeScrollingNodeDelegateMac::createTimer):

  • page/scrolling/nicosia/ScrollingCoordinatorNicosia.cpp:

(WebCore::ScrollingCoordinatorNicosia::handleWheelEventForScrolling):

  • platform/graphics/BitmapImage.cpp:

(WebCore::BitmapImage::framesNativeImages):

  • platform/graphics/FontCascadeFonts.cpp:

(WebCore::FontCascadeFonts::FontCascadeFonts):

  • platform/graphics/ImageSource.cpp:

(WebCore::ImageSource::startAsyncDecodingQueue):

  • platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm:

(WebCore::LocalSampleBufferDisplayLayer::enqueueSample):

  • platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:

(WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData):

  • platform/graphics/cg/GraphicsContextGLCG.cpp:

(WebCore::GraphicsContextGLOpenGL::paintToCanvas):

  • platform/graphics/cg/ImageBufferCGBackend.cpp:

(WebCore::ImageBufferCGBackend::copyCGImageForEncoding const):

  • platform/graphics/displaylists/DisplayList.h:

(WebCore::DisplayList::DisplayList::cacheImageBuffer):
(WebCore::DisplayList::DisplayList::cacheNativeImage):
(WebCore::DisplayList::DisplayList::cacheFont):

  • platform/graphics/displaylists/DisplayListItems.cpp:

(WebCore::DisplayList::SetState::apply):

  • platform/graphics/gstreamer/mse/MediaSourceTrackGStreamer.cpp:

(WebCore::MediaSourceTrackGStreamer::create):

  • platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:

(webKitMediaSrcEmitStreams):

  • platform/graphics/mac/ImageMac.mm:

(WebCore::BitmapImage::snapshotNSImage):

  • platform/graphics/nicosia/NicosiaSceneIntegration.cpp:

(Nicosia::SceneIntegration::SceneIntegration):

  • platform/mac/DataDetectorHighlight.mm:

(WebCore::DataDetectorHighlight::fadeOut):

  • platform/mediastream/libwebrtc/gstreamer/RealtimeIncomingVideoSourceLibWebRTC.cpp:

(WebCore::RealtimeIncomingVideoSourceLibWebRTC::OnFrame):

  • platform/mediastream/libwebrtc/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp:

(WebCore::RealtimeOutgoingAudioSourceLibWebRTC::audioSamplesAvailable):

  • platform/network/SocketStreamHandle.cpp:

(WebCore::SocketStreamHandle::disconnect):

  • platform/network/curl/CurlRequest.cpp:

(WebCore::CurlRequest::callClient):

  • platform/network/curl/CurlResourceHandleDelegate.cpp:

(WebCore::CurlResourceHandleDelegate::curlDidReceiveResponse):

  • style/StyleBuilder.cpp:

(WebCore::Style::Builder::applyCustomProperty):

  • style/StyleBuilderCustom.h:

(WebCore::Style::BuilderCustom::applyValueCustomProperty):

  • style/StyleBuilderState.cpp:

(WebCore::Style::BuilderState::resolveImageStyles):

  • style/StyleScope.cpp:

(WebCore::Style::Scope::createOrFindSharedShadowTreeResolver):
(WebCore::Style::Scope::collectResolverScopes):

  • svg/SVGElement.cpp:

(WebCore::SVGElement::removedFromAncestor):

  • testing/Internals.cpp:

(WebCore:: const):
(WebCore::Internals::queueMicroTask):
(WebCore::Internals::queueTaskToQueueMicrotask):

  • testing/ServiceWorkerInternals.cpp:

(WebCore::ServiceWorkerInternals::waitForFetchEventToFinish):

  • workers/Worker.cpp:

(WebCore::Worker::createRTCRtpScriptTransformer):

  • workers/WorkerGlobalScope.cpp:

(WebCore::WorkerGlobalScope::createRTCDataChannelRemoteHandlerConnection):

  • workers/WorkerOrWorkletScriptController.cpp:

(WebCore::WorkerOrWorkletScriptController::loadModuleSynchronously):
(WebCore::WorkerOrWorkletScriptController::loadAndEvaluateModule):

  • workers/service/FetchEvent.cpp:

(WebCore::FetchEvent::promiseIsSettled):

  • workers/service/ServiceWorkerGlobalScope.cpp:

(WebCore::ServiceWorkerGlobalScope::skipWaiting):

  • workers/service/context/SWContextManager.cpp:

(WebCore::SWContextManager::stopWorker):

  • workers/service/context/ServiceWorkerThread.cpp:

(WebCore::ServiceWorkerThread::queueTaskToFireFetchEvent):
(WebCore::ServiceWorkerThread::queueTaskToPostMessage):
(WebCore::ServiceWorkerThread::queueTaskToFireInstallEvent):
(WebCore::ServiceWorkerThread::queueTaskToFireActivateEvent):

  • workers/service/context/ServiceWorkerThreadProxy.cpp:

(WebCore::ServiceWorkerThreadProxy::notifyNetworkStateChange):
(WebCore::ServiceWorkerThreadProxy::continueDidReceiveFetchResponse):

  • xml/XMLHttpRequestProgressEventThrottle.cpp:

(WebCore::XMLHttpRequestProgressEventThrottle::dispatchEventWhenPossible):

Source/WTF:

  • wtf/WeakPtr.h:

(WTF::WeakPtrFactory::createWeakPtr const):

  • Property svn:eol-style set to native
File size: 5.9 KB
Line 
1/*
2 * Copyright (C) 2010 Julien Chaffraix <[email protected]> All right reserved.
3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "config.h"
28#include "XMLHttpRequestProgressEventThrottle.h"
29
30#include "EventNames.h"
31#include "EventTarget.h"
32#include "XMLHttpRequest.h"
33#include "XMLHttpRequestProgressEvent.h"
34
35namespace WebCore {
36
37const Seconds XMLHttpRequestProgressEventThrottle::minimumProgressEventDispatchingInterval { 50_ms }; // 50 ms per specification.
38
39XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle(XMLHttpRequest& target)
40 : m_target(target)
41 , m_dispatchThrottledProgressEventTimer(target.scriptExecutionContext(), *this, &XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEventTimerFired)
42{
43 m_dispatchThrottledProgressEventTimer.suspendIfNeeded();
44}
45
46XMLHttpRequestProgressEventThrottle::~XMLHttpRequestProgressEventThrottle() = default;
47
48void XMLHttpRequestProgressEventThrottle::updateProgress(bool isAsync, bool lengthComputable, unsigned long long loaded, unsigned long long total)
49{
50 m_lengthComputable = lengthComputable;
51 m_loaded = loaded;
52 m_total = total;
53
54 if (!isAsync || !m_target.hasEventListeners(eventNames().progressEvent))
55 return;
56
57 if (!m_shouldDeferEventsDueToSuspension && !m_dispatchThrottledProgressEventTimer.isActive()) {
58 // The timer is not active so the least frequent event for now is every byte. Just dispatch the event.
59
60 // We should not have any throttled progress event.
61 ASSERT(!m_hasPendingThrottledProgressEvent);
62
63 dispatchEventWhenPossible(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, lengthComputable, loaded, total));
64 m_dispatchThrottledProgressEventTimer.startRepeating(minimumProgressEventDispatchingInterval);
65 m_hasPendingThrottledProgressEvent = false;
66 return;
67 }
68
69 // The timer is already active so minimumProgressEventDispatchingInterval is the least frequent event.
70 m_hasPendingThrottledProgressEvent = true;
71}
72
73void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(Event& event, ProgressEventAction progressEventAction)
74{
75 if (progressEventAction == FlushProgressEvent)
76 flushProgressEvent();
77
78 dispatchEventWhenPossible(event);
79}
80
81void XMLHttpRequestProgressEventThrottle::dispatchEventWhenPossible(Event& event)
82{
83 if (m_shouldDeferEventsDueToSuspension)
84 m_target.queueTaskToDispatchEvent(m_target, TaskSource::Networking, event);
85 else
86 m_target.dispatchEvent(event);
87}
88
89void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(const AtomString& type)
90{
91 ASSERT(type == eventNames().loadstartEvent || type == eventNames().progressEvent || type == eventNames().loadEvent || type == eventNames().loadendEvent || type == eventNames().abortEvent || type == eventNames().errorEvent || type == eventNames().timeoutEvent);
92
93 if (type == eventNames().loadstartEvent) {
94 m_lengthComputable = false;
95 m_loaded = 0;
96 m_total = 0;
97 }
98
99 if (m_target.hasEventListeners(type))
100 dispatchEventWhenPossible(XMLHttpRequestProgressEvent::create(type, m_lengthComputable, m_loaded, m_total));
101}
102
103void XMLHttpRequestProgressEventThrottle::flushProgressEvent()
104{
105 if (!m_hasPendingThrottledProgressEvent)
106 return;
107
108 m_hasPendingThrottledProgressEvent = false;
109 // We stop the timer as this is called when no more events are supposed to occur.
110 m_dispatchThrottledProgressEventTimer.cancel();
111
112 dispatchEventWhenPossible(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total));
113}
114
115void XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEventTimerFired()
116{
117 ASSERT(m_dispatchThrottledProgressEventTimer.isActive());
118 if (!m_hasPendingThrottledProgressEvent) {
119 // No progress event was queued since the previous dispatch, we can safely stop the timer.
120 m_dispatchThrottledProgressEventTimer.cancel();
121 return;
122 }
123
124 dispatchEventWhenPossible(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total));
125 m_hasPendingThrottledProgressEvent = false;
126}
127
128void XMLHttpRequestProgressEventThrottle::suspend()
129{
130 m_shouldDeferEventsDueToSuspension = true;
131
132 if (m_hasPendingThrottledProgressEvent) {
133 m_target.queueTaskKeepingObjectAlive(m_target, TaskSource::Networking, [this] {
134 flushProgressEvent();
135 });
136 }
137}
138
139void XMLHttpRequestProgressEventThrottle::resume()
140{
141 m_target.queueTaskKeepingObjectAlive(m_target, TaskSource::Networking, [this] {
142 m_shouldDeferEventsDueToSuspension = false;
143 });
144}
145
146} // namespace WebCore
Note: See TracBrowser for help on using the repository browser.