haikuwebkit/Source/WTF/wtf/Function.h

130 lines
4.9 KiB
C
Raw Permalink Normal View History

callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
/*
* Copyright (C) 2016-2019 Apple Inc. All rights reserved.
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
*
* 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 <memory>
#include <wtf/FastMalloc.h>
Remove <wtf/Optional.h> https://bugs.webkit.org/show_bug.cgi?id=226437 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Remove include of <wtf/Optional.h>. * inspector/scripts/codegen/generate_cpp_backend_dispatcher_header.py: (CppBackendDispatcherHeaderGenerator._generate_secondary_header_includes): Don't generate an include of wtf/Optional.h; including WTFString.h takes care of this anyway. * inspector/scripts/codegen/generate_cpp_frontend_dispatcher_header.py: (CppFrontendDispatcherHeaderGenerator._generate_secondary_header_includes): Ditto. * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: (CppProtocolTypesHeaderGenerator._generate_secondary_header_includes): Ditto. * inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py: (CppProtocolTypesImplementationGenerator.generate_output): Generate an include of <optional> instead of <wtf/Optional.h>. * inspector/scripts/tests/expected/*: Regenerate. Source/WebCore: * <many files>: Removed include of <wtf/Optional.h>. * platform/graphics/Font.h: Tweaked style a bit. * Modules/geolocation/GeolocationClient.h: Added include of <optional>. * Modules/mediastream/DoubleRange.h: Ditto. * Modules/mediastream/LongRange.h: Ditto. * Modules/webauthn/AuthenticationExtensionsClientOutputs.h: Ditto. * css/CSSToLengthConversionData.h: Ditto. * css/DOMMatrix2DInit.h: Ditto. * dom/AddEventListenerOptions.h: Ditto. * dom/DeviceMotionData.h: Ditto. * dom/DeviceOrientationData.h: Ditto. * dom/SuccessOr.h: Ditto. * html/DateTimeFieldsState.h: Ditto. * html/ImageBitmapOptions.h: Ditto. * html/canvas/PredefinedColorSpace.h: Ditto. * layout/LayoutPhase.h: Ditto. * layout/MarginTypes.h: Ditto. * loader/ResourceLoadNotifier.h: Ditto. * page/RuntimeEnabledFeatures.h: Ditto. * page/ScrollOptions.h: Ditto. * platform/MediaCapabilitiesInfo.h: Ditto. * platform/cocoa/SystemBattery.h: Ditto. * platform/graphics/DecodingOptions.h: Ditto. * platform/graphics/DestinationColorSpace.h: Ditto. * platform/graphics/DisplayRefreshMonitorClient.h: Ditto. * platform/graphics/FloatLine.h: Ditto. * platform/graphics/gpu/GPURequestAdapterOptions.h: Ditto. * platform/graphics/x11/PlatformDisplayX11.h: Ditto. * platform/ios/SelectionGeometry.h: Ditto. * platform/mac/NSScrollerImpDetails.h: Ditto. * platform/network/DNS.h: Ditto. * platform/text/EncodingTables.h: Ditto. * platform/text/TextCodecCJK.h: Ditto. * platform/text/TextCodecUTF16.h: Ditto. * platform/text/TextFlags.h: Ditto. Source/WebCore/PAL: * pal/SessionID.h: Include <optional>. * pal/crypto/gcrypt/Utilities.h: Ditto. * pal/crypto/tasn1/Utilities.cpp: Removed include of <wtf/Optional.h>. Source/WebDriver: * SessionHost.h: Removed include of <wtf/Optional.h>. Source/WebKit: * <many files>: Removed include of <wtf/Optional.h>. Source/WebKitLegacy/mac: * DOM/DOMRangeInternal.h: Added import of <optional>. * WebView/WebGeolocationPosition.mm: Removed import of <wtf/Optional.h>. * WebView/WebGeolocationPositionInternal.h: Added import of <optional>. Source/WTF: * <many files>: Removed include of <wtf/Optional.h>. * WTF.xcodeproj/project.pbxproj: Removed Optional.h. * wtf/Markable.h: Added include of <optional>. * wtf/OptionSet.h: Ditto. * wtf/Optional.h: Emptied this file. On the Windows build system, we can't seem to build successfully without an empty file here. The copied forwarding header seems to linger even if we remove the original. Until we fix the Windows build system, if we want to support incremental builds, we need to keep this empty file around. * wtf/PrintStream.h: Added include of <optional>. * wtf/Seconds.h: Ditto. * wtf/StackTrace.h: Ditto. * wtf/StdLibExtras.h: Moved the valueOrCompute function here from Optional.h. Re-sorted the "using" at the bottom of the file. * wtf/URLHelpers.h: Added include of <optional>. * wtf/Vector.h: Ditto. Tools: * <many files>: Removed include of <wtf/Optional.h>. Canonical link: https://commits.webkit.org/238372@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278340 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-02 06:45:51 +00:00
#include <wtf/Forward.h>
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
namespace WTF {
namespace Detail {
template<typename Out, typename... In>
class CallableWrapperBase {
WTF_MAKE_FAST_ALLOCATED;
public:
virtual ~CallableWrapperBase() { }
virtual Out call(In...) = 0;
};
template<typename, typename, typename...> class CallableWrapper;
template<typename CallableType, typename Out, typename... In>
class CallableWrapper : public CallableWrapperBase<Out, In...> {
public:
explicit CallableWrapper(CallableType&& callable)
: m_callable(WTFMove(callable)) { }
CallableWrapper(const CallableWrapper&) = delete;
CallableWrapper& operator=(const CallableWrapper&) = delete;
Out call(In... in) final { return m_callable(std::forward<In>(in)...); }
private:
CallableType m_callable;
};
} // namespace Detail
template<typename Out, typename... In> Function<Out(In...)> adopt(Detail::CallableWrapperBase<Out, In...>*);
Templatize NoncopyableFunction class similarly to std::function https://bugs.webkit.org/show_bug.cgi?id=158185 Reviewed by Darin Adler. Templatize NoncopyableFunction class similarly to std::function, so that it can be used as a std::function replacement in more places. Previously, NoncopyableFunction could only support "void()" lambdas. Source/WebCore: * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::perform): (WebCore::AsyncFileStream::getSize): (WebCore::AsyncFileStream::openForRead): (WebCore::AsyncFileStream::openForWrite): (WebCore::AsyncFileStream::write): * fileapi/AsyncFileStream.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): Source/WebKit: * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): * Storage/StorageThread.h: Source/WebKit2: * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp: (WebKit::NetworkCache::runTaskInQueue): Source/WTF: * wtf/FunctionDispatcher.h: * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: * wtf/NoncopyableFunction.h: * wtf/RunLoop.cpp: (WTF::RunLoop::performWork): (WTF::RunLoop::dispatch): * wtf/RunLoop.h: * wtf/WorkQueue.h: * wtf/cocoa/WorkQueueCocoa.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/efl/DispatchQueueWorkItemEfl.h: (WorkItem::WorkItem): (TimerWorkItem::create): (TimerWorkItem::TimerWorkItem): * wtf/efl/WorkQueueEfl.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/generic/RunLoopGeneric.cpp: (WTF::RunLoop::TimerBase::ScheduledTask::create): (WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask): (WTF::RunLoop::dispatchAfter): * wtf/generic/WorkQueueGeneric.cpp: (WorkQueue::dispatch): (WorkQueue::dispatchAfter): * wtf/glib/RunLoopGLib.cpp: (WTF::DispatchAfterContext::DispatchAfterContext): (WTF::RunLoop::dispatchAfter): * wtf/win/WorkItemWin.cpp: (WTF::WorkItemWin::WorkItemWin): (WTF::WorkItemWin::create): (WTF::HandleWorkItem::HandleWorkItem): (WTF::HandleWorkItem::createByAdoptingHandle): * wtf/win/WorkItemWin.h: (WTF::WorkItemWin::function): * wtf/win/WorkQueueWin.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): Canonical link: https://commits.webkit.org/176293@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201493 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-29 04:20:06 +00:00
template <typename Out, typename... In>
Rename NoncopyableFunction to Function https://bugs.webkit.org/show_bug.cgi?id=158354 Reviewed by Chris Dumez. Source/WebCore: * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/webaudio/AudioDestinationNode.h: (WebCore::AudioDestinationNode::resume): (WebCore::AudioDestinationNode::suspend): (WebCore::AudioDestinationNode::close): * Modules/webaudio/DefaultAudioDestinationNode.cpp: (WebCore::DefaultAudioDestinationNode::resume): (WebCore::DefaultAudioDestinationNode::suspend): (WebCore::DefaultAudioDestinationNode::close): * Modules/webaudio/DefaultAudioDestinationNode.h: * dom/ActiveDOMCallbackMicrotask.cpp: (WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask): * dom/ActiveDOMCallbackMicrotask.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::Task::Task): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * page/FrameView.cpp: (WebCore::FrameView::queuePostLayoutCallback): (WebCore::FrameView::flushPostLayoutTasksQueue): * page/FrameView.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * platform/GenericTaskQueue.cpp: (WebCore::TaskDispatcher<Timer>::postTask): * platform/GenericTaskQueue.h: (WebCore::TaskDispatcher::postTask): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * style/StyleTreeResolver.cpp: (WebCore::Style::postResolutionCallbackQueue): (WebCore::Style::queuePostResolutionCallback): * style/StyleTreeResolver.h: Source/WebKit: * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): * Storage/StorageThread.h: Source/WebKit2: * NetworkProcess/NetworkProcess.cpp: (WebKit::fetchDiskCacheEntries): (WebKit::NetworkProcess::fetchWebsiteData): (WebKit::clearDiskCacheEntries): * NetworkProcess/NetworkProcess.h: * NetworkProcess/cache/NetworkCache.cpp: (WebKit::NetworkCache::Cache::traverse): * NetworkProcess/cache/NetworkCache.h: * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp: (WebKit::NetworkCache::runTaskInQueue): * NetworkProcess/cache/NetworkCacheStorage.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadTask.h: (WTF::CrossThreadTask::CrossThreadTask): * wtf/Function.h: Renamed from Source/WTF/wtf/NoncopyableFunction.h. * wtf/FunctionDispatcher.h: * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: * wtf/RunLoop.cpp: (WTF::RunLoop::performWork): (WTF::RunLoop::dispatch): * wtf/RunLoop.h: * wtf/WorkQueue.h: * wtf/cocoa/WorkQueueCocoa.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/efl/DispatchQueueWorkItemEfl.h: (WorkItem::WorkItem): (TimerWorkItem::create): (TimerWorkItem::TimerWorkItem): * wtf/efl/WorkQueueEfl.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/generic/RunLoopGeneric.cpp: (WTF::RunLoop::TimerBase::ScheduledTask::create): (WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask): (WTF::RunLoop::dispatchAfter): * wtf/generic/WorkQueueGeneric.cpp: (WorkQueue::dispatch): (WorkQueue::dispatchAfter): * wtf/glib/RunLoopGLib.cpp: (WTF::DispatchAfterContext::DispatchAfterContext): (WTF::RunLoop::dispatchAfter): * wtf/win/WorkItemWin.cpp: (WTF::WorkItemWin::WorkItemWin): (WTF::WorkItemWin::create): (WTF::HandleWorkItem::HandleWorkItem): (WTF::HandleWorkItem::createByAdoptingHandle): * wtf/win/WorkItemWin.h: (WTF::WorkItemWin::function): * wtf/win/WorkQueueWin.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): Canonical link: https://commits.webkit.org/177198@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202439 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-24 19:40:19 +00:00
class Function<Out(In...)> {
Mark more heap-allocated classes as fast allocated https://bugs.webkit.org/show_bug.cgi?id=194422 Reviewed by Ryosuke Niwa. Source/WebCore: * Modules/applepay/PaymentCoordinator.h: * Modules/beacon/NavigatorBeacon.h: * Modules/cache/DOMWindowCaches.h: * Modules/cache/WorkerGlobalScopeCaches.h: * Modules/credentialmanagement/NavigatorCredentials.h: * Modules/encryptedmedia/legacy/LegacyCDMPrivateClearKey.h: * Modules/gamepad/NavigatorGamepad.h: * Modules/indexeddb/IDBGetAllResult.h: * Modules/indexeddb/IDBGetResult.h: * Modules/indexeddb/IDBKeyData.h: * Modules/indexeddb/IDBValue.h: * Modules/indexeddb/WorkerGlobalScopeIndexedDatabase.h: * Modules/indexeddb/server/IndexValueEntry.h: * Modules/indexeddb/server/IndexValueStore.h: * Modules/indexeddb/server/MemoryBackingStoreTransaction.h: * Modules/indexeddb/server/MemoryCursor.h: * Modules/indexeddb/server/MemoryIDBBackingStore.h: * Modules/indexeddb/server/SQLiteIDBBackingStore.h: * Modules/indexeddb/server/SQLiteIDBCursor.h: * Modules/indexeddb/server/SQLiteIDBTransaction.h: * Modules/indexeddb/server/UniqueIDBDatabase.h: * Modules/indexeddb/shared/IDBDatabaseInfo.h: * Modules/indexeddb/shared/IDBResourceIdentifier.h: * Modules/indexeddb/shared/IDBTransactionInfo.h: * Modules/mediacapabilities/NavigatorMediaCapabilities.h: * Modules/mediasession/WebMediaSessionManager.cpp: * Modules/mediastream/NavigatorMediaDevices.h: * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h: * Modules/mediastream/libwebrtc/LibWebRTCRtpTransceiverBackend.h: * Modules/navigatorcontentutils/NavigatorContentUtils.h: * Modules/quota/DOMWindowQuota.h: * Modules/quota/NavigatorStorageQuota.h: * Modules/quota/WorkerNavigatorStorageQuota.h: * Modules/speech/DOMWindowSpeechSynthesis.h: * Modules/webaudio/BiquadProcessor.h: * Modules/webaudio/DelayProcessor.h: * Modules/webauthn/fido/FidoHidPacket.h: * Modules/webdriver/NavigatorWebDriver.h: * Modules/webgpu/DOMWindowWebGPU.h: * Modules/websockets/WebSocketChannel.h: * Modules/webvr/NavigatorWebVR.h: * accessibility/AXObjectCache.h: * bindings/js/DOMGCOutputConstraint.h: * bindings/js/DOMPromiseProxy.h: * bridge/c/c_runtime.h: * contentextensions/CombinedURLFilters.cpp: * crypto/CryptoAlgorithmParameters.h: * css/CSSComputedStyleDeclaration.h: * css/CSSRegisteredCustomProperty.h: * css/DOMCSSPaintWorklet.h: * css/DOMCSSRegisterCustomProperty.h: * css/StyleRule.h: * dom/ConstantPropertyMap.h: * dom/CustomElementReactionQueue.h: * dom/Document.h: * dom/GenericEventQueue.h: * dom/RejectedPromiseTracker.h: * dom/UserGestureIndicator.h: * editing/ReplaceSelectionCommand.cpp: * editing/SelectionRectGatherer.h: * editing/TextIterator.h: * editing/cocoa/HTMLConverter.mm: * fileapi/AsyncFileStream.cpp: * fileapi/AsyncFileStream.h: * html/forms/FileIconLoader.h: * html/parser/HTMLTreeBuilder.h: * html/track/WebVTTParser.h: * inspector/DOMPatchSupport.cpp: * loader/FrameLoaderClient.h: * loader/WorkerThreadableLoader.cpp: * page/IntersectionObserver.h: * page/PerformanceMonitor.h: * page/PerformanceUserTiming.h: * page/PrintContext.h: * page/ValidationMessageClient.h: * platform/ColorChooser.h: * platform/ControlStates.h: * platform/DataListSuggestionPicker.h: * platform/FileStream.h: * platform/KeyedCoding.h: * platform/LowPowerModeNotifier.h: * platform/PlatformSpeechSynthesizer.h: * platform/WebGLStateTracker.h: * platform/audio/AudioArray.h: * platform/audio/AudioDestination.h: * platform/audio/DownSampler.h: * platform/audio/DynamicsCompressor.h: * platform/audio/FFTFrame.h: * platform/audio/HRTFDatabase.h: * platform/audio/MultiChannelResampler.h: * platform/audio/Panner.h: * platform/audio/Reverb.h: * platform/audio/ReverbConvolver.h: * platform/audio/ReverbConvolverStage.h: * platform/audio/UpSampler.h: * platform/audio/mac/AudioSessionMac.cpp: * platform/audio/mac/CAAudioStreamDescription.h: * platform/audio/mac/CARingBuffer.h: * platform/cocoa/ScrollSnapAnimatorState.h: * platform/gamepad/PlatformGamepad.h: * platform/graphics/GraphicsLayer.cpp: * platform/graphics/GraphicsLayerFactory.h: * platform/graphics/PlatformTimeRanges.h: * platform/graphics/TextTrackRepresentation.h: * platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.h: * platform/graphics/avfoundation/objc/CDMSessionAVStreamSession.h: * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h: * platform/graphics/displaylists/DisplayListRecorder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: * platform/sql/SQLiteDatabase.h: * platform/text/TextCodecICU.h: * rendering/GridBaselineAlignment.h: * rendering/GridTrackSizingAlgorithm.h: * rendering/RenderObject.h: * rendering/style/GridArea.h: * workers/service/context/SWContextManager.h: Source/WebCore/PAL: * pal/crypto/openssl/CryptoDigestOpenSSL.cpp: * pal/system/Clock.h: Source/WebKit: * NetworkProcess/NetworkLoad.cpp: * NetworkProcess/NetworkLoadChecker.h: * NetworkProcess/NetworkResourceLoader.cpp: * Platform/IPC/Connection.h: * Platform/IPC/mac/ImportanceAssertion.h: * PluginProcess/PluginCreationParameters.h: * Shared/API/Cocoa/RemoteObjectRegistry.h: * Shared/WebEvent.h: * UIProcess/API/APIHTTPCookieStore.cpp: * UIProcess/API/APINotificationProvider.h: * UIProcess/API/Cocoa/PageLoadStateObserver.h: * UIProcess/API/Cocoa/WKHTTPCookieStore.mm: * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _setInputDelegate:]): * UIProcess/API/gtk/PageClientImpl.h: * UIProcess/BackingStore.h: * UIProcess/Cocoa/AutomationClient.h: * UIProcess/Cocoa/DiagnosticLoggingClient.h: * UIProcess/Cocoa/DownloadClient.h: * UIProcess/Cocoa/FindClient.h: * UIProcess/Cocoa/NavigationState.h: * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/ViewGestureController.h: * UIProcess/DeviceIdHashSaltStorage.h: * UIProcess/Downloads/DownloadProxyMap.h: * UIProcess/Gamepad/UIGamepad.h: * UIProcess/Notifications/WebNotificationProvider.h: * UIProcess/ProcessAssertion.h: * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h: * UIProcess/WebContextInjectedBundleClient.h: * UIProcess/WebFormClient.h: * UIProcess/WebGeolocationProvider.h: * UIProcess/WebPageProxy.h: * WebProcess/Automation/WebAutomationSessionProxy.h: * WebProcess/InjectedBundle/API/APIInjectedBundleBundleClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundleEditorClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageContextMenuClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageLoaderClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageResourceLoadClient.h: * WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h: * WebProcess/InjectedBundle/APIInjectedBundleFormClient.h: * WebProcess/Network/webrtc/LibWebRTCNetwork.h: * WebProcess/Network/webrtc/LibWebRTCSocket.h: * WebProcess/Network/webrtc/WebRTCResolver.h: * WebProcess/WebCoreSupport/WebInspectorClient.cpp: * WebProcess/WebPage/DrawingArea.h: Source/WTF: * wtf/Function.h: (WTF::Function<Out): * wtf/RefCounter.h: * wtf/URL.h: * wtf/text/StringView.cpp: Canonical link: https://commits.webkit.org/208851@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241183 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-08 02:38:46 +00:00
WTF_MAKE_FAST_ALLOCATED;
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
public:
using Impl = Detail::CallableWrapperBase<Out, In...>;
Rename NoncopyableFunction to Function https://bugs.webkit.org/show_bug.cgi?id=158354 Reviewed by Chris Dumez. Source/WebCore: * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/webaudio/AudioDestinationNode.h: (WebCore::AudioDestinationNode::resume): (WebCore::AudioDestinationNode::suspend): (WebCore::AudioDestinationNode::close): * Modules/webaudio/DefaultAudioDestinationNode.cpp: (WebCore::DefaultAudioDestinationNode::resume): (WebCore::DefaultAudioDestinationNode::suspend): (WebCore::DefaultAudioDestinationNode::close): * Modules/webaudio/DefaultAudioDestinationNode.h: * dom/ActiveDOMCallbackMicrotask.cpp: (WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask): * dom/ActiveDOMCallbackMicrotask.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::Task::Task): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * page/FrameView.cpp: (WebCore::FrameView::queuePostLayoutCallback): (WebCore::FrameView::flushPostLayoutTasksQueue): * page/FrameView.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * platform/GenericTaskQueue.cpp: (WebCore::TaskDispatcher<Timer>::postTask): * platform/GenericTaskQueue.h: (WebCore::TaskDispatcher::postTask): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * style/StyleTreeResolver.cpp: (WebCore::Style::postResolutionCallbackQueue): (WebCore::Style::queuePostResolutionCallback): * style/StyleTreeResolver.h: Source/WebKit: * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): * Storage/StorageThread.h: Source/WebKit2: * NetworkProcess/NetworkProcess.cpp: (WebKit::fetchDiskCacheEntries): (WebKit::NetworkProcess::fetchWebsiteData): (WebKit::clearDiskCacheEntries): * NetworkProcess/NetworkProcess.h: * NetworkProcess/cache/NetworkCache.cpp: (WebKit::NetworkCache::Cache::traverse): * NetworkProcess/cache/NetworkCache.h: * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp: (WebKit::NetworkCache::runTaskInQueue): * NetworkProcess/cache/NetworkCacheStorage.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadTask.h: (WTF::CrossThreadTask::CrossThreadTask): * wtf/Function.h: Renamed from Source/WTF/wtf/NoncopyableFunction.h. * wtf/FunctionDispatcher.h: * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: * wtf/RunLoop.cpp: (WTF::RunLoop::performWork): (WTF::RunLoop::dispatch): * wtf/RunLoop.h: * wtf/WorkQueue.h: * wtf/cocoa/WorkQueueCocoa.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/efl/DispatchQueueWorkItemEfl.h: (WorkItem::WorkItem): (TimerWorkItem::create): (TimerWorkItem::TimerWorkItem): * wtf/efl/WorkQueueEfl.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/generic/RunLoopGeneric.cpp: (WTF::RunLoop::TimerBase::ScheduledTask::create): (WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask): (WTF::RunLoop::dispatchAfter): * wtf/generic/WorkQueueGeneric.cpp: (WorkQueue::dispatch): (WorkQueue::dispatchAfter): * wtf/glib/RunLoopGLib.cpp: (WTF::DispatchAfterContext::DispatchAfterContext): (WTF::RunLoop::dispatchAfter): * wtf/win/WorkItemWin.cpp: (WTF::WorkItemWin::WorkItemWin): (WTF::WorkItemWin::create): (WTF::HandleWorkItem::HandleWorkItem): (WTF::HandleWorkItem::createByAdoptingHandle): * wtf/win/WorkItemWin.h: (WTF::WorkItemWin::function): * wtf/win/WorkQueueWin.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): Canonical link: https://commits.webkit.org/177198@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202439 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-24 19:40:19 +00:00
Function() = default;
Function(std::nullptr_t) { }
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
template<typename CallableType, class = typename std::enable_if<!(std::is_pointer<CallableType>::value && std::is_function<typename std::remove_pointer<CallableType>::type>::value) && std::is_rvalue_reference<CallableType&&>::value>::type>
Rename NoncopyableFunction to Function https://bugs.webkit.org/show_bug.cgi?id=158354 Reviewed by Chris Dumez. Source/WebCore: * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/webaudio/AudioDestinationNode.h: (WebCore::AudioDestinationNode::resume): (WebCore::AudioDestinationNode::suspend): (WebCore::AudioDestinationNode::close): * Modules/webaudio/DefaultAudioDestinationNode.cpp: (WebCore::DefaultAudioDestinationNode::resume): (WebCore::DefaultAudioDestinationNode::suspend): (WebCore::DefaultAudioDestinationNode::close): * Modules/webaudio/DefaultAudioDestinationNode.h: * dom/ActiveDOMCallbackMicrotask.cpp: (WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask): * dom/ActiveDOMCallbackMicrotask.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::Task::Task): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * page/FrameView.cpp: (WebCore::FrameView::queuePostLayoutCallback): (WebCore::FrameView::flushPostLayoutTasksQueue): * page/FrameView.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * platform/GenericTaskQueue.cpp: (WebCore::TaskDispatcher<Timer>::postTask): * platform/GenericTaskQueue.h: (WebCore::TaskDispatcher::postTask): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * style/StyleTreeResolver.cpp: (WebCore::Style::postResolutionCallbackQueue): (WebCore::Style::queuePostResolutionCallback): * style/StyleTreeResolver.h: Source/WebKit: * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): * Storage/StorageThread.h: Source/WebKit2: * NetworkProcess/NetworkProcess.cpp: (WebKit::fetchDiskCacheEntries): (WebKit::NetworkProcess::fetchWebsiteData): (WebKit::clearDiskCacheEntries): * NetworkProcess/NetworkProcess.h: * NetworkProcess/cache/NetworkCache.cpp: (WebKit::NetworkCache::Cache::traverse): * NetworkProcess/cache/NetworkCache.h: * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp: (WebKit::NetworkCache::runTaskInQueue): * NetworkProcess/cache/NetworkCacheStorage.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadTask.h: (WTF::CrossThreadTask::CrossThreadTask): * wtf/Function.h: Renamed from Source/WTF/wtf/NoncopyableFunction.h. * wtf/FunctionDispatcher.h: * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: * wtf/RunLoop.cpp: (WTF::RunLoop::performWork): (WTF::RunLoop::dispatch): * wtf/RunLoop.h: * wtf/WorkQueue.h: * wtf/cocoa/WorkQueueCocoa.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/efl/DispatchQueueWorkItemEfl.h: (WorkItem::WorkItem): (TimerWorkItem::create): (TimerWorkItem::TimerWorkItem): * wtf/efl/WorkQueueEfl.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/generic/RunLoopGeneric.cpp: (WTF::RunLoop::TimerBase::ScheduledTask::create): (WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask): (WTF::RunLoop::dispatchAfter): * wtf/generic/WorkQueueGeneric.cpp: (WorkQueue::dispatch): (WorkQueue::dispatchAfter): * wtf/glib/RunLoopGLib.cpp: (WTF::DispatchAfterContext::DispatchAfterContext): (WTF::RunLoop::dispatchAfter): * wtf/win/WorkItemWin.cpp: (WTF::WorkItemWin::WorkItemWin): (WTF::WorkItemWin::create): (WTF::HandleWorkItem::HandleWorkItem): (WTF::HandleWorkItem::createByAdoptingHandle): * wtf/win/WorkItemWin.h: (WTF::WorkItemWin::function): * wtf/win/WorkQueueWin.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): Canonical link: https://commits.webkit.org/177198@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202439 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-24 19:40:19 +00:00
Function(CallableType&& callable)
: m_callableWrapper(makeUnique<Detail::CallableWrapper<CallableType, Out, In...>>(std::forward<CallableType>(callable))) { }
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
template<typename FunctionType, class = typename std::enable_if<std::is_pointer<FunctionType>::value && std::is_function<typename std::remove_pointer<FunctionType>::type>::value>::type>
Function(FunctionType f)
: m_callableWrapper(makeUnique<Detail::CallableWrapper<FunctionType, Out, In...>>(std::forward<FunctionType>(f))) { }
Templatize NoncopyableFunction class similarly to std::function https://bugs.webkit.org/show_bug.cgi?id=158185 Reviewed by Darin Adler. Templatize NoncopyableFunction class similarly to std::function, so that it can be used as a std::function replacement in more places. Previously, NoncopyableFunction could only support "void()" lambdas. Source/WebCore: * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::perform): (WebCore::AsyncFileStream::getSize): (WebCore::AsyncFileStream::openForRead): (WebCore::AsyncFileStream::openForWrite): (WebCore::AsyncFileStream::write): * fileapi/AsyncFileStream.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): Source/WebKit: * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): * Storage/StorageThread.h: Source/WebKit2: * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp: (WebKit::NetworkCache::runTaskInQueue): Source/WTF: * wtf/FunctionDispatcher.h: * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: * wtf/NoncopyableFunction.h: * wtf/RunLoop.cpp: (WTF::RunLoop::performWork): (WTF::RunLoop::dispatch): * wtf/RunLoop.h: * wtf/WorkQueue.h: * wtf/cocoa/WorkQueueCocoa.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/efl/DispatchQueueWorkItemEfl.h: (WorkItem::WorkItem): (TimerWorkItem::create): (TimerWorkItem::TimerWorkItem): * wtf/efl/WorkQueueEfl.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/generic/RunLoopGeneric.cpp: (WTF::RunLoop::TimerBase::ScheduledTask::create): (WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask): (WTF::RunLoop::dispatchAfter): * wtf/generic/WorkQueueGeneric.cpp: (WorkQueue::dispatch): (WorkQueue::dispatchAfter): * wtf/glib/RunLoopGLib.cpp: (WTF::DispatchAfterContext::DispatchAfterContext): (WTF::RunLoop::dispatchAfter): * wtf/win/WorkItemWin.cpp: (WTF::WorkItemWin::WorkItemWin): (WTF::WorkItemWin::create): (WTF::HandleWorkItem::HandleWorkItem): (WTF::HandleWorkItem::createByAdoptingHandle): * wtf/win/WorkItemWin.h: (WTF::WorkItemWin::function): * wtf/win/WorkQueueWin.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): Canonical link: https://commits.webkit.org/176293@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201493 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-29 04:20:06 +00:00
Out operator()(In... in) const
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
{
WTF::Function does not allow for reference / non-default constructible return types https://bugs.webkit.org/show_bug.cgi?id=175244 Source/JavaScriptCore: Reviewed by Chris Dumez. * runtime/ArrayBuffer.cpp: (JSC::ArrayBufferContents::transferTo): Call reset(), rather than clear() to avoid the call to destroy() in clear(). The destroy call needed to be a no-op anyway, since the data is being moved. Source/WebCore: Reviewed by Chris Dumez. * bindings/js/JSCustomElementInterface.h: (WebCore::JSCustomElementInterface::invokeCallback): Update the default value for the addArguments parameter to be an empty lambda, rather than default initialization, which leads to a null WTF::Function. This allows us to remove support for calling null WTF::Function. No change in behavior. Source/WebKit: Reviewed by Chris Dumez. * UIProcess/WebResourceLoadStatisticsStore.h: Update the default value for the updateCookiePartitioningForDomainsHandler parameter to be an empty lambda, rather than default initialization, which leads to a null WTF::Function. This allows us to remove support for calling null WTF::Function. No change in behavior. Source/WTF: Reviewed by Chris Dumez. When Function, then NoncopyableFunction, was templatized to allow non-void return values in r201493, it maintained the behavior of being callable even if the Function was null. To accomplish this, when null, the default construction of the return parameter was used. This means Function can't be used with return types that are not default constructible, such as reference types and Ref. This behavior of returning something when null is surprising, as this is not how normal functions behave, and not very useful. Instead, we now assert that the function is not null when being called. * wtf/Function.h: (WTF::Function operator(...)): Instead of allowing a null callable wrapper by returning the default construction of the return type, assert that the wrapper is there when calling a Function. Tools: <rdar://problem/33801582> Reviewed by Chris Dumez. * TestWebKitAPI/Tests/WTF/Function.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/192188@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220601 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-11 16:56:37 +00:00
ASSERT(m_callableWrapper);
return m_callableWrapper->call(std::forward<In>(in)...);
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
}
explicit operator bool() const { return !!m_callableWrapper; }
template<typename CallableType, class = typename std::enable_if<!(std::is_pointer<CallableType>::value && std::is_function<typename std::remove_pointer<CallableType>::type>::value) && std::is_rvalue_reference<CallableType&&>::value>::type>
Rename NoncopyableFunction to Function https://bugs.webkit.org/show_bug.cgi?id=158354 Reviewed by Chris Dumez. Source/WebCore: * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/webaudio/AudioDestinationNode.h: (WebCore::AudioDestinationNode::resume): (WebCore::AudioDestinationNode::suspend): (WebCore::AudioDestinationNode::close): * Modules/webaudio/DefaultAudioDestinationNode.cpp: (WebCore::DefaultAudioDestinationNode::resume): (WebCore::DefaultAudioDestinationNode::suspend): (WebCore::DefaultAudioDestinationNode::close): * Modules/webaudio/DefaultAudioDestinationNode.h: * dom/ActiveDOMCallbackMicrotask.cpp: (WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask): * dom/ActiveDOMCallbackMicrotask.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::Task::Task): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * page/FrameView.cpp: (WebCore::FrameView::queuePostLayoutCallback): (WebCore::FrameView::flushPostLayoutTasksQueue): * page/FrameView.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * platform/GenericTaskQueue.cpp: (WebCore::TaskDispatcher<Timer>::postTask): * platform/GenericTaskQueue.h: (WebCore::TaskDispatcher::postTask): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * style/StyleTreeResolver.cpp: (WebCore::Style::postResolutionCallbackQueue): (WebCore::Style::queuePostResolutionCallback): * style/StyleTreeResolver.h: Source/WebKit: * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): * Storage/StorageThread.h: Source/WebKit2: * NetworkProcess/NetworkProcess.cpp: (WebKit::fetchDiskCacheEntries): (WebKit::NetworkProcess::fetchWebsiteData): (WebKit::clearDiskCacheEntries): * NetworkProcess/NetworkProcess.h: * NetworkProcess/cache/NetworkCache.cpp: (WebKit::NetworkCache::Cache::traverse): * NetworkProcess/cache/NetworkCache.h: * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp: (WebKit::NetworkCache::runTaskInQueue): * NetworkProcess/cache/NetworkCacheStorage.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadTask.h: (WTF::CrossThreadTask::CrossThreadTask): * wtf/Function.h: Renamed from Source/WTF/wtf/NoncopyableFunction.h. * wtf/FunctionDispatcher.h: * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: * wtf/RunLoop.cpp: (WTF::RunLoop::performWork): (WTF::RunLoop::dispatch): * wtf/RunLoop.h: * wtf/WorkQueue.h: * wtf/cocoa/WorkQueueCocoa.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/efl/DispatchQueueWorkItemEfl.h: (WorkItem::WorkItem): (TimerWorkItem::create): (TimerWorkItem::TimerWorkItem): * wtf/efl/WorkQueueEfl.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/generic/RunLoopGeneric.cpp: (WTF::RunLoop::TimerBase::ScheduledTask::create): (WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask): (WTF::RunLoop::dispatchAfter): * wtf/generic/WorkQueueGeneric.cpp: (WorkQueue::dispatch): (WorkQueue::dispatchAfter): * wtf/glib/RunLoopGLib.cpp: (WTF::DispatchAfterContext::DispatchAfterContext): (WTF::RunLoop::dispatchAfter): * wtf/win/WorkItemWin.cpp: (WTF::WorkItemWin::WorkItemWin): (WTF::WorkItemWin::create): (WTF::HandleWorkItem::HandleWorkItem): (WTF::HandleWorkItem::createByAdoptingHandle): * wtf/win/WorkItemWin.h: (WTF::WorkItemWin::function): * wtf/win/WorkQueueWin.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): Canonical link: https://commits.webkit.org/177198@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202439 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-24 19:40:19 +00:00
Function& operator=(CallableType&& callable)
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
{
m_callableWrapper = makeUnique<Detail::CallableWrapper<CallableType, Out, In...>>(std::forward<CallableType>(callable));
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
return *this;
}
template<typename FunctionType, class = typename std::enable_if<std::is_pointer<FunctionType>::value && std::is_function<typename std::remove_pointer<FunctionType>::type>::value>::type>
Function& operator=(FunctionType f)
{
m_callableWrapper = makeUnique<Detail::CallableWrapper<FunctionType, Out, In...>>(std::forward<FunctionType>(f));
return *this;
}
Rename NoncopyableFunction to Function https://bugs.webkit.org/show_bug.cgi?id=158354 Reviewed by Chris Dumez. Source/WebCore: * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/webaudio/AudioDestinationNode.h: (WebCore::AudioDestinationNode::resume): (WebCore::AudioDestinationNode::suspend): (WebCore::AudioDestinationNode::close): * Modules/webaudio/DefaultAudioDestinationNode.cpp: (WebCore::DefaultAudioDestinationNode::resume): (WebCore::DefaultAudioDestinationNode::suspend): (WebCore::DefaultAudioDestinationNode::close): * Modules/webaudio/DefaultAudioDestinationNode.h: * dom/ActiveDOMCallbackMicrotask.cpp: (WebCore::ActiveDOMCallbackMicrotask::ActiveDOMCallbackMicrotask): * dom/ActiveDOMCallbackMicrotask.h: * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::Task::Task): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * page/FrameView.cpp: (WebCore::FrameView::queuePostLayoutCallback): (WebCore::FrameView::flushPostLayoutTasksQueue): * page/FrameView.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * platform/GenericTaskQueue.cpp: (WebCore::TaskDispatcher<Timer>::postTask): * platform/GenericTaskQueue.h: (WebCore::TaskDispatcher::postTask): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * style/StyleTreeResolver.cpp: (WebCore::Style::postResolutionCallbackQueue): (WebCore::Style::queuePostResolutionCallback): * style/StyleTreeResolver.h: Source/WebKit: * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): * Storage/StorageThread.h: Source/WebKit2: * NetworkProcess/NetworkProcess.cpp: (WebKit::fetchDiskCacheEntries): (WebKit::NetworkProcess::fetchWebsiteData): (WebKit::clearDiskCacheEntries): * NetworkProcess/NetworkProcess.h: * NetworkProcess/cache/NetworkCache.cpp: (WebKit::NetworkCache::Cache::traverse): * NetworkProcess/cache/NetworkCache.h: * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp: (WebKit::NetworkCache::runTaskInQueue): * NetworkProcess/cache/NetworkCacheStorage.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/CrossThreadTask.h: (WTF::CrossThreadTask::CrossThreadTask): * wtf/Function.h: Renamed from Source/WTF/wtf/NoncopyableFunction.h. * wtf/FunctionDispatcher.h: * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: * wtf/RunLoop.cpp: (WTF::RunLoop::performWork): (WTF::RunLoop::dispatch): * wtf/RunLoop.h: * wtf/WorkQueue.h: * wtf/cocoa/WorkQueueCocoa.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/efl/DispatchQueueWorkItemEfl.h: (WorkItem::WorkItem): (TimerWorkItem::create): (TimerWorkItem::TimerWorkItem): * wtf/efl/WorkQueueEfl.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): * wtf/generic/RunLoopGeneric.cpp: (WTF::RunLoop::TimerBase::ScheduledTask::create): (WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask): (WTF::RunLoop::dispatchAfter): * wtf/generic/WorkQueueGeneric.cpp: (WorkQueue::dispatch): (WorkQueue::dispatchAfter): * wtf/glib/RunLoopGLib.cpp: (WTF::DispatchAfterContext::DispatchAfterContext): (WTF::RunLoop::dispatchAfter): * wtf/win/WorkItemWin.cpp: (WTF::WorkItemWin::WorkItemWin): (WTF::WorkItemWin::create): (WTF::HandleWorkItem::HandleWorkItem): (WTF::HandleWorkItem::createByAdoptingHandle): * wtf/win/WorkItemWin.h: (WTF::WorkItemWin::function): * wtf/win/WorkQueueWin.cpp: (WTF::WorkQueue::dispatch): (WTF::WorkQueue::dispatchAfter): Canonical link: https://commits.webkit.org/177198@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202439 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-24 19:40:19 +00:00
Function& operator=(std::nullptr_t)
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
{
m_callableWrapper = nullptr;
return *this;
}
Impl* leak()
{
return m_callableWrapper.release();
}
private:
enum AdoptTag { Adopt };
Function(Impl* impl, AdoptTag)
: m_callableWrapper(impl)
{
}
friend Function adopt<Out, In...>(Impl*);
std::unique_ptr<Impl> m_callableWrapper;
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
};
template<typename Out, typename... In> Function<Out(In...)> adopt(Detail::CallableWrapperBase<Out, In...>* impl)
{
return Function<Out(In...)>(impl, Function<Out(In...)>::Adopt);
}
callOnMainThread() should not copy captured lambda variables https://bugs.webkit.org/show_bug.cgi?id=158166 Reviewed by Brady Eidson. Source/WebCore: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Modules/indexeddb/IDBTransaction.cpp: (WebCore::IDBTransaction::putOrAddOnServer): * Modules/mediastream/MediaDevicesRequest.cpp: (WebCore::MediaDevicesRequest::didCompletePermissionCheck): (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest): * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::MediaEndpointPeerConnection::runTask): * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::constraintsValidated): (WebCore::UserMediaRequest::userMediaAccessGranted): * Modules/webaudio/AudioContext.cpp: (WebCore::AudioContext::scheduleNodeDeletion): (WebCore::AudioContext::isPlayingAudioDidChange): * dom/Document.cpp: (WebCore::Document::postTask): (WebCore::Document::pendingTasksTimerFired): Deleted. * dom/ScriptElement.cpp: (WebCore::ScriptElement::requestScript): * fileapi/AsyncFileStream.cpp: (WebCore::callOnFileThread): (WebCore::AsyncFileStream::~AsyncFileStream): (WebCore::AsyncFileStream::perform): * fileapi/AsyncFileStream.h: * fileapi/ThreadableBlobRegistry.cpp: (WebCore::ThreadableBlobRegistry::registerFileBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLForSlice): (WebCore::ThreadableBlobRegistry::blobSize): (WebCore::ThreadableBlobRegistry::unregisterBlobURL): (WebCore::ThreadableBlobRegistry::registerBlobURLOptionallyFileBacked): Deleted. * loader/icon/IconDatabase.cpp: (WebCore::IconDatabase::dispatchDidImportIconURLForPageURLOnMainThread): (WebCore::IconDatabase::dispatchDidImportIconDataForPageURLOnMainThread): * page/ResourceUsageThread.cpp: (WebCore::ResourceUsageThread::notifyObservers): (WebCore::ResourceUsageThread::threadBody): * page/ResourceUsageThread.h: * page/scrolling/ScrollingThread.cpp: (WebCore::ScrollingThread::dispatch): (WebCore::ScrollingThread::dispatchBarrier): (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread): * page/scrolling/ScrollingThread.h: * page/scrolling/ios/ScrollingTreeIOS.cpp: (WebCore::ScrollingTreeIOS::invalidate): (WebCore::ScrollingTreeIOS::scrollingTreeNodeDidScroll): (WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): (WebCore::ScrollingTreeIOS::createScrollingTreeNode): Deleted. * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm: (WebCore::ScrollingTreeFrameScrollingNodeMac::releaseReferencesToScrollerImpsOnTheMainThread): * platform/MemoryPressureHandler.cpp: (WebCore::MemoryPressureHandler::releaseMemory): * platform/audio/ios/MediaSessionManagerIOS.mm: (-[WebMediaSessionHelper dealloc]): (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm: (WebCore::AudioSourceProviderAVFObjC::prepare): * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification): (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification): * platform/graphics/avfoundation/objc/CDMSessionAVFoundationObjC.mm: (-[WebCDMSessionAVFoundationObjCListener observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm: (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer): (-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]): (-[WebCoreAVFMovieObserver outputSequenceWasFlushed:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]): (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForResponseToAuthenticationChallenge:]): (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: (WebCore::CMTimebaseEffectiveRateChangedCallback): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play): (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause): * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm: (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask): * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParser:didReachEndOfTrackWithTrackID:mediaType:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]): (-[WebAVSampleBufferErrorListener layerFailedToDecode:]): * platform/graphics/cg/GraphicsContextCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/cg/PatternCG.cpp: (WebCore::patternReleaseCallback): * platform/graphics/win/MediaPlayerPrivateMediaFoundation.cpp: (WebCore::MediaPlayerPrivateMediaFoundation::endCreatedMediaSource): (WebCore::MediaPlayerPrivateMediaFoundation::endGetEvent): (WebCore::MediaPlayerPrivateMediaFoundation::CustomVideoPresenter::processInputNotify): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::scheduleDeferredTask): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/mac/AVMediaCaptureSource.h: * platform/mediastream/mac/AVMediaCaptureSource.mm: (WebCore::AVMediaCaptureSource::scheduleDeferredTask): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::getMediaStreamTrackSources): * platform/mediastream/mac/WebAudioSourceProviderAVFObjC.mm: (WebCore::WebAudioSourceProviderAVFObjC::prepare): * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources): * platform/network/BlobResourceHandle.cpp: (WebCore::BlobResourceHandle::start): (WebCore::BlobResourceHandle::notifyFinish): * platform/network/DataURLDecoder.cpp: (WebCore::DataURLDecoder::decode): * platform/network/DataURLDecoder.h: * platform/network/cocoa/WebCoreNSURLSession.mm: (-[WebCoreNSURLSession dealloc]): (-[WebCoreNSURLSessionDataTask cancel]): (-[WebCoreNSURLSessionDataTask suspend]): (-[WebCoreNSURLSessionDataTask resume]): * platform/network/curl/CurlDownload.cpp: (WebCore::CurlDownload::didReceiveHeader): (WebCore::CurlDownload::didReceiveData): Deleted. Source/WebKit: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/StorageAreaSync.cpp: (WebCore::StorageAreaSync::deleteEmptyDatabase): * Storage/StorageSyncManager.cpp: (WebCore::StorageSyncManager::dispatch): * Storage/StorageSyncManager.h: * Storage/StorageThread.cpp: (WebCore::StorageThread::dispatch): (WebCore::StorageThread::terminate): (WebCore::StorageThread::releaseFastMallocFreeMemoryInAllThreads): * Storage/StorageThread.h: * Storage/StorageTracker.cpp: (WebCore::StorageTracker::syncFileSystemAndTrackerDatabase): (WebCore::StorageTracker::setOriginDetails): Source/WebKit/mac: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * Storage/WebDatabaseManagerClient.mm: (DidModifyOriginData::dispatchToMainThread): (DidModifyOriginData::DidModifyOriginData): Deleted. * Storage/WebStorageTrackerClient.mm: (WebStorageTrackerClient::dispatchDidModifyOrigin): Source/WTF: callOnMainThread() should not copy captured lambda variables. This function is usually called cross-thread with a lambda and copying the lambda (and its captured variables) can lead to thread-safety issues. This patch updates callOnMainThread() to take a NoncopyableFunction&& in parameter instead of a std::function. The call sites of callOnMainThread() have also been updated to use C++14's lambda capture with initializer. * WTF.xcodeproj/project.pbxproj: * wtf/FunctionDispatcher.h: * wtf/NoncopyableFunction.h: - Moved NoncopyableFunction from FunctionDispatcher.h to NoncopyableFunction.h. - Add a new operator=(nullptr_t) operator to NoncopyableFunction to match std::function, as one of the call sites needed it. * wtf/MainThread.cpp: (WTF::functionQueue): (WTF::dispatchFunctionsFromMainThread): (WTF::callOnMainThread): * wtf/MainThread.h: Canonical link: https://commits.webkit.org/176282@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-28 05:51:42 +00:00
} // namespace WTF