Title: [274174] trunk
Revision
274174
Author
[email protected]
Date
2021-03-09 14:07:00 -0800 (Tue, 09 Mar 2021)

Log Message

Stop using callOnMainThread() / isMainThread() in WebKit2
https://bugs.webkit.org/show_bug.cgi?id=222986

Reviewed by Alex Christensen.

Source/WebKit:

Use callOnMainRunLoop() / callOnMainRunLoopAndWait() / isMainRunLoop() in WebKit2
instead of callOnMainThread() / callOnMainThreadAndWait() / isMainThread().
Using the "MainThread" variants doesn't do the right thing in the UIProcess when
an iOS app is using both WK1 (with WebThread) and WK2.

* GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::copyTextureFromMedia):
* GPUProcess/media/RemoteAudioDestinationManager.cpp:
(WebKit::RemoteAudioDestination::render):
* GPUProcess/media/RemoteMediaResource.cpp:
(WebKit::RemoteMediaResource::~RemoteMediaResource):
(WebKit::RemoteMediaResource::responseReceived):
* GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.cpp:
(WebKit::RemoteSampleBufferDisplayLayerManager::close):
(WebKit::RemoteSampleBufferDisplayLayerManager::createLayer):
(WebKit::RemoteSampleBufferDisplayLayerManager::releaseLayer):
* NetworkProcess/Downloads/Download.cpp:
(WebKit::Download::cancel):
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::storageQuotaManager):
* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::getDirectorySize):
(WebKit::CacheStorage::Engine::diskUsage):
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::resume):
* NetworkProcess/webrtc/NetworkRTCMonitor.cpp:
(WebKit::NetworkManagerWrapper::onNetworksChanged):
* NetworkProcess/webrtc/NetworkRTCProvider.cpp:
(WebKit::NetworkRTCProvider::createServerTCPSocket):
(WebKit::NetworkRTCProvider::createClientTCPSocket):
(WebKit::NetworkRTCProvider::createResolver):
(WebKit::NetworkRTCProvider::stopResolver):
(WebKit::NetworkRTCProvider::closeListeningSockets):
* Platform/IPC/Connection.cpp:
(IPC::Connection::sendMessage):
(IPC::Connection::dispatchMessage):
* Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm:
(WebKit::AuthenticationManager::initializeConnection):
* Shared/mac/MediaFormatReader/MediaFormatReader.cpp:
(WebKit::MediaFormatReader::startOnMainThread):
(WebKit::MediaFormatReader::parseByteSource):
(WebKit::MediaFormatReader::didParseTracks):
(WebKit::MediaFormatReader::didProvideMediaData):
(WebKit::MediaFormatReader::finishParsing):
* Shared/mac/MediaFormatReader/MediaSampleByteRange.cpp:
(WebKit::MediaSampleByteRange::MediaSampleByteRange):
* Shared/mac/MediaFormatReader/MediaTrackReader.cpp:
(WebKit::MediaTrackReader::MediaTrackReader):
(WebKit::MediaTrackReader::addSample):
(WebKit::MediaTrackReader::finishParsing):
* Shared/mac/MediaFormatReader/MediaTrackReader.h:
* UIProcess/API/glib/IconDatabase.cpp:
(WebKit::IconDatabase::IconDatabase):
(WebKit::IconDatabase::~IconDatabase):
(WebKit::IconDatabase::createTablesIfNeeded):
(WebKit::IconDatabase::populatePageURLToIconURLMap):
(WebKit::IconDatabase::clearStatements):
(WebKit::IconDatabase::pruneTimerFired):
(WebKit::IconDatabase::startPruneTimer):
(WebKit::IconDatabase::clearLoadedIconsTimerFired):
(WebKit::IconDatabase::startClearLoadedIconsTimer):
(WebKit::IconDatabase::iconIDForIconURL):
(WebKit::IconDatabase::setIconIDForPageURL):
(WebKit::IconDatabase::iconData):
(WebKit::IconDatabase::addIcon):
(WebKit::IconDatabase::updateIconTimestamp):
(WebKit::IconDatabase::deleteIcon):
(WebKit::IconDatabase::checkIconURLAndSetPageURLIfNeeded):
(WebKit::IconDatabase::loadIconForPageURL):
(WebKit::IconDatabase::iconURLForPageURL):
(WebKit::IconDatabase::setIconForPageURL):
(WebKit::IconDatabase::clear):
* UIProcess/Cocoa/MediaPermissionUtilities.mm:
(WebKit::requestAVCaptureAccessForType):
(WebKit::requestSpeechRecognitionAccess):
* UIProcess/Cocoa/PreferenceObserver.mm:
(-[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::nonBrowserServices):
(WebKit::agxCompilerClasses):
(WebKit::agxCompilerServices):
(WebKit::diagnosticServices):
* UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
(WebKit::RemoteInspectorClient::sendWebInspectorEvent):
(WebKit::RemoteInspectorClient::didClose):
* UIProcess/WebFramePolicyListenerProxy.cpp:
(WebKit::WebFramePolicyListenerProxy::didReceiveSafeBrowsingResults):
* UIProcess/WebPageProxy.cpp:
(WebKit::gpuIOKitClasses):
(WebKit::gpuMachServices):
(WebKit::mediaRelatedMachServices):
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView web_setContentProviderData:suggestedFilename:]):
* UIProcess/mac/WKPrintingView.mm:
(-[WKPrintingView dealloc]):
* WebProcess/Cache/WebCacheStorageConnection.cpp:
(WebKit::WebCacheStorageConnection::~WebCacheStorageConnection):
* WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
(WebKit::RemoteImageBufferProxy::waitForDidFlushOnSecondaryThread):
* WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::load):
* WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp:
(WebKit::RemoteAudioDestinationProxy::renderQuantum):
* WebProcess/GPU/media/RemoteAudioSourceProvider.cpp:
(WebKit::RemoteAudioSourceProvider::RemoteAudioSourceProvider):
(WebKit::RemoteAudioSourceProvider::close):
* WebProcess/GPU/media/RemoteImageDecoderAVF.cpp:
(WebKit::RemoteImageDecoderAVF::createFrameImageAtIndex):
* WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp:
(WebKit::LibWebRTCCodecs::setCallbacks):
(WebKit::LibWebRTCCodecs::failedDecoding):
(WebKit::LibWebRTCCodecs::completedDecoding):
(WebKit::LibWebRTCCodecs::completedEncoding):
* WebProcess/Network/webrtc/LibWebRTCResolver.cpp:
(WebKit::LibWebRTCResolver::sendOnMainThread):
* WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:
(WebKit::LibWebRTCSocketFactory::createServerTcpSocket):
(WebKit::LibWebRTCSocketFactory::createUdpSocket):
(WebKit::LibWebRTCSocketFactory::createClientTcpSocket):
* WebProcess/Network/webrtc/WebRTCMonitor.cpp:
(WebKit::WebRTCMonitor::sendOnMainThread):
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(WebKit::PDFPlugin::pdfLog):
(WebKit::PDFPlugin::logStreamLoader):
(WebKit::PDFPlugin::verboseLog):
(WebKit::PDFPlugin::receivedNonLinearizedPDFSentinel):
(WebKit::dataProviderGetBytesAtPositionCallback):
(WebKit::dataProviderGetByteRangesCallback):
(WebKit::dataProviderReleaseInfoCallback):
(WebKit::PDFPlugin::threadEntry):
(WebKit::PDFPlugin::getResourceBytesAtPositionMainThread):
(WebKit::PDFPlugin::getResourceBytesAtPosition):
(WebKit::PDFPlugin::adoptBackgroundThreadDocument):
(WebKit::PDFPlugin::installPDFDocument):
(WebKit::PDFPlugin::tryRunScriptsInPDFDocument):
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::didMatchRegistration):
(WebKit::WebSWClientConnection::didGetRegistrations):
(WebKit::WebSWClientConnection::matchRegistration):
(WebKit::WebSWClientConnection::getRegistrations):
* WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:
(WebKit::WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish):
(WebKit::WebServiceWorkerFetchTaskClient::cleanup):
* WebProcess/WebPage/FindController.cpp:
(WebKit::FindController::drawRect):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::elementDidBlur):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::handleSyntheticClick):
(WebKit::WebPage::didFinishContentChangeObserving):
(WebKit::WebPage::updateInputContextAfterBlurringAndRefocusingElementIfNeeded):
* WebProcess/WebPage/mac/DrawingAreaMac.cpp:
(WebKit::DisplayRefreshMonitorMac::displayLinkFired):
* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm:
(-[WKAccessibilityWebPageObjectBase axObjectCache]):
(-[WKAccessibilityWebPageObjectBase accessibilityPluginObject]):
(-[WKAccessibilityWebPageObjectBase setWebPage:]):
(-[WKAccessibilityWebPageObjectBase setHasMainFramePlugin:]):
(-[WKAccessibilityWebPageObjectBase setRemoteParent:]):
* WebProcess/cocoa/RemoteRealtimeAudioSource.cpp:
(WebKit::RemoteRealtimeAudioSource::remoteAudioSamplesAvailable):
* WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp:
(WebKit::RemoteRealtimeMediaSourceProxy::connection):

Source/WTF:

* wtf/MainThread.h:

Tools:

Add corresponding style checker rules.

* Scripts/webkitpy/style/checkers/cpp.py:
(check_no_callonmainthread):
(check_no_ismainthread):
(check_style):
(CppChecker):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (274173 => 274174)


