Consistently use RunLoop::isMain() in WebKit2
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jun 2017 21:18:28 +0000 (21:18 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jun 2017 21:18:28 +0000 (21:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173745
<rdar://problem/32936527>

Reviewed by Brent Fulgham.

Consistently use RunLoop:isMain() on WebKit2 instead of WTF::isMainThread().
WTF::isMainThread() returns true for the WebThread instead of the UIThread
in WebKit1. Therefore WTF::isMainThread() is unsafe to use in the UIProcess
as the application may be using WebKit1 as well and have a WebThread.

Technically, we only *need* to move from WTF::isMainThread() to
RunLoop::isMain() in the UIProcess code but I ported all of WebKit2 for
consistency. RunLoop::isMain() is always safe in WebKit2.

* NetworkProcess/NetworkDataTask.cpp:
(WebKit::NetworkDataTask::NetworkDataTask):
(WebKit::NetworkDataTask::~NetworkDataTask):
* NetworkProcess/NetworkDataTaskBlob.cpp:
(WebKit::NetworkDataTaskBlob::getSizeForNext):
(WebKit::NetworkDataTaskBlob::didGetSize):
(WebKit::NetworkDataTaskBlob::seek):
(WebKit::NetworkDataTaskBlob::read):
* NetworkProcess/NetworkLoad.cpp:
(WebKit::NetworkLoad::didReceiveResponseNetworkSession):
(WebKit::NetworkLoad::notifyDidReceiveResponse):
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::defaultSession):
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::resourceType):
(WebKit::NetworkCache::Cache::initialize):
* NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp:
(WebKit::NetworkCache::IOChannel::read):
(WebKit::NetworkCache::IOChannel::readSyncInThread):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]):
(WebKit::NetworkSessionCocoa::defaultSession):
(WebKit::NetworkSessionCocoa::dataTaskForIdentifier):
* Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
(WebKit::CoordinatedGraphicsScene::dispatchOnMainThread):
(WebKit::CoordinatedGraphicsScene::syncRemoteContent):
(WebKit::CoordinatedGraphicsScene::detach):
(WebKit::CoordinatedGraphicsScene::appendUpdate):
* Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
(WebKit::WorkQueuePool::singleton):
(WebKit::WorkQueuePool::dispatch):
(WebKit::CompositingRunLoop::~CompositingRunLoop):
(WebKit::CompositingRunLoop::performTask):
(WebKit::CompositingRunLoop::performTaskSync):
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::createGLContext):
(WebKit::ThreadedCompositor::renderNextFrame):
(WebKit::ThreadedCompositor::commitScrollOffset):
(WebKit::ThreadedCompositor::updateSceneState):
(WebKit::ThreadedCompositor::releaseUpdateAtlases):
(WebKit::ThreadedCompositor::frameComplete):
* Shared/Plugins/NPObjectProxy.cpp:
(WebKit::NPObjectProxy::NP_Deallocate):
* UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
(WebKit::LocalStorageDatabaseTracker::deleteDatabasesModifiedSince):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores):
(WebKit::WebProcessProxy::topPrivatelyControlledDomainsWithWebiteData):
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
(WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
(WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
(WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
* UIProcess/ios/WKPDFView.mm:
(-[WKPDFView _highlightLinkAnnotation:forDuration:completionHandler:]):
* UIProcess/ios/forms/WKFileUploadPanel.mm:
(-[WKFileUploadPanel _uploadItemForImageData:imageName:successBlock:failureBlock:]):
* WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp:
(WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
* WebProcess/soup/WebKitSoupRequestInputStream.cpp:
(webkitSoupRequestInputStreamReadAsync):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218763 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkDataTask.cpp
Source/WebKit2/NetworkProcess/NetworkDataTaskBlob.cpp
Source/WebKit2/NetworkProcess/NetworkLoad.cpp
Source/WebKit2/NetworkProcess/NetworkSession.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp
Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm
Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
Source/WebKit2/Shared/Plugins/NPObjectProxy.cpp
Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit2/UIProcess/ios/WKPDFView.mm
Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.mm
Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp
Source/WebKit2/WebProcess/soup/WebKitSoupRequestInputStream.cpp

index 468cf0f..32a0e5d 100644 (file)
@@ -1,3 +1,82 @@
+2017-06-23  Chris Dumez  <cdumez@apple.com>
+
+        Consistently use RunLoop::isMain() in WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=173745
+        <rdar://problem/32936527>
+
+        Reviewed by Brent Fulgham.
+
+        Consistently use RunLoop:isMain() on WebKit2 instead of WTF::isMainThread().
+        WTF::isMainThread() returns true for the WebThread instead of the UIThread
+        in WebKit1. Therefore WTF::isMainThread() is unsafe to use in the UIProcess
+        as the application may be using WebKit1 as well and have a WebThread.
+
+        Technically, we only *need* to move from WTF::isMainThread() to
+        RunLoop::isMain() in the UIProcess code but I ported all of WebKit2 for
+        consistency. RunLoop::isMain() is always safe in WebKit2.
+
+        * NetworkProcess/NetworkDataTask.cpp:
+        (WebKit::NetworkDataTask::NetworkDataTask):
+        (WebKit::NetworkDataTask::~NetworkDataTask):
+        * NetworkProcess/NetworkDataTaskBlob.cpp:
+        (WebKit::NetworkDataTaskBlob::getSizeForNext):
+        (WebKit::NetworkDataTaskBlob::didGetSize):
+        (WebKit::NetworkDataTaskBlob::seek):
+        (WebKit::NetworkDataTaskBlob::read):
+        * NetworkProcess/NetworkLoad.cpp:
+        (WebKit::NetworkLoad::didReceiveResponseNetworkSession):
+        (WebKit::NetworkLoad::notifyDidReceiveResponse):
+        * NetworkProcess/NetworkSession.cpp:
+        (WebKit::NetworkSession::defaultSession):
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::resourceType):
+        (WebKit::NetworkCache::Cache::initialize):
+        * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp:
+        (WebKit::NetworkCache::IOChannel::read):
+        (WebKit::NetworkCache::IOChannel::readSyncInThread):
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]):
+        (WebKit::NetworkSessionCocoa::defaultSession):
+        (WebKit::NetworkSessionCocoa::dataTaskForIdentifier):
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsScene.cpp:
+        (WebKit::CoordinatedGraphicsScene::dispatchOnMainThread):
+        (WebKit::CoordinatedGraphicsScene::syncRemoteContent):
+        (WebKit::CoordinatedGraphicsScene::detach):
+        (WebKit::CoordinatedGraphicsScene::appendUpdate):
+        * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
+        (WebKit::WorkQueuePool::singleton):
+        (WebKit::WorkQueuePool::dispatch):
+        (WebKit::CompositingRunLoop::~CompositingRunLoop):
+        (WebKit::CompositingRunLoop::performTask):
+        (WebKit::CompositingRunLoop::performTaskSync):
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::createGLContext):
+        (WebKit::ThreadedCompositor::renderNextFrame):
+        (WebKit::ThreadedCompositor::commitScrollOffset):
+        (WebKit::ThreadedCompositor::updateSceneState):
+        (WebKit::ThreadedCompositor::releaseUpdateAtlases):
+        (WebKit::ThreadedCompositor::frameComplete):
+        * Shared/Plugins/NPObjectProxy.cpp:
+        (WebKit::NPObjectProxy::NP_Deallocate):
+        * UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
+        (WebKit::LocalStorageDatabaseTracker::deleteDatabasesModifiedSince):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores):
+        (WebKit::WebProcessProxy::topPrivatelyControlledDomainsWithWebiteData):
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::removeDataRecords):
+        (WebKit::WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver):
+        (WebKit::WebResourceLoadStatisticsStore::writeStoreToDisk):
+        (WebKit::WebResourceLoadStatisticsStore::writeEncoderToDisk):
+        * UIProcess/ios/WKPDFView.mm:
+        (-[WKPDFView _highlightLinkAnnotation:forDuration:completionHandler:]):
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+        (-[WKFileUploadPanel _uploadItemForImageData:imageName:successBlock:failureBlock:]):
+        * WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp:
+        (WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
+        * WebProcess/soup/WebKitSoupRequestInputStream.cpp:
+        (webkitSoupRequestInputStreamReadAsync):
+
 2017-06-23  David Kilzer  <ddkilzer@apple.com>
 
         v3: REGRESSION (r218419): 3 NSMutableDictionary leaks calling -[WKProcessPool _pluginLoadClientPolicies]
index 83eb6ea..1294fd1 100644 (file)
@@ -69,7 +69,7 @@ NetworkDataTask::NetworkDataTask(NetworkSession& session, NetworkDataTaskClient&
     , m_firstRequest(requestWithCredentials)
     , m_shouldClearReferrerOnHTTPSToHTTPRedirect(shouldClearReferrerOnHTTPSToHTTPRedirect)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
 
     if (!requestWithCredentials.url().isValid()) {
         scheduleFailure(InvalidURLFailure);
@@ -84,7 +84,7 @@ NetworkDataTask::NetworkDataTask(NetworkSession& session, NetworkDataTaskClient&
 
 NetworkDataTask::~NetworkDataTask()
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     ASSERT(!m_client);
 }
 
index 6f4bbf5..0961273 100644 (file)
@@ -180,7 +180,7 @@ void NetworkDataTaskBlob::invalidateAndCancel()
 
 void NetworkDataTaskBlob::getSizeForNext()
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
 
     // Do we finish validating and counting size for all items?
     if (m_sizeItemCount >= m_blobData->items().size()) {
@@ -205,7 +205,7 @@ void NetworkDataTaskBlob::getSizeForNext()
 
 void NetworkDataTaskBlob::didGetSize(long long size)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
 
     if (m_state == State::Canceling || m_state == State::Completed || (!m_client && !isDownload())) {
         clearStream();
@@ -236,7 +236,7 @@ void NetworkDataTaskBlob::didGetSize(long long size)
 
 void NetworkDataTaskBlob::seek()
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
 
     // Convert from the suffix length to the range.
     if (m_rangeSuffixLength != kPositionNotSpecified) {
@@ -330,7 +330,7 @@ void NetworkDataTaskBlob::dispatchDidReceiveResponse(Error errorCode)
 
 void NetworkDataTaskBlob::read()
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
 
     // If there is no more remaining data to read, we are done.
     if (!m_totalRemainingSize || m_readItemCount >= m_blobData->items().size()) {
index b7dfd31..5173e79 100644 (file)
@@ -370,7 +370,7 @@ void NetworkLoad::continueCanAuthenticateAgainstProtectionSpace(bool result)
 
 void NetworkLoad::didReceiveResponseNetworkSession(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     ASSERT(!m_throttle);
 
     if (m_task && m_task->isDownload()) {
@@ -389,7 +389,7 @@ void NetworkLoad::didReceiveResponseNetworkSession(ResourceResponse&& response,
 
 void NetworkLoad::notifyDidReceiveResponse(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
 
 #if ENABLE(NETWORK_CAPTURE)
     if (m_recorder)
index 6e013f3..acde5c1 100644 (file)
@@ -60,7 +60,7 @@ NetworkSession& NetworkSession::defaultSession()
 #if PLATFORM(COCOA)
     return NetworkSessionCocoa::defaultSession();
 #else
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     static NetworkSession* session = &NetworkSession::create(SessionID::defaultSessionID()).leakRef();
     return *session;
 #endif
index 9f1cd0a..6fdb2cb 100644 (file)
@@ -57,7 +57,7 @@ namespace NetworkCache {
 
 static const AtomicString& resourceType()
 {
-    ASSERT(WTF::isMainThread());
+    ASSERT(WTF::RunLoop::isMain());
     static NeverDestroyed<const AtomicString> resource("Resource", AtomicString::ConstructFromLiteral);
     return resource;
 }
@@ -82,7 +82,7 @@ bool Cache::initialize(const String& cachePath, OptionSet<Option> options)
 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
     if (options.contains(Option::SpeculativeRevalidation)) {
         m_lowPowerModeNotifier = std::make_unique<WebCore::LowPowerModeNotifier>([this](bool isLowPowerModeEnabled) {
-            ASSERT(WTF::isMainThread());
+            ASSERT(WTF::RunLoop::isMain());
             if (isLowPowerModeEnabled)
                 m_speculativeLoadManager = nullptr;
             else {
index 3c43e87..0e19eaa 100644 (file)
@@ -164,7 +164,7 @@ void IOChannel::read(size_t offset, size_t size, WorkQueue* queue, Function<void
         return;
     }
 
-    if (!isMainThread()) {
+    if (!RunLoop::isMain()) {
         readSyncInThread(offset, size, queue, WTFMove(completionHandler));
         return;
     }
@@ -181,7 +181,7 @@ void IOChannel::read(size_t offset, size_t size, WorkQueue* queue, Function<void
 
 void IOChannel::readSyncInThread(size_t offset, size_t size, WorkQueue* queue, Function<void (Data&, int error)>&& completionHandler)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
 
     RefPtr<IOChannel> channel(this);
     Thread::create("IOChannel::readSync", [channel, size, queue, completionHandler = WTFMove(completionHandler)] () mutable {
index 16a5c47..9a452a5 100644 (file)
@@ -358,7 +358,7 @@ static WebCore::NetworkLoadPriority toNetworkLoadPriority(float priority)
     auto taskIdentifier = dataTask.taskIdentifier;
     LOG(NetworkSession, "%llu didReceiveResponse", taskIdentifier);
     if (auto* networkDataTask = [self existingTask:dataTask]) {
-        ASSERT(isMainThread());
+        ASSERT(RunLoop::isMain());
         
         // Avoid MIME type sniffing if the response comes back as 304 Not Modified.
         int statusCode = [response respondsToSelector:@selector(statusCode)] ? [(id)response statusCode] : 0;
@@ -535,7 +535,7 @@ Ref<NetworkSession> NetworkSessionCocoa::create(WebCore::SessionID sessionID, Le
 
 NetworkSession& NetworkSessionCocoa::defaultSession()
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     static NetworkSession* session = &NetworkSessionCocoa::create(WebCore::SessionID::defaultSessionID(), legacyCustomProtocolManager).leakRef();
     return *session;
 }
@@ -628,7 +628,7 @@ void NetworkSessionCocoa::clearCredentials()
 
 NetworkDataTaskCocoa* NetworkSessionCocoa::dataTaskForIdentifier(NetworkDataTaskCocoa::TaskIdentifier taskIdentifier, WebCore::StoredCredentials storedCredentials)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     if (storedCredentials == WebCore::StoredCredentials::AllowStoredCredentials)
         return m_dataTaskMapWithCredentials.get(taskIdentifier);
     return m_dataTaskMapWithoutCredentials.get(taskIdentifier);
index 2d806f1..31ca0f8 100644 (file)
@@ -37,7 +37,7 @@ namespace WebKit {
 
 void CoordinatedGraphicsScene::dispatchOnMainThread(Function<void()>&& function)
 {
-    if (isMainThread()) {
+    if (RunLoop::isMain()) {
         function();
         return;
     }
@@ -589,7 +589,7 @@ void CoordinatedGraphicsScene::syncRemoteContent()
     ensureRootLayer();
 
     Vector<Function<void()>> renderQueue;
-    bool calledOnMainThread = WTF::isMainThread();
+    bool calledOnMainThread = RunLoop::isMain();
     if (!calledOnMainThread)
         m_renderQueueMutex.lock();
     renderQueue = WTFMove(m_renderQueue);
@@ -642,7 +642,7 @@ void CoordinatedGraphicsScene::setLayerAnimationsIfNeeded(TextureMapperLayer* la
 
 void CoordinatedGraphicsScene::detach()
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     m_isActive = false;
     m_client = nullptr;
     LockHolder locker(m_renderQueueMutex);
@@ -654,7 +654,7 @@ void CoordinatedGraphicsScene::appendUpdate(Function<void()>&& function)
     if (!m_isActive)
         return;
 
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     LockHolder locker(m_renderQueueMutex);
     m_renderQueue.append(WTFMove(function));
 }
index eb2bf3a..4e0cb0f 100644 (file)
@@ -45,14 +45,14 @@ class WorkQueuePool {
 public:
     static WorkQueuePool& singleton()
     {
-        ASSERT(isMainThread());
+        ASSERT(RunLoop::isMain());
         static NeverDestroyed<WorkQueuePool> workQueuePool;
         return workQueuePool;
     }
 
     void dispatch(void* context, Function<void ()>&& function)
     {
-        ASSERT(isMainThread());
+        ASSERT(RunLoop::isMain());
         getOrCreateWorkQueueForContext(context).dispatch(WTFMove(function));
     }
 
@@ -119,7 +119,7 @@ CompositingRunLoop::CompositingRunLoop(Function<void ()>&& updateFunction)
 
 CompositingRunLoop::~CompositingRunLoop()
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     // Make sure the WorkQueue is deleted after the CompositingRunLoop, because m_updateTimer has a reference
     // of the WorkQueue run loop. Passing this is not a problem because the pointer will only be used as a
     // HashMap key by WorkQueuePool.
@@ -128,13 +128,13 @@ CompositingRunLoop::~CompositingRunLoop()
 
 void CompositingRunLoop::performTask(Function<void ()>&& function)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     WorkQueuePool::singleton().dispatch(this, WTFMove(function));
 }
 
 void CompositingRunLoop::performTaskSync(Function<void ()>&& function)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     LockHolder locker(m_dispatchSyncConditionMutex);
     WorkQueuePool::singleton().dispatch(this, [this, function = WTFMove(function)] {
         function();
index 29f0f60..e9cd21d 100644 (file)
@@ -81,7 +81,7 @@ ThreadedCompositor::~ThreadedCompositor()
 
 void ThreadedCompositor::createGLContext()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
 
     ASSERT(m_nativeSurfaceHandle);
 
@@ -165,13 +165,13 @@ void ThreadedCompositor::setDrawsBackground(bool drawsBackground)
 
 void ThreadedCompositor::renderNextFrame()
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     m_client.renderNextFrame();
 }
 
 void ThreadedCompositor::commitScrollOffset(uint32_t layerID, const IntSize& offset)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     m_client.commitScrollOffset(layerID, offset);
 }
 
@@ -239,7 +239,7 @@ void ThreadedCompositor::sceneUpdateFinished()
 
 void ThreadedCompositor::updateSceneState(const CoordinatedGraphicsState& state)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     m_scene->appendUpdate([this, scene = makeRef(*m_scene), state] {
         scene->commitSceneState(state);
 
@@ -259,7 +259,7 @@ void ThreadedCompositor::updateSceneState(const CoordinatedGraphicsState& state)
 
 void ThreadedCompositor::releaseUpdateAtlases(Vector<uint32_t>&& atlasesToRemove)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     m_scene->appendUpdate([scene = makeRef(*m_scene), atlasesToRemove = WTFMove(atlasesToRemove)] {
         scene->releaseUpdateAtlases(atlasesToRemove);
     });
@@ -294,7 +294,7 @@ void ThreadedCompositor::coordinateUpdateCompletionWithClient()
 
 void ThreadedCompositor::frameComplete()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     sceneUpdateFinished();
 }
 
index ef6c791..5aa9aed 100644 (file)
@@ -302,7 +302,7 @@ void NPObjectProxy::NP_Deallocate(NPObject* npObject)
     // Since NPAPI behavior on a background thread is undefined, it is okay to limit this workaround to the one API
     // that is known to be misused during plugin teardown, and to not be concerned about change in behavior if this
     // occured at any other time.
-    if (!isMainThread()) {
+    if (!RunLoop::isMain()) {
         RunLoop::main().dispatch([npObject] {
             NP_Deallocate(npObject);
         });
index 3e86b05..19b229f 100644 (file)
@@ -33,6 +33,7 @@
 #include <WebCore/SecurityOriginData.h>
 #include <WebCore/TextEncoding.h>
 #include <wtf/MainThread.h>
+#include <wtf/RunLoop.h>
 #include <wtf/WorkQueue.h>
 #include <wtf/text/CString.h>
 
@@ -143,7 +144,7 @@ static std::optional<time_t> fileModificationTime(const String& filePath)
 
 Vector<SecurityOriginData> LocalStorageDatabaseTracker::deleteDatabasesModifiedSince(std::chrono::system_clock::time_point time)
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     importOriginIdentifiers();
     Vector<String> originIdentifiersToDelete;
 
index b2271a7..7df2698 100644 (file)
@@ -212,7 +212,7 @@ WebPageProxy* WebProcessProxy::webPage(uint64_t pageID)
 void WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, Function<void(Vector<String>)>&& completionHandler)
 {
     // We expect this to be called on the main thread so we get the default website data store.
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     
     struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> {
         explicit CallbackAggregator(Function<void(Vector<String>)>&& completionHandler)
@@ -259,7 +259,7 @@ void WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPers
         callbackAggregator->addPendingCallback();
         dataStore.removeDataForTopPrivatelyControlledDomains(dataTypes, { }, topPrivatelyControlledDomains, [callbackAggregator, shouldNotifyPage, page](Vector<String>&& domainsWithDeletedWebsiteData) {
             // When completing the task, we should be getting called on the main thread.
-            ASSERT(isMainThread());
+            ASSERT(RunLoop::isMain());
             
             if (shouldNotifyPage)
                 page.value->postMessageToInjectedBundle("WebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished", nullptr);
@@ -273,7 +273,7 @@ void WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPers
 void WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, Function<void(HashSet<String>&&)>&& completionHandler)
 {
     // We expect this to be called on the main thread so we get the default website data store.
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     
     struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> {
         explicit CallbackAggregator(Function<void(HashSet<String>&&)>&& completionHandler)
@@ -321,7 +321,7 @@ void WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<Web
         callbackAggregator->addPendingCallback();
         dataStore.topPrivatelyControlledDomainsWithWebsiteData(dataTypes, { }, [callbackAggregator, shouldNotifyPage, page](HashSet<String>&& domainsWithDataRecords) {
             // When completing the task, we should be getting called on the main thread.
-            ASSERT(isMainThread());
+            ASSERT(RunLoop::isMain());
             
             if (shouldNotifyPage)
                 page.value->postMessageToInjectedBundle("WebsiteDataScanForTopPrivatelyControlledDomainsFinished", nullptr);
index f85c4cb..6f248a3 100644 (file)
@@ -103,7 +103,7 @@ static inline void initializeDataTypesToRemove()
     
 void WebResourceLoadStatisticsStore::removeDataRecords()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     
     if (!coreStore().shouldRemoveDataRecords())
         return;
@@ -176,7 +176,7 @@ bool WebResourceLoadStatisticsStore::resourceLoadStatisticsEnabled() const
 
 void WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver()
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     
     ResourceLoadObserver::sharedObserver().setStatisticsStore(m_resourceLoadStatisticsStore.copyRef());
     ResourceLoadObserver::sharedObserver().setStatisticsQueue(m_statisticsQueue.copyRef());
@@ -200,7 +200,7 @@ void WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver()
     
 void WebResourceLoadStatisticsStore::registerSharedResourceLoadObserver(WTF::Function<void(const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst)>&& shouldPartitionCookiesForDomainsHandler)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     
     registerSharedResourceLoadObserver();
     m_resourceLoadStatisticsStore->setShouldPartitionCookiesCallback([shouldPartitionCookiesForDomainsHandler = WTFMove(shouldPartitionCookiesForDomainsHandler)] (const Vector<String>& domainsToRemove, const Vector<String>& domainsToAdd, bool clearFirst) {
@@ -276,7 +276,7 @@ String WebResourceLoadStatisticsStore::persistentStoragePath(const String& label
 
 void WebResourceLoadStatisticsStore::writeStoreToDisk()
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     
     auto encoder = coreStore().createEncoderFromData();
     writeEncoderToDisk(*encoder.get(), "full_browsing_session");
@@ -284,7 +284,7 @@ void WebResourceLoadStatisticsStore::writeStoreToDisk()
 
 void WebResourceLoadStatisticsStore::writeEncoderToDisk(KeyedEncoder& encoder, const String& label) const
 {
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
     
     RefPtr<SharedBuffer> rawData = encoder.finishEncoding();
     if (!rawData)
index db8c7d8..cb8dce1 100644 (file)
@@ -427,7 +427,7 @@ static void detachViewForPage(PDFPageInfo& page)
     [highlightView setCornerRadius:highlightBorderRadius];
     [highlightView setColor:highlightColor];
 
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     [self addSubview:highlightView.get()];
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
         [highlightView removeFromSuperview];
index 31677f0..9e79b2b 100644 (file)
@@ -614,7 +614,7 @@ static NSArray *UTIsForMIMETypes(NSArray *mimeTypes)
 - (void)_uploadItemForImageData:(NSData *)imageData imageName:(NSString *)imageName successBlock:(void (^)(_WKFileUploadItem *))successBlock failureBlock:(void (^)(void))failureBlock
 {
     ASSERT_ARG(imageData, imageData);
-    ASSERT(!isMainThread());
+    ASSERT(!RunLoop::isMain());
 
     NSString * const kTemporaryDirectoryName = @"WKWebFileUpload";
 
index b5b021f..acb3625 100644 (file)
@@ -42,7 +42,7 @@ namespace WebKit {
 
 void WebFrameNetworkingContext::ensurePrivateBrowsingSession(SessionID sessionID)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     ASSERT(sessionID.isEphemeral());
 
     if (NetworkStorageSession::storageSession(sessionID))
index cfb5b10..f642aa7 100644 (file)
@@ -79,7 +79,7 @@ static bool webkitSoupRequestInputStreamIsWaitingForData(WebKitSoupRequestInputS
 
 static void webkitSoupRequestInputStreamReadAsync(GInputStream* inputStream, void* buffer, gsize count, int /*priority*/, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
     WebKitSoupRequestInputStream* stream = WEBKIT_SOUP_REQUEST_INPUT_STREAM(inputStream);
     GRefPtr<GTask> task = adoptGRef(g_task_new(stream, cancellable, callback, userData));
 
@@ -142,7 +142,7 @@ GInputStream* webkitSoupRequestInputStreamNew(uint64_t contentLength)
 
 void webkitSoupRequestInputStreamAddData(WebKitSoupRequestInputStream* stream, const void* data, size_t dataLength)
 {
-    ASSERT(isMainThread());
+    ASSERT(RunLoop::isMain());
 
     if (webkitSoupRequestInputStreamFinished(stream))
         return;