haikuwebkit/Source/WTF/wtf/CancellableTask.h

93 lines
3.0 KiB
C
Raw Permalink Normal View History

Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
/*
* Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <wtf/Function.h>
#include <wtf/UniqueRef.h>
#include <wtf/WeakPtr.h>
namespace WTF {
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
class CancellableTask;
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
class TaskCancellationGroup : public CanMakeWeakPtr<TaskCancellationGroup> {
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
public:
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
TaskCancellationGroup() : m_impl(makeUniqueRef<Impl>()) { }
void cancel() { m_impl->cancel(); }
bool hasPendingTask() const { return m_impl->hasPendingTask(); }
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
private:
friend class CancellableTask;
class Impl : public CanMakeWeakPtr<Impl> {
WTF_MAKE_FAST_ALLOCATED;
public:
void cancel() { weakPtrFactory().revokeAll(); }
bool hasPendingTask() const { return weakPtrFactory().weakPtrCount(); }
};
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
class Handle {
public:
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
bool isCancelled() const { return !m_impl; }
void clear() { m_impl = nullptr; }
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
private:
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
friend class TaskCancellationGroup;
explicit Handle(Impl& impl) : m_impl(makeWeakPtr(impl)) { }
WeakPtr<Impl> m_impl;
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
};
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
Handle createHandle() { return Handle { m_impl }; }
UniqueRef<Impl> m_impl;
};
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
class CancellableTask {
public:
CancellableTask(TaskCancellationGroup&, Function<void()>&&);
void operator()();
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
private:
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
TaskCancellationGroup::Handle m_cancellationGroup;
Function<void()> m_task;
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
};
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
inline CancellableTask::CancellableTask(TaskCancellationGroup& cancellationGroup, Function<void()>&& task)
: m_cancellationGroup(cancellationGroup.createHandle())
, m_task(WTFMove(task))
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
{ }
inline void CancellableTask::operator()()
{
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
if (m_cancellationGroup.isCancelled())
return;
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
m_cancellationGroup.clear();
m_task();
Stop using legacy EventLoopDeferrableTask https://bugs.webkit.org/show_bug.cgi?id=226700 Reviewed by Darin Adler. Source/WebCore: Stop using legacy EventLoopDeferrableTask and drop the class entirely. Call sites are now using the HTML event loop directly and using WTF::CancellableTask to wrap the task they schedule. This achieves the same result as EventLoopDeferrableTask but is more lightweight and flexible. * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::DocumentTimelinesController): (WebCore::DocumentTimelinesController::detachFromDocument): (WebCore::DocumentTimelinesController::cacheCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/DeferrableTask.h: Source/WTF: Introduce new WTF::CancellableTask type which is a wrapper around a WTF::Function. It can create a handle for the task and this handle can be used to check if the task is still pending and to cancel it. This is useful when scheduling tasks in the event loop for example as there are cases where we need to know if a task we scheduled is still pending (to avoid double scheduling) or where we need to cancel a previously scheduled task. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/CancellableTask.h: Added. (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): (WTF::CancellableTask::isPending const): (WTF::CancellableTask::cancel): (WTF::CancellableTask::Handle::Handle): (WTF::CancellableTask::Handle::isPending const): (WTF::CancellableTask::Handle::cancel): (WTF::CancellableTask::createHandle): Canonical link: https://commits.webkit.org/238541@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278543 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-07 04:22:38 +00:00
}
} // namespace WTF
using WTF::CancellableTask;
Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes https://bugs.webkit.org/show_bug.cgi?id=226734 Reviewed by Ryosuke Niwa. Source/WebCore: Drop legacy MainThreadTaskQueue & EventLoopTaskQueue classes. Code that was using MainThreadTaskQueue is now calling callOnMainThread() directly. Call that was using EventLoopTaskQueue is now using the HTML event loop directly. If said code needed to cancel tasks or check if a previously scheduled task is still pending, it now relies on WTF::CancellableTask / WTF::TaskCancellationGroup to do so. * Headers.cmake: * Modules/encryptedmedia/MediaKeySystemAccess.cpp: * WebCore.xcodeproj/project.pbxproj: * animation/DocumentTimelinesController.cpp: (WebCore::DocumentTimelinesController::cacheCurrentTime): (WebCore::DocumentTimelinesController::maybeClearCachedCurrentTime): * animation/DocumentTimelinesController.h: * dom/ActiveDOMObject.h: * dom/Document.h: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::HTMLMediaElement): (WebCore::HTMLMediaElement::~HTMLMediaElement): (WebCore::HTMLMediaElement::scheduleNextSourceChild): (WebCore::HTMLMediaElement::scheduleCheckPlaybackTargetCompatability): (WebCore::HTMLMediaElement::seekWithTolerance): (WebCore::HTMLMediaElement::setVolume): (WebCore::HTMLMediaElement::scheduleConfigureTextTracks): (WebCore::HTMLMediaElement::scheduleMediaEngineWasUpdated): (WebCore::HTMLMediaElement::scheduleUpdatePlayState): (WebCore::HTMLMediaElement::cancelPendingTasks): (WebCore::HTMLMediaElement::clearMediaPlayer): (WebCore::HTMLMediaElement::closeTaskQueues): (WebCore::HTMLMediaElement::suspend): (WebCore::HTMLMediaElement::resume): (WebCore::HTMLMediaElement::virtualHasPendingActivity const): (WebCore::HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured): (WebCore::HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged): (WebCore::HTMLMediaElement::scheduleUpdateMediaState): (WebCore::HTMLMediaElement::playbackControlsManagerBehaviorRestrictionsTimerFired): * html/HTMLMediaElement.h: * platform/GenericTaskQueue.h: Removed. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (-[WebCoreAVFMovieObserver metadataLoaded]): (-[WebCoreAVFMovieObserver didEnd:]): (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFMovieObserver metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:]): (-[WebCoreAVFMovieObserver metadataCollector:didCollectDateRangeMetadataGroups:indexesOfNewGroups:indexesOfModifiedGroups:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h: * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): (WebCore::SourceBufferPrivateAVFObjC::didParseInitializationData): (WebCore::SourceBufferPrivateAVFObjC::abort): * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.h: Source/WTF: We recently introduced the WTF::CancellableTask in order to be able to cancel a pending task in the event loop, and/or check if the task is still pending. It worked great as a replacement for EventLoopDeferrableTask. However, it was insufficient as a replacement for task queues (such as MainThreadTaskQueue & EventLoopTaskQueue) since there was no convenient way to cancel a group of tasks. To address this, I am introducing WTF::TaskCancellationGroup. Whenever one needs to create a CancellableTask, it now needs to provide a TaskCancellationGroup. Several CancellableTask objects can share the same TaskCancellationGroup. Code now now schedule one or more CancellableTasks on the event loop and hold on to a TaskCancellationGroup. If they need to cancel those tasks, they can simply call cancel() on the TaskCancellationGroup. They can also check if previously scheduled tasks are still pending via TaskCancellationGroup::hasPendingTask(). * wtf/CancellableTask.h: (WTF::TaskCancellationGroup::TaskCancellationGroup): (WTF::TaskCancellationGroup::cancel): (WTF::TaskCancellationGroup::hasPendingTask const): (WTF::TaskCancellationGroup::Impl::cancel): (WTF::TaskCancellationGroup::Impl::hasPendingTask const): (WTF::TaskCancellationGroup::Handle::isCancelled const): (WTF::TaskCancellationGroup::Handle::Handle): (WTF::TaskCancellationGroup::createHandle): (WTF::CancellableTask::CancellableTask): (WTF::CancellableTask::operator()): * wtf/WeakPtr.h: (WTF::WeakPtrFactory::weakPtrCount const): Canonical link: https://commits.webkit.org/238574@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278580 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-08 00:29:50 +00:00
using WTF::TaskCancellationGroup;