--- trunk/Source/WTF/ChangeLog	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WTF/ChangeLog	2021-03-09 22:07:00 UTC (rev 274174)
@@ -1,3 +1,12 @@
+2021-03-09  Chris Dumez  <[email protected]>
+
+        Stop using callOnMainThread() / isMainThread() in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=222986
+
+        Reviewed by Alex Christensen.
+
+        * wtf/MainThread.h:
+
 2021-03-09  Said Abou-Hallawa  <[email protected]>
 
         [GPUP] Enable 2D Canvas in layout tests by default

Modified: trunk/Source/WTF/wtf/MainThread.h (274173 => 274174)


--- trunk/Source/WTF/wtf/MainThread.h	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WTF/wtf/MainThread.h	2021-03-09 22:07:00 UTC (rev 274174)
@@ -80,6 +80,7 @@
 using WTF::callOnMainRunLoop;
 using WTF::callOnMainRunLoopAndWait;
 using WTF::canCurrentThreadAccessThreadLocalData;
+using WTF::isMainRunLoop;
 using WTF::isMainThread;
 using WTF::isMainThreadOrGCThread;
 using WTF::isUIThread;

Modified: trunk/Source/WebKit/ChangeLog (274173 => 274174)


--- trunk/Source/WebKit/ChangeLog	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/ChangeLog	2021-03-09 22:07:00 UTC (rev 274174)
@@ -1,5 +1,176 @@
 2021-03-09  Chris Dumez  <[email protected]>
 
+        Stop using callOnMainThread() / isMainThread() in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=222986
+
+        Reviewed by Alex Christensen.
+
+        Use callOnMainRunLoop() / callOnMainRunLoopAndWait() / isMainRunLoop() in WebKit2
+        instead of callOnMainThread() / callOnMainThreadAndWait() / isMainThread().
+        Using the "MainThread" variants doesn't do the right thing in the UIProcess when
+        an iOS app is using both WK1 (with WebThread) and WK2.
+
+        * GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
+        (WebKit::RemoteGraphicsContextGL::copyTextureFromMedia):
+        * GPUProcess/media/RemoteAudioDestinationManager.cpp:
+        (WebKit::RemoteAudioDestination::render):
+        * GPUProcess/media/RemoteMediaResource.cpp:
+        (WebKit::RemoteMediaResource::~RemoteMediaResource):
+        (WebKit::RemoteMediaResource::responseReceived):
+        * GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.cpp:
+        (WebKit::RemoteSampleBufferDisplayLayerManager::close):
+        (WebKit::RemoteSampleBufferDisplayLayerManager::createLayer):
+        (WebKit::RemoteSampleBufferDisplayLayerManager::releaseLayer):
+        * NetworkProcess/Downloads/Download.cpp:
+        (WebKit::Download::cancel):
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::storageQuotaManager):
+        * NetworkProcess/cache/CacheStorageEngine.cpp:
+        (WebKit::CacheStorage::getDirectorySize):
+        (WebKit::CacheStorage::Engine::diskUsage):
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::NetworkDataTaskCocoa::resume):
+        * NetworkProcess/webrtc/NetworkRTCMonitor.cpp:
+        (WebKit::NetworkManagerWrapper::onNetworksChanged):
+        * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
+        (WebKit::NetworkRTCProvider::createServerTCPSocket):
+        (WebKit::NetworkRTCProvider::createClientTCPSocket):
+        (WebKit::NetworkRTCProvider::createResolver):
+        (WebKit::NetworkRTCProvider::stopResolver):
+        (WebKit::NetworkRTCProvider::closeListeningSockets):
+        * Platform/IPC/Connection.cpp:
+        (IPC::Connection::sendMessage):
+        (IPC::Connection::dispatchMessage):
+        * Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm:
+        (WebKit::AuthenticationManager::initializeConnection):
+        * Shared/mac/MediaFormatReader/MediaFormatReader.cpp:
+        (WebKit::MediaFormatReader::startOnMainThread):
+        (WebKit::MediaFormatReader::parseByteSource):
+        (WebKit::MediaFormatReader::didParseTracks):
+        (WebKit::MediaFormatReader::didProvideMediaData):
+        (WebKit::MediaFormatReader::finishParsing):
+        * Shared/mac/MediaFormatReader/MediaSampleByteRange.cpp:
+        (WebKit::MediaSampleByteRange::MediaSampleByteRange):
+        * Shared/mac/MediaFormatReader/MediaTrackReader.cpp:
+        (WebKit::MediaTrackReader::MediaTrackReader):
+        (WebKit::MediaTrackReader::addSample):
+        (WebKit::MediaTrackReader::finishParsing):
+        * Shared/mac/MediaFormatReader/MediaTrackReader.h:
+        * UIProcess/API/glib/IconDatabase.cpp:
+        (WebKit::IconDatabase::IconDatabase):
+        (WebKit::IconDatabase::~IconDatabase):
+        (WebKit::IconDatabase::createTablesIfNeeded):
+        (WebKit::IconDatabase::populatePageURLToIconURLMap):
+        (WebKit::IconDatabase::clearStatements):
+        (WebKit::IconDatabase::pruneTimerFired):
+        (WebKit::IconDatabase::startPruneTimer):
+        (WebKit::IconDatabase::clearLoadedIconsTimerFired):
+        (WebKit::IconDatabase::startClearLoadedIconsTimer):
+        (WebKit::IconDatabase::iconIDForIconURL):
+        (WebKit::IconDatabase::setIconIDForPageURL):
+        (WebKit::IconDatabase::iconData):
+        (WebKit::IconDatabase::addIcon):
+        (WebKit::IconDatabase::updateIconTimestamp):
+        (WebKit::IconDatabase::deleteIcon):
+        (WebKit::IconDatabase::checkIconURLAndSetPageURLIfNeeded):
+        (WebKit::IconDatabase::loadIconForPageURL):
+        (WebKit::IconDatabase::iconURLForPageURL):
+        (WebKit::IconDatabase::setIconForPageURL):
+        (WebKit::IconDatabase::clear):
+        * UIProcess/Cocoa/MediaPermissionUtilities.mm:
+        (WebKit::requestAVCaptureAccessForType):
+        (WebKit::requestSpeechRecognitionAccess):
+        * UIProcess/Cocoa/PreferenceObserver.mm:
+        (-[WKUserDefaults _notifyObserversOfChangeFromValuesForKeys:toValuesForKeys:]):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::nonBrowserServices):
+        (WebKit::agxCompilerClasses):
+        (WebKit::agxCompilerServices):
+        (WebKit::diagnosticServices):
+        * UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
+        (WebKit::RemoteInspectorClient::sendWebInspectorEvent):
+        (WebKit::RemoteInspectorClient::didClose):
+        * UIProcess/WebFramePolicyListenerProxy.cpp:
+        (WebKit::WebFramePolicyListenerProxy::didReceiveSafeBrowsingResults):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::gpuIOKitClasses):
+        (WebKit::gpuMachServices):
+        (WebKit::mediaRelatedMachServices):
+        * UIProcess/ios/WKPDFView.mm:
+        (-[WKPDFView web_setContentProviderData:suggestedFilename:]):
+        * UIProcess/mac/WKPrintingView.mm:
+        (-[WKPrintingView dealloc]):
+        * WebProcess/Cache/WebCacheStorageConnection.cpp:
+        (WebKit::WebCacheStorageConnection::~WebCacheStorageConnection):
+        * WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
+        (WebKit::RemoteImageBufferProxy::waitForDidFlushOnSecondaryThread):
+        * WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
+        (WebKit::MediaPlayerPrivateRemote::load):
+        * WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp:
+        (WebKit::RemoteAudioDestinationProxy::renderQuantum):
+        * WebProcess/GPU/media/RemoteAudioSourceProvider.cpp:
+        (WebKit::RemoteAudioSourceProvider::RemoteAudioSourceProvider):
+        (WebKit::RemoteAudioSourceProvider::close):
+        * WebProcess/GPU/media/RemoteImageDecoderAVF.cpp:
+        (WebKit::RemoteImageDecoderAVF::createFrameImageAtIndex):
+        * WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp:
+        (WebKit::LibWebRTCCodecs::setCallbacks):
+        (WebKit::LibWebRTCCodecs::failedDecoding):
+        (WebKit::LibWebRTCCodecs::completedDecoding):
+        (WebKit::LibWebRTCCodecs::completedEncoding):
+        * WebProcess/Network/webrtc/LibWebRTCResolver.cpp:
+        (WebKit::LibWebRTCResolver::sendOnMainThread):
+        * WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:
+        (WebKit::LibWebRTCSocketFactory::createServerTcpSocket):
+        (WebKit::LibWebRTCSocketFactory::createUdpSocket):
+        (WebKit::LibWebRTCSocketFactory::createClientTcpSocket):
+        * WebProcess/Network/webrtc/WebRTCMonitor.cpp:
+        (WebKit::WebRTCMonitor::sendOnMainThread):
+        * WebProcess/Plugins/PDF/PDFPlugin.mm:
+        (WebKit::PDFPlugin::pdfLog):
+        (WebKit::PDFPlugin::logStreamLoader):
+        (WebKit::PDFPlugin::verboseLog):
+        (WebKit::PDFPlugin::receivedNonLinearizedPDFSentinel):
+        (WebKit::dataProviderGetBytesAtPositionCallback):
+        (WebKit::dataProviderGetByteRangesCallback):
+        (WebKit::dataProviderReleaseInfoCallback):
+        (WebKit::PDFPlugin::threadEntry):
+        (WebKit::PDFPlugin::getResourceBytesAtPositionMainThread):
+        (WebKit::PDFPlugin::getResourceBytesAtPosition):
+        (WebKit::PDFPlugin::adoptBackgroundThreadDocument):
+        (WebKit::PDFPlugin::installPDFDocument):
+        (WebKit::PDFPlugin::tryRunScriptsInPDFDocument):
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::didMatchRegistration):
+        (WebKit::WebSWClientConnection::didGetRegistrations):
+        (WebKit::WebSWClientConnection::matchRegistration):
+        (WebKit::WebSWClientConnection::getRegistrations):
+        * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:
+        (WebKit::WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish):
+        (WebKit::WebServiceWorkerFetchTaskClient::cleanup):
+        * WebProcess/WebPage/FindController.cpp:
+        (WebKit::FindController::drawRect):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::elementDidBlur):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::handleSyntheticClick):
+        (WebKit::WebPage::didFinishContentChangeObserving):
+        (WebKit::WebPage::updateInputContextAfterBlurringAndRefocusingElementIfNeeded):
+        * WebProcess/WebPage/mac/DrawingAreaMac.cpp:
+        (WebKit::DisplayRefreshMonitorMac::displayLinkFired):
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm:
+        (-[WKAccessibilityWebPageObjectBase axObjectCache]):
+        (-[WKAccessibilityWebPageObjectBase accessibilityPluginObject]):
+        (-[WKAccessibilityWebPageObjectBase setWebPage:]):
+        (-[WKAccessibilityWebPageObjectBase setHasMainFramePlugin:]):
+        (-[WKAccessibilityWebPageObjectBase setRemoteParent:]):
+        * WebProcess/cocoa/RemoteRealtimeAudioSource.cpp:
+        (WebKit::RemoteRealtimeAudioSource::remoteAudioSamplesAvailable):
+        * WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp:
+        (WebKit::RemoteRealtimeMediaSourceProxy::connection):
+
+2021-03-09  Chris Dumez  <[email protected]>
+
         [IPC Hardening] Protect against bad input in WebProcessProxy::createSpeechRecognitionServer() and MessageReceiverMap
         https://bugs.webkit.org/show_bug.cgi?id=222948
         <rdar://problem/75191472>

Modified: trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp (274173 => 274174)


--- trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -231,10 +231,10 @@
             pixelBuffer = mediaPlayer->pixelBufferForCurrentTime();
     };
 
-    if (isMainThread())
+    if (isMainRunLoop())
         getPixelBuffer();
     else
-        callOnMainThreadAndWait(WTFMove(getPixelBuffer));
+        callOnMainRunLoopAndWait(WTFMove(getPixelBuffer));
 
     if (!pixelBuffer) {
         completionHandler(false);

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.cpp (274173 => 274174)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioDestinationManager.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -116,7 +116,7 @@
 #if PLATFORM(COCOA)
     OSStatus render(double sampleTime, uint64_t hostTime, UInt32 numberOfFrames, AudioBufferList* ioData)
     {
-        ASSERT(!isMainThread());
+        ASSERT(!isMainRunLoop());
 
         OSStatus status = -1;
 

Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaResource.cpp (274173 => 274174)


--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaResource.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaResource.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -50,7 +50,7 @@
 
 RemoteMediaResource::~RemoteMediaResource()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     stop();
     if (!m_remoteMediaResourceManager)
         return;
@@ -76,7 +76,7 @@
 
     m_didPassAccessControlCheck = didPassAccessControlCheck;
     m_client->responseReceived(*this, response, [protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](auto shouldContinue) mutable {
-        ASSERT(isMainThread());
+        ASSERT(isMainRunLoop());
         if (shouldContinue == ShouldContinuePolicyCheck::No)
             protectedThis->stop();
 

Modified: trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.cpp (274173 => 274174)


--- trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/GPUProcess/webrtc/RemoteSampleBufferDisplayLayerManager.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -58,7 +58,7 @@
     m_connectionToWebProcess.connection().removeThreadMessageReceiver(Messages::RemoteSampleBufferDisplayLayer::messageReceiverName());
     m_connectionToWebProcess.connection().removeThreadMessageReceiver(Messages::RemoteSampleBufferDisplayLayerManager::messageReceiverName());
     dispatchToThread([this, protectedThis = makeRef(*this)] {
-        callOnMainThread([layers = WTFMove(m_layers)] { });
+        callOnMainRunLoop([layers = WTFMove(m_layers)] { });
     });
 }
 
@@ -80,11 +80,11 @@
 
 void RemoteSampleBufferDisplayLayerManager::createLayer(SampleBufferDisplayLayerIdentifier identifier, bool hideRootLayer, WebCore::IntSize size, LayerCreationCallback&& callback)
 {
-    callOnMainThread([this, protectedThis = makeRef(*this), identifier, hideRootLayer, size, callback = WTFMove(callback)]() mutable {
+    callOnMainRunLoop([this, protectedThis = makeRef(*this), identifier, hideRootLayer, size, callback = WTFMove(callback)]() mutable {
         auto layer = RemoteSampleBufferDisplayLayer::create(identifier, m_connection.copyRef());
         auto& layerReference = *layer;
         layerReference.initialize(hideRootLayer, size, [this, protectedThis = makeRef(*this), callback = WTFMove(callback), identifier, layer = WTFMove(layer)](auto layerId) mutable {
-            dispatchToThread([this, protectedThis = WTFMove(protectedThis), callback = WTFMove(callback), identifier, layer = WTFMove(layer), layerId = WTFMove(layerId)]() mutable {
+            callOnMainRunLoop([this, protectedThis = WTFMove(protectedThis), callback = WTFMove(callback), identifier, layer = WTFMove(layer), layerId = WTFMove(layerId)]() mutable {
                 ASSERT(!m_layers.contains(identifier));
                 m_layers.add(identifier, WTFMove(layer));
                 callback(WTFMove(layerId));
@@ -95,10 +95,10 @@
 
 void RemoteSampleBufferDisplayLayerManager::releaseLayer(SampleBufferDisplayLayerIdentifier identifier)
 {
-    callOnMainThread([this, protectedThis = makeRef(*this), identifier]() mutable {
+    callOnMainRunLoop([this, protectedThis = makeRef(*this), identifier]() mutable {
         dispatchToThread([this, protectedThis = WTFMove(protectedThis), identifier] {
             ASSERT(m_layers.contains(identifier));
-            callOnMainThread([layer = m_layers.take(identifier)] { });
+            callOnMainRunLoop([layer = m_layers.take(identifier)] { });
         });
     });
 }

Modified: trunk/Source/WebKit/NetworkProcess/Downloads/Download.cpp (274173 => 274174)


--- trunk/Source/WebKit/NetworkProcess/Downloads/Download.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/NetworkProcess/Downloads/Download.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -87,7 +87,7 @@
 
 void Download::cancel(CompletionHandler<void(const IPC::DataReference&)>&& completionHandler, IgnoreDidFailCallback ignoreDidFailCallback)
 {
-    RELEASE_ASSERT(isMainThread());
+    RELEASE_ASSERT(isMainRunLoop());
 
     // URLSession:task:didCompleteWithError: is still called after cancelByProducingResumeData's completionHandler.
     // If this cancel request came from the API, we do not want to send DownloadProxy::DidFail because the

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (274173 => 274174)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -2510,7 +2510,7 @@
     idbRootPath = sessionStorageQuotaManager->idbRootPath();
 #endif
     StorageQuotaManager::UsageGetter usageGetter = [cacheRootPath = sessionStorageQuotaManager->cacheRootPath().isolatedCopy(), idbRootPath = idbRootPath.isolatedCopy(), origin = origin.isolatedCopy()]() {
-        ASSERT(!isMainThread());    
+        ASSERT(!isMainRunLoop());
 
         uint64_t usage = CacheStorage::Engine::diskUsage(cacheRootPath, origin);
 #if ENABLE(INDEXED_DATABASE)
@@ -2520,7 +2520,7 @@
         return usage;
     };
     StorageQuotaManager::QuotaIncreaseRequester quotaIncreaseRequester = [this, weakThis = makeWeakPtr(*this), sessionID, origin] (uint64_t currentQuota, uint64_t currentSpace, uint64_t requestedIncrease, auto&& callback) {
-        ASSERT(isMainThread());
+        ASSERT(isMainRunLoop());
         if (!weakThis)
             callback({ });
         requestStorageSpace(sessionID, origin, currentQuota, currentSpace, requestedIncrease, WTFMove(callback));

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (274173 => 274174)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -199,7 +199,7 @@
 
 static uint64_t getDirectorySize(const String& directoryPath)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     uint64_t directorySize = 0;
     Deque<String> paths;
@@ -227,7 +227,7 @@
 
 uint64_t Engine::diskUsage(const String& rootPath, const WebCore::ClientOrigin& origin)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     if (rootPath.isEmpty())
         return 0;

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (274173 => 274174)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2021-03-09 22:07:00 UTC (rev 274174)
@@ -623,7 +623,7 @@
     auto& cocoaSession = static_cast<NetworkSessionCocoa&>(*m_session);
     if (cocoaSession.deviceManagementRestrictionsEnabled() && m_isForMainResourceNavigationForAnyFrame) {
         auto didDetermineDeviceRestrictionPolicyForURL = makeBlockPtr([this, protectedThis = makeRef(*this)](BOOL isBlocked) mutable {
-            callOnMainThread([this, protectedThis = WTFMove(protectedThis), isBlocked] {
+            callOnMainRunLoop([this, protectedThis = WTFMove(protectedThis), isBlocked] {
                 if (isBlocked) {
                     scheduleFailure(RestrictedURLFailure);
                     return;

Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCMonitor.cpp (274173 => 274174)


--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCMonitor.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCMonitor.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -115,7 +115,7 @@
     RTCNetwork::IPAddress ipv6;
     m_manager->GetDefaultLocalAddress(AF_INET6, &ipv6.value);
 
-    callOnMainThread([this, networkList = WTFMove(networkList), ipv4 = WTFMove(ipv4), ipv6 = WTFMove(ipv6)]() mutable {
+    callOnMainRunLoop([this, networkList = WTFMove(networkList), ipv4 = WTFMove(ipv4), ipv6 = WTFMove(ipv6)]() mutable {
         m_didReceiveResults = true;
 
         m_networkList = WTFMove(networkList);

Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp (274173 => 274174)


--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -145,7 +145,7 @@
 void NetworkRTCProvider::createServerTCPSocket(LibWebRTCSocketIdentifier identifier, const RTCNetwork::SocketAddress& address, uint16_t minPort, uint16_t maxPort, int options)
 {
     ASSERT(m_rtcNetworkThread.IsCurrent());
-    callOnMainThread([this, protectedThis = makeRef(*this), identifier, address, minPort, maxPort, options] {
+    callOnMainRunLoop([this, protectedThis = makeRef(*this), identifier, address, minPort, maxPort, options] {
         if (!m_connection)
             return;
 
@@ -170,7 +170,7 @@
 
 void NetworkRTCProvider::createClientTCPSocket(LibWebRTCSocketIdentifier identifier, const RTCNetwork::SocketAddress& localAddress, const RTCNetwork::SocketAddress& remoteAddress, String&& userAgent, int options)
 {
-    callOnMainThread([this, protectedThis = makeRef(*this), identifier, localAddress, remoteAddress, userAgent = WTFMove(userAgent).isolatedCopy(), options]() mutable {
+    callOnMainRunLoop([this, protectedThis = makeRef(*this), identifier, localAddress, remoteAddress, userAgent = WTFMove(userAgent).isolatedCopy(), options]() mutable {
         if (!m_connection)
             return;
 
@@ -260,8 +260,8 @@
 
 void NetworkRTCProvider::createResolver(LibWebRTCResolverIdentifier identifier, String&& address)
 {
-    if (!isMainThread()) {
-        callOnMainThread([this, protectedThis = makeRef(*this), identifier, address = WTFMove(address).isolatedCopy()]() mutable {
+    if (!isMainRunLoop()) {
+        callOnMainRunLoop([this, protectedThis = makeRef(*this), identifier, address = WTFMove(address).isolatedCopy()]() mutable {
             if (!m_connection)
                 return;
             createResolver(identifier, WTFMove(address));
@@ -298,8 +298,8 @@
 
 void NetworkRTCProvider::stopResolver(LibWebRTCResolverIdentifier identifier)
 {
-    if (!isMainThread()) {
-        callOnMainThread([this, protectedThis = makeRef(*this), identifier] {
+    if (!isMainRunLoop()) {
+        callOnMainRunLoop([this, protectedThis = makeRef(*this), identifier] {
             if (!m_connection)
                 return;
             stopResolver(identifier);
@@ -316,7 +316,7 @@
 
 void NetworkRTCProvider::closeListeningSockets(Function<void()>&& completionHandler)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     if (!m_isListeningSocketAuthorized) {
         completionHandler();
         return;
@@ -332,7 +332,7 @@
         for (auto id : listeningSocketIdentifiers)
             m_sockets.get(id)->close();
 
-        callOnMainThread([provider = makeRef(*this), listeningSocketIdentifiers = WTFMove(listeningSocketIdentifiers), completionHandler = WTFMove(completionHandler)] {
+        callOnMainRunLoop([provider = makeRef(*this), listeningSocketIdentifiers = WTFMove(listeningSocketIdentifiers), completionHandler = WTFMove(completionHandler)] {
             if (provider->m_connection) {
                 for (auto identifier : listeningSocketIdentifiers)
                     provider->m_connection->connection().send(Messages::LibWebRTCNetwork::SignalClose(identifier, ECONNABORTED), 0);

Modified: trunk/Source/WebKit/Platform/IPC/Connection.cpp (274173 => 274174)


--- trunk/Source/WebKit/Platform/IPC/Connection.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/Platform/IPC/Connection.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -432,7 +432,7 @@
         return false;
 
 #if ENABLE(IPC_TESTING_API)
-    if (isMainThread()) {
+    if (isMainRunLoop()) {
         bool hasDeadObservers = false;
         for (auto& observerWeakPtr : m_messageObservers) {
             if (auto* observer = observerWeakPtr.get())
@@ -445,7 +445,7 @@
     }
 #endif
 
-    if (isMainThread() && m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting && !encoder->isSyncMessage() && !(encoder->messageReceiverName() == ReceiverName::IPC) && !sendOptions.contains(SendOption::IgnoreFullySynchronousMode)) {
+    if (isMainRunLoop() && m_inDispatchMessageMarkedToUseFullySynchronousModeForTesting && !encoder->isSyncMessage() && !(encoder->messageReceiverName() == ReceiverName::IPC) && !sendOptions.contains(SendOption::IgnoreFullySynchronousMode)) {
         uint64_t syncRequestID;
         auto wrappedMessage = createSyncMessageEncoder(MessageName::WrappedAsyncMessageForTesting, encoder->destinationID(), syncRequestID);
         wrappedMessage->setFullySynchronousModeForTesting();
@@ -994,7 +994,7 @@
     }
 
 #if ENABLE(IPC_TESTING_API)
-    if (isMainThread()) {
+    if (isMainRunLoop()) {
         bool hasDeadObservers = false;
         for (auto& observerWeakPtr : m_messageObservers) {
             if (auto* observer = observerWeakPtr.get())

Modified: trunk/Source/WebKit/Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm (274173 => 274174)


--- trunk/Source/WebKit/Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm	2021-03-09 22:07:00 UTC (rev 274174)
@@ -39,7 +39,7 @@
 
 void AuthenticationManager::initializeConnection(IPC::Connection* connection)
 {
-    RELEASE_ASSERT(isMainThread());
+    RELEASE_ASSERT(isMainRunLoop());
 
     if (!connection || !connection->xpcConnection()) {
         ASSERT_NOT_REACHED();
@@ -50,8 +50,8 @@
     // The following xpc event handler overwrites the boostrap event handler and is only used
     // to capture client certificate credential.
     xpc_connection_set_event_handler(connection->xpcConnection(), ^(xpc_object_t event) {
-        callOnMainThread([event = OSObjectPtr(event), weakThis = weakThis] {
-            RELEASE_ASSERT(isMainThread());
+        callOnMainRunLoop([event = OSObjectPtr(event), weakThis = weakThis] {
+            RELEASE_ASSERT(isMainRunLoop());
 
             xpc_type_t type = xpc_get_type(event.get());
             if (type == XPC_TYPE_ERROR || !weakThis)

Modified: trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaFormatReader.cpp (274173 => 274174)


--- trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaFormatReader.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaFormatReader.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -82,12 +82,12 @@
 
 void MediaFormatReader::startOnMainThread(MTPluginByteSourceRef byteSource)
 {
-    if (isMainThread()) {
+    if (isMainRunLoop()) {
         parseByteSource(WTFMove(byteSource));
         return;
     }
 
-    callOnMainThread([this, protectedThis = makeRef(*this), byteSource = retainPtr(byteSource)]() mutable {
+    callOnMainRunLoop([this, protectedThis = makeRef(*this), byteSource = retainPtr(byteSource)]() mutable {
         parseByteSource(WTFMove(byteSource));
     });
 }
@@ -100,7 +100,7 @@
 
 void MediaFormatReader::parseByteSource(RetainPtr<MTPluginByteSourceRef>&& byteSource)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     static NeverDestroyed<ContentType> contentType("video/webm"_s);
     auto parser = SourceBufferParserWebM::create(contentType);
@@ -152,7 +152,7 @@
 
 void MediaFormatReader::didParseTracks(SourceBufferPrivateClient::InitializationSegment&& segment, uint64_t errorCode)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     auto locker = holdLock(m_parseTracksLock);
     ASSERT(!m_parseTracksStatus);
@@ -195,7 +195,7 @@
 
 void MediaFormatReader::didProvideMediaData(Ref<MediaSample>&& mediaSample, uint64_t trackID, const String&)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     auto locker = holdLock(m_parseTracksLock);
     auto trackIndex = m_trackReaders.findMatching([&](auto& track) {
@@ -208,7 +208,7 @@
 
 void MediaFormatReader::finishParsing(Ref<SourceBufferParser>&& parser)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     ALWAYS_LOG(LOGIDENTIFIER);
 
     auto locker = holdLock(m_parseTracksLock);

Modified: trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaSampleByteRange.cpp (274173 => 274174)


--- trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaSampleByteRange.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaSampleByteRange.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -45,7 +45,7 @@
     , m_byteSource(byteSource)
     , m_flags(sample.flags())
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     ASSERT(m_decodeTime == m_presentationTime || m_decodeTime == MediaTime::invalidTime());
     auto platformSample = sample.platformSample();
     switch (platformSample.type) {

Modified: trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaTrackReader.cpp (274173 => 274174)


--- trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaTrackReader.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaTrackReader.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -78,7 +78,7 @@
     , m_logger(formatReader.logger())
     , m_logIdentifier(formatReader.nextTrackReaderLogIdentifier(trackID))
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     ALWAYS_LOG(LOGIDENTIFIER, mediaTypeString(), " ", trackID);
     if (enabled)
@@ -97,7 +97,7 @@
 
 void MediaTrackReader::addSample(Ref<MediaSample>&& sample, MTPluginByteSourceRef byteSource)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     auto locker = holdLock(m_sampleStorageLock);
     if (!m_sampleStorage)
         m_sampleStorage = makeUnique<SampleStorage>();
@@ -126,7 +126,7 @@
 
 void MediaTrackReader::finishParsing()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     ALWAYS_LOG(LOGIDENTIFIER);
     auto locker = holdLock(m_sampleStorageLock);

Modified: trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaTrackReader.h (274173 => 274174)


--- trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaTrackReader.h	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaTrackReader.h	2021-03-09 22:07:00 UTC (rev 274174)
@@ -89,7 +89,7 @@
 
     struct SampleStorage {
         WTF_MAKE_STRUCT_FAST_ALLOCATED;
-        ~SampleStorage() { ASSERT(!isMainThread()); }
+        ~SampleStorage() { ASSERT(!isMainRunLoop()); }
         WebCore::SampleMap sampleMap;
         bool hasAllSamples { false };
     };

Modified: trunk/Source/WebKit/UIProcess/API/glib/IconDatabase.cpp (274173 => 274174)


--- trunk/Source/WebKit/UIProcess/API/glib/IconDatabase.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/UIProcess/API/glib/IconDatabase.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -51,7 +51,7 @@
     , m_allowDatabaseWrite(allowDatabaseWrite)
     , m_clearLoadedIconsTimer(RunLoop::main(), this, &IconDatabase::clearLoadedIconsTimerFired)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     m_clearLoadedIconsTimer.setPriority(RunLoopSourcePriority::ReleaseUnusedResourcesTimer);
 
     // We initialize the database synchronously, it's hopefully fast enough because it makes
@@ -108,7 +108,7 @@
 
 IconDatabase::~IconDatabase()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     BinarySemaphore semaphore;
     m_workQueue->dispatch([&] {
@@ -124,7 +124,7 @@
 
 bool IconDatabase::createTablesIfNeeded()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     if (m_db.tableExists("IconInfo") && m_db.tableExists("IconData") && m_db.tableExists("PageURL") && m_db.tableExists("IconDatabaseInfo"))
         return false;
@@ -182,7 +182,7 @@
 
 void IconDatabase::populatePageURLToIconURLMap()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     if (!m_db.isOpen())
         return;
@@ -206,7 +206,7 @@
 
 void IconDatabase::clearStatements()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     ASSERT(m_db.isOpen());
 
     m_iconIDForIconURLStatement = nullptr;
@@ -223,7 +223,7 @@
 
 void IconDatabase::pruneTimerFired()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     ASSERT(m_db.isOpen());
 
     if (!m_pruneIconsStatement) {
@@ -253,7 +253,7 @@
 
 void IconDatabase::startPruneTimer()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     if (!m_pruneTimer || !m_db.isOpen())
         return;
@@ -265,7 +265,7 @@
 
 void IconDatabase::clearLoadedIconsTimerFired()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     LockHolder lockHolder(m_loadedIconsLock);
     auto now = MonotonicTime::now();
@@ -284,7 +284,7 @@
 
 void IconDatabase::startClearLoadedIconsTimer()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     if (m_clearLoadedIconsTimer.isActive())
         return;
@@ -294,7 +294,7 @@
 
 Optional<int64_t> IconDatabase::iconIDForIconURL(const String& iconURL, bool& expired)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     ASSERT(m_db.isOpen());
 
     if (!m_iconIDForIconURLStatement) {
@@ -323,7 +323,7 @@
 
 bool IconDatabase::setIconIDForPageURL(int64_t iconID, const String& pageURL)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     ASSERT(m_db.isOpen());
     ASSERT(m_allowDatabaseWrite == AllowDatabaseWrite::Yes);
 
@@ -351,7 +351,7 @@
 
 Vector<char> IconDatabase::iconData(int64_t iconID)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     ASSERT(m_db.isOpen());
 
     if (!m_iconDataStatement) {
@@ -378,7 +378,7 @@
 
 Optional<int64_t> IconDatabase::addIcon(const String& iconURL, const Vector<char>& iconData)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     ASSERT(m_db.isOpen());
     ASSERT(m_allowDatabaseWrite == AllowDatabaseWrite::Yes);
 
@@ -421,7 +421,7 @@
 
 void IconDatabase::updateIconTimestamp(int64_t iconID, int64_t timestamp)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     ASSERT(m_db.isOpen());
     ASSERT(m_allowDatabaseWrite == AllowDatabaseWrite::Yes);
 
@@ -445,7 +445,7 @@
 
 void IconDatabase::deleteIcon(int64_t iconID)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     ASSERT(m_db.isOpen());
     ASSERT(m_allowDatabaseWrite == AllowDatabaseWrite::Yes);
 
@@ -492,7 +492,7 @@
 
 void IconDatabase::checkIconURLAndSetPageURLIfNeeded(const String& iconURL, const String& pageURL, AllowDatabaseWrite allowDatabaseWrite, CompletionHandler<void(bool, bool)>&& completionHandler)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     m_workQueue->dispatch([this, protectedThis = makeRef(*this), iconURL = iconURL.isolatedCopy(), pageURL = pageURL.isolatedCopy(), allowDatabaseWrite, completionHandler = WTFMove(completionHandler)]() mutable {
         bool result = false;
@@ -545,7 +545,7 @@
 
 void IconDatabase::loadIconForPageURL(const String& pageURL, AllowDatabaseWrite allowDatabaseWrite, CompletionHandler<void(PlatformImagePtr&&)>&& completionHandler)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     m_workQueue->dispatch([this, protectedThis = makeRef(*this), pageURL = pageURL.isolatedCopy(), allowDatabaseWrite, timestamp = WallTime::now().secondsSinceEpoch(), completionHandler = WTFMove(completionHandler)]() mutable {
         Optional<int64_t> iconID;
@@ -607,7 +607,7 @@
 
 String IconDatabase::iconURLForPageURL(const String& pageURL)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     LockHolder lockHolder(m_pageURLToIconURLMapLock);
     return m_pageURLToIconURLMap.get(pageURL);
@@ -615,7 +615,7 @@
 
 void IconDatabase::setIconForPageURL(const String& iconURL, const unsigned char* iconData, size_t iconDataSize, const String& pageURL, AllowDatabaseWrite allowDatabaseWrite, CompletionHandler<void(bool)>&& completionHandler)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     // If database write is not allowed load the icon to cache it in memory only.
     if (m_allowDatabaseWrite == AllowDatabaseWrite::No || allowDatabaseWrite == AllowDatabaseWrite::No) {
@@ -677,7 +677,7 @@
 
 void IconDatabase::clear(CompletionHandler<void()>&& completionHandler)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     {
         LockHolder lockHolder(m_loadedIconsLock);

Modified: trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm (274173 => 274174)


--- trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm	2021-03-09 22:07:00 UTC (rev 274174)
@@ -212,7 +212,7 @@
 
 void requestAVCaptureAccessForType(MediaPermissionType type, CompletionHandler<void(bool authorized)>&& completionHandler)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     AVMediaType mediaType = type == MediaPermissionType::Audio ? AVMediaTypeAudio : AVMediaTypeVideo;
     auto decisionHandler = makeBlockPtr([completionHandler = WTFMove(completionHandler)](BOOL authorized) mutable {
@@ -240,7 +240,7 @@
 
 void requestSpeechRecognitionAccess(CompletionHandler<void(bool authorized)>&& completionHandler)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     auto decisionHandler = makeBlockPtr([completionHandler = WTFMove(completionHandler)](SFSpeechRecognizerAuthorizationStatus status) mutable {
         bool authorized = status == SFSpeechRecognizerAuthorizationStatusAuthorized;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/PreferenceObserver.mm (274173 => 274174)


--- trunk/Source/WebKit/UIProcess/Cocoa/PreferenceObserver.mm	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/UIProcess/Cocoa/PreferenceObserver.mm	2021-03-09 22:07:00 UTC (rev 274174)
@@ -89,7 +89,7 @@
 {
     [super _notifyObserversOfChangeFromValuesForKeys:oldValues toValuesForKeys:newValues];
 
-    if (!isMainThread()) {
+    if (!isMainRunLoop()) {
         [self findPreferenceChangesAndNotifyForKeys:oldValues toValuesForKeys:newValues];
         return;
     }

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (274173 => 274174)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-03-09 22:07:00 UTC (rev 274174)
@@ -224,7 +224,7 @@
 #if PLATFORM(IOS_FAMILY)
 static const Vector<ASCIILiteral>& nonBrowserServices()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     static const auto services = makeNeverDestroyed(Vector<ASCIILiteral> {
         "com.apple.lsd.open"_s,
         "com.apple.iconservices"_s,
@@ -236,7 +236,7 @@
 
 static const Vector<ASCIILiteral>& agxCompilerClasses()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     static const auto iokitClasses = makeNeverDestroyed(Vector<ASCIILiteral> {
         "AGXCommandQueue"_s,
         "AGXDevice"_s,
@@ -256,7 +256,7 @@
 #if PLATFORM(IOS)
 static const Vector<ASCIILiteral>& agxCompilerServices()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     static const auto services = makeNeverDestroyed(Vector<ASCIILiteral> {
         "com.apple.AGXCompilerService"_s,
         "com.apple.AGXCompilerService-S2A8"_s
@@ -267,7 +267,7 @@
 
 static const Vector<ASCIILiteral>& diagnosticServices()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     static const auto services = makeNeverDestroyed(Vector<ASCIILiteral> {
         "com.apple.diagnosticd"_s,
 #if PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp (274173 => 274174)


--- trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -121,7 +121,7 @@
 
 void RemoteInspectorClient::sendWebInspectorEvent(const String& event)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     ASSERT(m_connectionID.hasValue());
     auto message = event.utf8();
     send(m_connectionID.value(), reinterpret_cast<const uint8_t*>(message.data()), message.length());
@@ -155,7 +155,7 @@
 
 void RemoteInspectorClient::didClose(Inspector::RemoteInspectorSocketEndpoint&, ConnectionID)
 {
-    callOnMainThread([this] {
+    callOnMainRunLoop([this] {
         connectionClosed();
     });
 }

Modified: trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp (274173 => 274174)


--- trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/UIProcess/WebFramePolicyListenerProxy.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -59,7 +59,7 @@
 
 void WebFramePolicyListenerProxy::didReceiveSafeBrowsingResults(RefPtr<SafeBrowsingWarning>&& safeBrowsingWarning)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     ASSERT(!m_safeBrowsingWarning);
     if (m_policyResult && m_isNavigatingToAppBoundDomain) {
         if (m_reply)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (274173 => 274174)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -7665,7 +7665,7 @@
 #if PLATFORM(COCOA)
 static const Vector<ASCIILiteral>& gpuIOKitClasses()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     static const auto services = makeNeverDestroyed(Vector<ASCIILiteral> {
 #if PLATFORM(IOS_FAMILY)
         "AGXDeviceUserClient"_s,
@@ -7697,7 +7697,7 @@
 
 static const Vector<ASCIILiteral>& gpuMachServices()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     static const auto services = makeNeverDestroyed(Vector<ASCIILiteral> {
         "com.apple.MTLCompilerService"_s,
 #if PLATFORM(MAC) || PLATFORM(MACCATALYST)
@@ -7710,7 +7710,7 @@
 // FIXME(207716): The following should be removed when the GPU process is complete.
 static const Vector<ASCIILiteral>& mediaRelatedMachServices()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     static const auto services = makeNeverDestroyed(Vector<ASCIILiteral> {
         "com.apple.audio.AudioComponentPrefs"_s, "com.apple.audio.AudioComponentRegistrar"_s,
         "com.apple.audio.AudioQueueServer"_s, "com.apple.coremedia.endpoint.xpc"_s,

Modified: trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm (274173 => 274174)


--- trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/UIProcess/ios/WKPDFView.mm	2021-03-09 22:07:00 UTC (rev 274174)
@@ -136,7 +136,7 @@
     _suggestedFilename = adoptNS([filename copy]);
 
     [PDFHostViewController createHostView:[self, weakSelf = WeakObjCPtr<WKPDFView>(self)](PDFHostViewController *hostViewController) {
-        ASSERT(isMainThread());
+        ASSERT(isMainRunLoop());
 
         WKPDFView *autoreleasedSelf = weakSelf.getAutoreleased();
         if (!autoreleasedSelf)

Modified: trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm (274173 => 274174)


--- trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm	2021-03-09 22:07:00 UTC (rev 274174)
@@ -63,7 +63,7 @@
 
 - (void)dealloc
 {
-    callOnMainThread([frame = WTFMove(_webFrame), previews = WTFMove(_pagePreviews)] {
+    callOnMainRunLoop([frame = WTFMove(_webFrame), previews = WTFMove(_pagePreviews)] {
         // Deallocate these on the main thread, not the current thread, since the
         // reference counting and the destructors aren't threadsafe.
     });

Modified: trunk/Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -47,7 +47,7 @@
 
 WebCacheStorageConnection::~WebCacheStorageConnection()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 }
 
 IPC::Connection& WebCacheStorageConnection::connection()

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h	2021-03-09 22:07:00 UTC (rev 274174)
@@ -81,7 +81,7 @@
 
     void waitForDidFlushOnSecondaryThread(WebCore::DisplayList::FlushIdentifier targetFlushIdentifier)
     {
-        ASSERT(!isMainThread());
+        ASSERT(!isMainRunLoop());
         auto locker = holdLock(m_receivedFlushIdentifierLock);
         m_receivedFlushIdentifierChangedCondition.wait(m_receivedFlushIdentifierLock, [&] {
             return m_receivedFlushIdentifier == targetFlushIdentifier;

Modified: trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -670,7 +670,7 @@
         return;
     }
 
-    callOnMainThread([weakThis = makeWeakPtr(*this), this] {
+    callOnMainRunLoop([weakThis = makeWeakPtr(*this), this] {
         if (!weakThis)
             return;
 
@@ -683,7 +683,7 @@
 #if ENABLE(MEDIA_STREAM)
 void MediaPlayerPrivateRemote::load(MediaStreamPrivate&)
 {
-    callOnMainThread([weakThis = makeWeakPtr(*this), this] {
+    callOnMainRunLoop([weakThis = makeWeakPtr(*this), this] {
         if (!weakThis)
             return;
 

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -158,7 +158,7 @@
 
 void RemoteAudioDestinationProxy::renderQuantum()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
 #if PLATFORM(COCOA)
     m_audioBufferList->setSampleCount(WebCore::AudioUtilities::renderQuantumSize);

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProvider.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProvider.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSourceProvider.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -56,7 +56,7 @@
     , m_logIdentifier(helper.logIdentifier())
 #endif
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     UNUSED_PARAM(helper);
 
 #if ENABLE(WEB_AUDIO)
@@ -70,7 +70,7 @@
 
 void RemoteAudioSourceProvider::close()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     if (m_gpuProcessConnection)
         m_gpuProcessConnection->audioSourceProviderManager().removeProvider(m_identifier);
 }

Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteImageDecoderAVF.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -183,10 +183,10 @@
             m_frameImages.add(index, image);
     };
 
-    if (isMainThread())
+    if (isMainRunLoop())
         createFrameImage();
     else
-        callOnMainThreadAndWait(WTFMove(createFrameImage));
+        callOnMainRunLoopAndWait(WTFMove(createFrameImage));
 
     if (m_frameImages.contains(index))
         return m_frameImages.get(index);

Modified: trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -184,7 +184,7 @@
 
 void LibWebRTCCodecs::setCallbacks(bool useGPUProcess)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     if (!useGPUProcess) {
         webrtc::setVideoDecoderCallbacks(nullptr, nullptr, nullptr, nullptr);
@@ -259,7 +259,7 @@
 
 void LibWebRTCCodecs::failedDecoding(RTCDecoderIdentifier decoderIdentifier)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     if (auto* decoder = m_decoders.get(decoderIdentifier))
         decoder->hasError = true;
@@ -267,7 +267,7 @@
 
 void LibWebRTCCodecs::completedDecoding(RTCDecoderIdentifier decoderIdentifier, uint32_t timeStamp, WebCore::RemoteVideoSample&& remoteSample)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     // FIXME: Do error logging.
     auto* decoder = m_decoders.get(decoderIdentifier);
@@ -430,7 +430,7 @@
 
 void LibWebRTCCodecs::completedEncoding(RTCEncoderIdentifier identifier, IPC::DataReference&& data, const webrtc::WebKitEncodedFrameInfo& info)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
     // FIXME: Do error logging.
     auto* encoder = m_encoders.get(identifier);

Modified: trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCResolver.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCResolver.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCResolver.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -38,7 +38,7 @@
 
 void LibWebRTCResolver::sendOnMainThread(Function<void(IPC::Connection&)>&& callback)
 {
-    callOnMainThread([callback = WTFMove(callback)]() {
+    callOnMainRunLoop([callback = WTFMove(callback)]() {
         callback(WebProcess::singleton().ensureNetworkProcessConnection().connection());
     });
 }

Modified: trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -74,7 +74,7 @@
     if (m_connection)
         m_connection->send(Messages::NetworkRTCProvider::CreateServerTCPSocket(socket->identifier(), RTCNetwork::SocketAddress(address), minPort, maxPort, options), 0);
     else {
-        callOnMainThread([] {
+        callOnMainRunLoop([] {
             WebProcess::singleton().ensureNetworkProcessConnection();
         });
         m_pendingMessageTasks.append([identifier = socket->identifier(), address = RTCNetwork::SocketAddress(address), minPort, maxPort, options](auto& connection) {
@@ -92,7 +92,7 @@
     if (m_connection)
         m_connection->send(Messages::NetworkRTCProvider::CreateUDPSocket(socket->identifier(), RTCNetwork::SocketAddress(address), minPort, maxPort), 0);
     else {
-        callOnMainThread([] {
+        callOnMainRunLoop([] {
             WebProcess::singleton().ensureNetworkProcessConnection();
         });
         m_pendingMessageTasks.append([identifier = socket->identifier(), address = RTCNetwork::SocketAddress(address), minPort, maxPort](auto& connection) {
@@ -114,7 +114,7 @@
     if (m_connection)
         m_connection->send(Messages::NetworkRTCProvider::CreateClientTCPSocket(socket->identifier(), RTCNetwork::SocketAddress(prepareSocketAddress(localAddress, m_disableNonLocalhostConnections)), RTCNetwork::SocketAddress(prepareSocketAddress(remoteAddress, m_disableNonLocalhostConnections)), userAgent, options.opts), 0);
     else {
-        callOnMainThread([] {
+        callOnMainRunLoop([] {
             WebProcess::singleton().ensureNetworkProcessConnection();
         });
         m_pendingMessageTasks.append([identifier = socket->identifier(), localAddress = RTCNetwork::SocketAddress(prepareSocketAddress(localAddress, m_disableNonLocalhostConnections)), remoteAddress = RTCNetwork::SocketAddress(prepareSocketAddress(remoteAddress, m_disableNonLocalhostConnections)), userAgent, opts = options.opts](auto& connection) {

Modified: trunk/Source/WebKit/WebProcess/Network/webrtc/WebRTCMonitor.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/Network/webrtc/WebRTCMonitor.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/Network/webrtc/WebRTCMonitor.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -43,7 +43,7 @@
 
 void WebRTCMonitor::sendOnMainThread(Function<void(IPC::Connection&)>&& callback)
 {
-    callOnMainThread([callback = WTFMove(callback)]() {
+    callOnMainRunLoop([callback = WTFMove(callback)]() {
         callback(WebProcess::singleton().ensureNetworkProcessConnection().connection());
     });
 }

Modified: trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm	2021-03-09 22:07:00 UTC (rev 274174)
@@ -655,8 +655,8 @@
 #if !LOG_DISABLED
 void PDFPlugin::pdfLog(const String& message)
 {
-    if (!isMainThread()) {
-        callOnMainThread([this, protectedThis = makeRef(*this), message = message.isolatedCopy()] {
+    if (!isMainRunLoop()) {
+        callOnMainRunLoop([this, protectedThis = makeRef(*this), message = message.isolatedCopy()] {
             pdfLog(message);
         });
         return;
@@ -669,7 +669,7 @@
 
 void PDFPlugin::logStreamLoader(WTF::TextStream& stream, WebCore::NetscapePlugInStreamLoader& loader)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     auto* request = byteRangeRequestForLoader(loader);
     stream << "(";
@@ -683,7 +683,7 @@
 
 void PDFPlugin::verboseLog()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     TextStream stream;
     stream << "\n";
@@ -717,11 +717,11 @@
     if (m_hasBeenDestroyed)
         return;
 
-    if (!isMainThread()) {
+    if (!isMainRunLoop()) {
 #if !LOG_DISABLED
         pdfLog("Disabling incremental PDF loading on background thread");
 #endif
-        callOnMainThread([this, protectedThis = makeRef(*this)] {
+        callOnMainRunLoop([this, protectedThis = makeRef(*this)] {
             receivedNonLinearizedPDFSentinel();
         });
         return;
@@ -748,7 +748,7 @@
 {
     Ref<PDFPlugin> plugin = *((PDFPlugin*)info);
 
-    if (isMainThread()) {
+    if (isMainRunLoop()) {
 #if !LOG_DISABLED
         plugin->pdfLog(makeString("Handling request for ", count, " bytes at position ", position, " synchronously on the main thread"));
 #endif
@@ -799,7 +799,7 @@
 
 static void dataProviderGetByteRangesCallback(void* info, CFMutableArrayRef buffers, const CFRange* ranges, size_t count)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
 
 #if !LOG_DISABLED
     Ref<PDFPlugin> debugPluginRef = *((PDFPlugin*)info);
@@ -846,7 +846,7 @@
 
 static void dataProviderReleaseInfoCallback(void* info)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     adoptRef((PDFPlugin*)info);
 }
 
@@ -871,7 +871,7 @@
     auto scopeExit = makeScopeExit([protectedPlugin = WTFMove(protectedPlugin)] () mutable {
         // Keep the PDFPlugin alive until the end of this function and the end
         // of the last main thread task submitted by this function.
-        callOnMainThread([protectedPlugin = WTFMove(protectedPlugin)] { });
+        callOnMainRunLoop([protectedPlugin = WTFMove(protectedPlugin)] { });
     });
 
     // Balanced by a deref inside of the dataProviderReleaseInfoCallback
@@ -899,7 +899,7 @@
 
     [m_backgroundThreadDocument preloadDataOfPagesInRange:NSMakeRange(0, 1) onQueue:firstPageQueue->dispatchQueue() completion:[&firstPageSemaphore, this] (NSIndexSet *) mutable {
         if (m_incrementalPDFLoadingEnabled) {
-            callOnMainThread([this] {
+            callOnMainRunLoop([this] {
                 adoptBackgroundThreadDocument();
             });
         } else
@@ -924,7 +924,7 @@
 
 size_t PDFPlugin::getResourceBytesAtPositionMainThread(void* buffer, off_t position, size_t count)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     ASSERT(m_documentFinishedLoading);
     ASSERT(position >= 0);
 
@@ -943,7 +943,7 @@
 
 void PDFPlugin::getResourceBytesAtPosition(size_t count, off_t position, CompletionHandler<void(const uint8_t*, size_t)>&& completionHandler)
 {
-    ASSERT(isMainThread()); 
+    ASSERT(isMainRunLoop());
     ASSERT(position >= 0);
 
     ByteRangeRequest request = { static_cast<uint64_t>(position), count, WTFMove(completionHandler) };
@@ -1002,7 +1002,7 @@
 
     ASSERT(!m_pdfDocument);
     ASSERT(m_backgroundThreadDocument);
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
 #if !LOG_DISABLED
     pdfLog("Adopting PDFDocument from background thread");
@@ -1610,7 +1610,7 @@
 void PDFPlugin::installPDFDocument()
 {
     ASSERT(m_pdfDocument);
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     LOG(IncrementalPDF, "Installing PDF document");
 
     if (m_hasBeenDestroyed)
@@ -1760,7 +1760,7 @@
 
 void PDFPlugin::tryRunScriptsInPDFDocument()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     if (!m_pdfDocument || !m_documentFinishedLoading)
         return;
@@ -1781,12 +1781,12 @@
     auto& rawQueue = scriptUtilityQueue.get();
     RetainPtr<CGPDFDocumentRef> document = [m_pdfDocument documentRef];
     rawQueue.dispatch([scriptUtilityQueue = WTFMove(scriptUtilityQueue), completionHandler = WTFMove(completionHandler), document = WTFMove(document)] () mutable {
-        ASSERT(!isMainThread());
+        ASSERT(!isMainRunLoop());
 
         Vector<RetainPtr<CFStringRef>> scripts;
         getAllScriptsInPDFDocument(document.get(), scripts);
 
-        callOnMainThread([completionHandler = WTFMove(completionHandler), scripts = WTFMove(scripts)] () mutable {
+        callOnMainRunLoop([completionHandler = WTFMove(completionHandler), scripts = WTFMove(scripts)] () mutable {
             completionHandler(WTFMove(scripts));
         });
     });

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -147,7 +147,7 @@
 
 void WebSWClientConnection::didMatchRegistration(uint64_t matchingRequest, Optional<ServiceWorkerRegistrationData>&& result)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     if (auto completionHandler = m_ongoingMatchRegistrationTasks.take(matchingRequest))
         completionHandler(WTFMove(result));
@@ -155,7 +155,7 @@
 
 void WebSWClientConnection::didGetRegistrations(uint64_t matchingRequest, Vector<ServiceWorkerRegistrationData>&& registrations)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     if (auto completionHandler = m_ongoingGetRegistrationsTasks.take(matchingRequest))
         completionHandler(WTFMove(registrations));
@@ -163,7 +163,7 @@
 
 void WebSWClientConnection::matchRegistration(SecurityOriginData&& topOrigin, const URL& clientURL, RegistrationCallback&& callback)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     if (!mayHaveServiceWorkerRegisteredForOrigin(topOrigin)) {
         callback(WTF::nullopt);
@@ -209,7 +209,7 @@
 
 void WebSWClientConnection::getRegistrations(SecurityOriginData&& topOrigin, const URL& clientURL, GetRegistrationsCallback&& callback)
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     if (!mayHaveServiceWorkerRegisteredForOrigin(topOrigin)) {
         callback({ });

Modified: trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -111,7 +111,7 @@
         return;
     }
 
-    callOnMainThread([this, protectedThis = makeRef(*this), blobURL = blobURL.isolatedCopy()] () {
+    callOnMainRunLoop([this, protectedThis = makeRef(*this), blobURL = blobURL.isolatedCopy()] () {
         auto* serviceWorkerThreadProxy = SWContextManager::singleton().serviceWorkerThreadProxy(m_serviceWorkerIdentifier);
         if (!serviceWorkerThreadProxy) {
             didFail(internalError(blobURL));
@@ -222,8 +222,8 @@
 {
     m_connection = nullptr;
 
-    if (!isMainThread()) {
-        callOnMainThread([protectedThis = makeRef(*this)] () {
+    if (!isMainRunLoop()) {
+        callOnMainRunLoop([protectedThis = makeRef(*this)] () {
             protectedThis->cleanup();
         });
         return;

Modified: trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/WebPage/FindController.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -542,7 +542,7 @@
 
         if (findIndicatorRect != m_findIndicatorRect) {
             // We are underneath painting, so it's not safe to mutate the layer tree synchronously.
-            callOnMainThread([weakWebPage = makeWeakPtr(m_webPage)] {
+            callOnMainRunLoop([weakWebPage = makeWeakPtr(m_webPage)] {
                 if (!weakWebPage)
                     return;
                 weakWebPage->findController().didScrollAffectingFindIndicatorPosition();

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -5915,7 +5915,7 @@
 {
     if (m_focusedElement == &element) {
         m_recentlyBlurredElement = WTFMove(m_focusedElement);
-        callOnMainThread([protectedThis = makeRefPtr(this)] {
+        callOnMainRunLoop([protectedThis = makeRefPtr(this)] {
             if (protectedThis->m_recentlyBlurredElement) {
 #if PLATFORM(IOS_FAMILY)
                 protectedThis->send(Messages::WebPageProxy::ElementDidBlur());

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-03-09 22:07:00 UTC (rev 274174)
@@ -790,7 +790,7 @@
         return;
     }
     contentChangeObserver.stopContentObservation();
-    callOnMainThread([protectedThis = makeRefPtr(this), targetNode = Ref<Node>(nodeRespondingToClick), location, modifiers, observedContentChange, pointerId] {
+    callOnMainRunLoop([protectedThis = makeRefPtr(this), targetNode = Ref<Node>(nodeRespondingToClick), location, modifiers, observedContentChange, pointerId] {
         if (protectedThis->m_isClosed || !protectedThis->corePage())
             return;
 
@@ -811,7 +811,7 @@
     LOG_WITH_STREAM(ContentObservation, stream << "didFinishContentChangeObserving: pending target node(" << m_pendingSyntheticClickNode << ")");
     if (!m_pendingSyntheticClickNode)
         return;
-    callOnMainThread([protectedThis = makeRefPtr(this), targetNode = Ref<Node>(*m_pendingSyntheticClickNode), originalDocument = makeWeakPtr(m_pendingSyntheticClickNode->document()), observedContentChange, location = m_pendingSyntheticClickLocation, modifiers = m_pendingSyntheticClickModifiers, pointerId = m_pendingSyntheticClickPointerId] {
+    callOnMainRunLoop([protectedThis = makeRefPtr(this), targetNode = Ref<Node>(*m_pendingSyntheticClickNode), originalDocument = makeWeakPtr(m_pendingSyntheticClickNode->document()), observedContentChange, location = m_pendingSyntheticClickLocation, modifiers = m_pendingSyntheticClickModifiers, pointerId = m_pendingSyntheticClickPointerId] {
         if (protectedThis->m_isClosed || !protectedThis->corePage())
             return;
         if (!originalDocument || &targetNode->document() != originalDocument)
@@ -1238,7 +1238,7 @@
         return;
 
     m_hasPendingInputContextUpdateAfterBlurringAndRefocusingElement = true;
-    callOnMainThread([this, protectedThis = makeRefPtr(this)] {
+    callOnMainRunLoop([this, protectedThis = makeRefPtr(this)] {
         if (m_hasPendingInputContextUpdateAfterBlurringAndRefocusingElement)
             send(Messages::WebPageProxy::UpdateInputContextAfterBlurringAndRefocusingElement());
         m_hasPendingInputContextUpdateAfterBlurringAndRefocusingElement = false;

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/DrawingAreaMac.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/DrawingAreaMac.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/DrawingAreaMac.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -93,7 +93,7 @@
 
 void DisplayRefreshMonitorMac::displayLinkFired()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     if (!m_firstCallbackInCurrentRunloop)
         return;
     m_firstCallbackInCurrentRunloop = false;

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm	2021-03-09 22:07:00 UTC (rev 274174)
@@ -48,7 +48,7 @@
 
 - (NakedPtr<WebCore::AXObjectCache>)axObjectCache
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     if (!m_page)
         return nullptr;
@@ -66,7 +66,7 @@
 
 - (id)accessibilityPluginObject
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     auto retrieveBlock = [&self]() -> id {
         id axPlugin = nil;
         auto dispatchBlock = [&axPlugin, &self] {
@@ -74,10 +74,10 @@
                 axPlugin = self->m_page->accessibilityObjectForMainFramePlugin();
         };
 
-        if (isMainThread())
+        if (isMainRunLoop())
             dispatchBlock();
         else {
-            callOnMainThreadAndWait([&dispatchBlock] {
+            callOnMainRunLoopAndWait([&dispatchBlock] {
                 dispatchBlock();
             });
         }
@@ -107,7 +107,7 @@
 
 - (void)setWebPage:(NakedPtr<WebKit::WebPage>)page
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 
     m_page = page;
 
@@ -124,13 +124,13 @@
 
 - (void)setHasMainFramePlugin:(bool)hasPlugin
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     m_hasMainFramePlugin = hasPlugin;
 }
 
 - (void)setRemoteParent:(id)parent
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
     m_parent = parent;
 }
 

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeAudioSource.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -112,7 +112,7 @@
 
 void RemoteRealtimeAudioSource::remoteAudioSamplesAvailable(const MediaTime& time, const PlatformAudioData& data, const AudioStreamDescription& description, size_t size)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!isMainRunLoop());
     audioSamplesAvailable(time, data, description, size);
 }
 

Modified: trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp (274173 => 274174)


--- trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Source/WebKit/WebProcess/cocoa/RemoteRealtimeMediaSourceProxy.cpp	2021-03-09 22:07:00 UTC (rev 274174)
@@ -51,7 +51,7 @@
 
 IPC::Connection* RemoteRealtimeMediaSourceProxy::connection()
 {
-    ASSERT(isMainThread());
+    ASSERT(isMainRunLoop());
 #if ENABLE(GPU_PROCESS)
     if (m_shouldCaptureInGPUProcess)
         return &WebProcess::singleton().ensureGPUProcessConnection().connection();

Modified: trunk/Tools/ChangeLog (274173 => 274174)


--- trunk/Tools/ChangeLog	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Tools/ChangeLog	2021-03-09 22:07:00 UTC (rev 274174)
@@ -1,3 +1,18 @@
+2021-03-09  Chris Dumez  <[email protected]>
+
+        Stop using callOnMainThread() / isMainThread() in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=222986
+
+        Reviewed by Alex Christensen.
+
+        Add corresponding style checker rules.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_no_callonmainthread):
+        (check_no_ismainthread):
+        (check_style):
+        (CppChecker):
+
 2021-03-09  Aakash Jain  <[email protected]>
 
         buildbot checkconfig is failing in ews after buildbot upgrade

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (274173 => 274174)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2021-03-09 21:36:01 UTC (rev 274173)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2021-03-09 22:07:00 UTC (rev 274174)
@@ -2723,6 +2723,53 @@
     error(line_number, 'runtime/wtf_optional', 4, "Use 'WTF::Optional<>' instead of 'std::optional<>'.")
 
 
+def check_callonmainthread(filename, clean_lines, line_number, file_state, error):
+    """Looks for use of 'callOnMainThread()' which should be replaced with 'callOnMainRunLoop()'.
+
+    Args:
+      filename: The current file cpp_style is running over.
+      clean_lines: A CleansedLines instance containing the file.
+      line_number: The number of the line to check.
+      file_state: A _FileState instance which maintains information about
+                  the state of things in the file.
+      error: The function to call with any errors found.
+    """
+
+    if not _is_webkit2_file(filename):
+        return
+
+    line = clean_lines.elided[line_number]  # Get rid of comments and strings.
+    using_callonmainthread = search(r'\bcallOnMainThread\s*\(', line)
+    if using_callonmainthread:
+        error(line_number, 'runtime/callonmainthread', 4, "Use 'callOnMainRunLoop()' instead of 'callOnMainThread()' in Source/WebKit.")
+    using_callonmainthreadandwait = search(r'\bcallOnMainThreadAndWait\s*\(', line)
+    if using_callonmainthreadandwait:
+        error(line_number, 'runtime/callonmainthread', 4, "Use 'callOnMainRunLoopAndWait()' instead of 'callOnMainThreadAndWait()' in Source/WebKit.")
+
+
+def check_ismainthread(filename, clean_lines, line_number, file_state, error):
+    """Looks for use of 'isMainThread()' which should be replaced with 'isMainRunLoop()'.
+
+    Args:
+      filename: The current file cpp_style is running over.
+      clean_lines: A CleansedLines instance containing the file.
+      line_number: The number of the line to check.
+      file_state: A _FileState instance which maintains information about
+                  the state of things in the file.
+      error: The function to call with any errors found.
+    """
+
+    if not _is_webkit2_file(filename):
+        return
+
+    line = clean_lines.elided[line_number]  # Get rid of comments and strings.
+    using_ismainthread = search(r'\bisMainThread\s*\(', line)
+    if not using_ismainthread:
+        return
+
+    error(line_number, 'runtime/ismainthread', 4, "Use 'isMainRunLoop()' instead of 'isMainThread()' in Source/WebKit.")
+
+
 def check_wtf_make_unique(clean_lines, line_number, file_state, error):
     """Looks for use of 'std::make_unique<>' which should be replaced with 'WTF::makeUnique<>'.
 
@@ -3491,6 +3538,10 @@
     return filename.startswith('Source/_javascript_Core/')
 
 
+def _is_webkit2_file(filename):
+    return filename.startswith('Source/WebKit/')
+
+
 def check_include_line(filename, file_extension, clean_lines, line_number, include_state, error):
     """Check rules that are applicable to #include lines.
 
@@ -4431,6 +4482,8 @@
     check_posix_threading(clean_lines, line, error)
     check_invalid_increment(clean_lines, line, error)
     check_os_version_checks(filename, clean_lines, line, error)
+    check_callonmainthread(filename, clean_lines, line, file_state, error)
+    check_ismainthread(filename, clean_lines, line, file_state, error)
 
 
 class _InlineASMState(object):
@@ -4547,6 +4600,7 @@
         'readability/utf8',
         'runtime/arrays',
         'runtime/bitfields',
+        'runtime/callonmainthread',
         'runtime/casting',
         'runtime/ctype_function',
         'runtime/dispatch_set_target_queue',
@@ -4555,6 +4609,7 @@
         'runtime/init',
         'runtime/int',
         'runtime/invalid_increment',
+        'runtime/ismainthread',
         'runtime/leaky_pattern',
         'runtime/lock_guard',
         'runtime/max_min_macros',
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to