[IndexedDB] IndexedDB's threading assertion should respect Web thread
authorysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Nov 2019 20:53:34 +0000 (20:53 +0000)
committerysuzuki@apple.com <ysuzuki@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Nov 2019 20:53:34 +0000 (20:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=204346

Reviewed by Daniel Bates.

Source/WebCore:

Previously we are doing pointer-comparison between Thread::current() and origin-thread to
assert the thread affinity. But this does not respect Web thread: we can create an object
in Web Thread, and touch it in the main thread if web thread lock is correctly held.

This patch replaces pointer-comparison with WTF::canAccessThreadLocalDataForThread helper
function which appropriately respects Web thread status.

No behavior change.

* Modules/indexeddb/IDBActiveDOMObject.h:
(WebCore::IDBActiveDOMObject::performCallbackOnOriginThread):
(WebCore::IDBActiveDOMObject::callFunctionOnOriginThread):
* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::IDBCursor):
(WebCore::IDBCursor::~IDBCursor):
(WebCore::IDBCursor::sourcesDeleted const):
(WebCore::IDBCursor::transaction const):
(WebCore::IDBCursor::update):
(WebCore::IDBCursor::advance):
(WebCore::IDBCursor::continueFunction):
(WebCore::IDBCursor::uncheckedIterateCursor):
(WebCore::IDBCursor::deleteFunction):
(WebCore::IDBCursor::setGetResult):
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::~IDBDatabase):
(WebCore::IDBDatabase::hasPendingActivity const):
(WebCore::IDBDatabase::name const):
(WebCore::IDBDatabase::version const):
(WebCore::IDBDatabase::objectStoreNames const):
(WebCore::IDBDatabase::renameObjectStore):
(WebCore::IDBDatabase::renameIndex):
(WebCore::IDBDatabase::createObjectStore):
(WebCore::IDBDatabase::transaction):
(WebCore::IDBDatabase::deleteObjectStore):
(WebCore::IDBDatabase::close):
(WebCore::IDBDatabase::connectionToServerLost):
(WebCore::IDBDatabase::maybeCloseInServer):
(WebCore::IDBDatabase::activeDOMObjectName const):
(WebCore::IDBDatabase::stop):
(WebCore::IDBDatabase::startVersionChangeTransaction):
(WebCore::IDBDatabase::didStartTransaction):
(WebCore::IDBDatabase::willCommitTransaction):
(WebCore::IDBDatabase::didCommitTransaction):
(WebCore::IDBDatabase::willAbortTransaction):
(WebCore::IDBDatabase::didAbortTransaction):
(WebCore::IDBDatabase::didCommitOrAbortTransaction):
(WebCore::IDBDatabase::fireVersionChangeEvent):
(WebCore::IDBDatabase::dispatchEvent):
(WebCore::IDBDatabase::didCreateIndexInfo):
(WebCore::IDBDatabase::didDeleteIndexInfo):
* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::IDBIndex):
(WebCore::IDBIndex::~IDBIndex):
(WebCore::IDBIndex::name const):
(WebCore::IDBIndex::setName):
(WebCore::IDBIndex::objectStore):
(WebCore::IDBIndex::keyPath const):
(WebCore::IDBIndex::unique const):
(WebCore::IDBIndex::multiEntry const):
(WebCore::IDBIndex::rollbackInfoForVersionChangeAbort):
(WebCore::IDBIndex::doOpenCursor):
(WebCore::IDBIndex::doOpenKeyCursor):
(WebCore::IDBIndex::doCount):
(WebCore::IDBIndex::doGet):
(WebCore::IDBIndex::doGetKey):
(WebCore::IDBIndex::doGetAll):
(WebCore::IDBIndex::doGetAllKeys):
(WebCore::IDBIndex::markAsDeleted):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::IDBObjectStore):
(WebCore::IDBObjectStore::~IDBObjectStore):
(WebCore::IDBObjectStore::name const):
(WebCore::IDBObjectStore::setName):
(WebCore::IDBObjectStore::keyPath const):
(WebCore::IDBObjectStore::indexNames const):
(WebCore::IDBObjectStore::transaction):
(WebCore::IDBObjectStore::autoIncrement const):
(WebCore::IDBObjectStore::doOpenCursor):
(WebCore::IDBObjectStore::doOpenKeyCursor):
(WebCore::IDBObjectStore::get):
(WebCore::IDBObjectStore::getKey):
(WebCore::IDBObjectStore::putOrAdd):
(WebCore::IDBObjectStore::doDelete):
(WebCore::IDBObjectStore::clear):
(WebCore::IDBObjectStore::createIndex):
(WebCore::IDBObjectStore::index):
(WebCore::IDBObjectStore::deleteIndex):
(WebCore::IDBObjectStore::doCount):
(WebCore::IDBObjectStore::doGetAll):
(WebCore::IDBObjectStore::doGetAllKeys):
(WebCore::IDBObjectStore::markAsDeleted):
(WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::~IDBOpenDBRequest):
(WebCore::IDBOpenDBRequest::onError):
(WebCore::IDBOpenDBRequest::versionChangeTransactionDidFinish):
(WebCore::IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit):
(WebCore::IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion):
(WebCore::IDBOpenDBRequest::dispatchEvent):
(WebCore::IDBOpenDBRequest::onSuccess):
(WebCore::IDBOpenDBRequest::onUpgradeNeeded):
(WebCore::IDBOpenDBRequest::onDeleteDatabaseSuccess):
(WebCore::IDBOpenDBRequest::requestCompleted):
(WebCore::IDBOpenDBRequest::requestBlocked):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::~IDBRequest):
(WebCore:: const):
(WebCore::IDBRequest::setSource):
(WebCore::IDBRequest::setVersionChangeTransaction):
(WebCore::IDBRequest::transaction const):
(WebCore::IDBRequest::sourceObjectStoreIdentifier const):
(WebCore::IDBRequest::sourceIndexIdentifier const):
(WebCore::IDBRequest::requestedObjectStoreRecordType const):
(WebCore::IDBRequest::requestedIndexRecordType const):
(WebCore::IDBRequest::eventTargetInterface const):
(WebCore::IDBRequest::activeDOMObjectName const):
(WebCore::IDBRequest::hasPendingActivity const):
(WebCore::IDBRequest::stop):
(WebCore::IDBRequest::enqueueEvent):
(WebCore::IDBRequest::dispatchEvent):
(WebCore::IDBRequest::uncaughtExceptionInEventHandler):
(WebCore::IDBRequest::setResult):
(WebCore::IDBRequest::setResultToStructuredClone):
(WebCore::IDBRequest::setResultToUndefined):
(WebCore::IDBRequest::resultCursor):
(WebCore::IDBRequest::willIterateCursor):
(WebCore::IDBRequest::didOpenOrIterateCursor):
(WebCore::IDBRequest::completeRequestAndDispatchEvent):
(WebCore::IDBRequest::onError):
(WebCore::IDBRequest::onSuccess):
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::IDBTransaction):
(WebCore::IDBTransaction::~IDBTransaction):
(WebCore::IDBTransaction::objectStoreNames const):
(WebCore::IDBTransaction::db):
(WebCore::IDBTransaction::error const):
(WebCore::IDBTransaction::objectStore):
(WebCore::IDBTransaction::abortDueToFailedRequest):
(WebCore::IDBTransaction::transitionedToFinishing):
(WebCore::IDBTransaction::abort):
(WebCore::IDBTransaction::internalAbort):
(WebCore::IDBTransaction::abortOnServerAndCancelRequests):
(WebCore::IDBTransaction::activeDOMObjectName const):
(WebCore::IDBTransaction::hasPendingActivity const):
(WebCore::IDBTransaction::stop):
(WebCore::IDBTransaction::isActive const):
(WebCore::IDBTransaction::isFinishedOrFinishing const):
(WebCore::IDBTransaction::addRequest):
(WebCore::IDBTransaction::removeRequest):
(WebCore::IDBTransaction::scheduleOperation):
(WebCore::IDBTransaction::trySchedulePendingOperationTimer):
(WebCore::IDBTransaction::pendingOperationTimerFired):
(WebCore::IDBTransaction::operationCompletedOnServer):
(WebCore::IDBTransaction::scheduleCompletedOperationTimer):
(WebCore::IDBTransaction::completedOperationTimerFired):
(WebCore::IDBTransaction::commit):
(WebCore::IDBTransaction::commitOnServer):
(WebCore::IDBTransaction::finishAbortOrCommit):
(WebCore::IDBTransaction::didStart):
(WebCore::IDBTransaction::notifyDidAbort):
(WebCore::IDBTransaction::didAbort):
(WebCore::IDBTransaction::didCommit):
(WebCore::IDBTransaction::fireOnComplete):
(WebCore::IDBTransaction::fireOnAbort):
(WebCore::IDBTransaction::enqueueEvent):
(WebCore::IDBTransaction::dispatchEvent):
(WebCore::IDBTransaction::createObjectStore):
(WebCore::IDBTransaction::createObjectStoreOnServer):
(WebCore::IDBTransaction::didCreateObjectStoreOnServer):
(WebCore::IDBTransaction::renameObjectStore):
(WebCore::IDBTransaction::renameObjectStoreOnServer):
(WebCore::IDBTransaction::didRenameObjectStoreOnServer):
(WebCore::IDBTransaction::createIndex):
(WebCore::IDBTransaction::createIndexOnServer):
(WebCore::IDBTransaction::didCreateIndexOnServer):
(WebCore::IDBTransaction::renameIndex):
(WebCore::IDBTransaction::renameIndexOnServer):
(WebCore::IDBTransaction::didRenameIndexOnServer):
(WebCore::IDBTransaction::requestOpenCursor):
(WebCore::IDBTransaction::doRequestOpenCursor):
(WebCore::IDBTransaction::openCursorOnServer):
(WebCore::IDBTransaction::didOpenCursorOnServer):
(WebCore::IDBTransaction::iterateCursor):
(WebCore::IDBTransaction::iterateCursorOnServer):
(WebCore::IDBTransaction::didIterateCursorOnServer):
(WebCore::IDBTransaction::requestGetAllObjectStoreRecords):
(WebCore::IDBTransaction::requestGetAllIndexRecords):
(WebCore::IDBTransaction::getAllRecordsOnServer):
(WebCore::IDBTransaction::didGetAllRecordsOnServer):
(WebCore::IDBTransaction::requestGetRecord):
(WebCore::IDBTransaction::requestGetValue):
(WebCore::IDBTransaction::requestGetKey):
(WebCore::IDBTransaction::requestIndexRecord):
(WebCore::IDBTransaction::getRecordOnServer):
(WebCore::IDBTransaction::didGetRecordOnServer):
(WebCore::IDBTransaction::requestCount):
(WebCore::IDBTransaction::getCountOnServer):
(WebCore::IDBTransaction::didGetCountOnServer):
(WebCore::IDBTransaction::requestDeleteRecord):
(WebCore::IDBTransaction::deleteRecordOnServer):
(WebCore::IDBTransaction::didDeleteRecordOnServer):
(WebCore::IDBTransaction::requestClearObjectStore):
(WebCore::IDBTransaction::clearObjectStoreOnServer):
(WebCore::IDBTransaction::didClearObjectStoreOnServer):
(WebCore::IDBTransaction::requestPutOrAdd):
(WebCore::IDBTransaction::putOrAddOnServer):
(WebCore::IDBTransaction::didPutOrAddOnServer):
(WebCore::IDBTransaction::deleteObjectStore):
(WebCore::IDBTransaction::deleteObjectStoreOnServer):
(WebCore::IDBTransaction::didDeleteObjectStoreOnServer):
(WebCore::IDBTransaction::deleteIndex):
(WebCore::IDBTransaction::deleteIndexOnServer):
(WebCore::IDBTransaction::didDeleteIndexOnServer):
(WebCore::IDBTransaction::operationCompletedOnClient):
(WebCore::IDBTransaction::establishOnServer):
(WebCore::IDBTransaction::activate):
(WebCore::IDBTransaction::deactivate):
* Modules/indexeddb/client/IDBConnectionProxy.cpp:
(WebCore::IDBClient::removeItemsMatchingCurrentThread):
(WebCore::IDBClient::setMatchingItemsContextSuspended):
* Modules/indexeddb/client/TransactionOperation.h:
(WebCore::IDBClient::TransactionOperation::~TransactionOperation):
(WebCore::IDBClient::TransactionOperation::perform):
(WebCore::IDBClient::TransactionOperation::transitionToCompleteOnThisThread):
(WebCore::IDBClient::TransactionOperation::transitionToComplete):
(WebCore::IDBClient::TransactionOperation::doComplete):
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::~ActiveDOMObject):
* platform/Supplementable.h:
(WebCore::Supplementable::provideSupplement):
(WebCore::Supplementable::removeSupplement):
(WebCore::Supplementable::requireSupplement):
* platform/Timer.cpp:
(WebCore::TimerBase::~TimerBase):
(WebCore::TimerBase::start):
(WebCore::TimerBase::stop):
(WebCore::TimerBase::setNextFireTime):

Source/WTF:

* wtf/MainThread.cpp:
(WTF::canCurrentThreadAccessThreadLocalData):
(WTF::canAccessThreadLocalDataForThread): Deleted.
* wtf/MainThread.h:
* wtf/cocoa/MainThreadCocoa.mm:
(WTF::canCurrentThreadAccessThreadLocalData):
(WTF::canAccessThreadLocalDataForThread): Deleted.

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

18 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/MainThread.cpp
Source/WTF/wtf/MainThread.h
Source/WTF/wtf/cocoa/MainThreadCocoa.mm
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBActiveDOMObject.h
Source/WebCore/Modules/indexeddb/IDBCursor.cpp
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBIndex.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp
Source/WebCore/Modules/indexeddb/client/TransactionOperation.h
Source/WebCore/dom/ActiveDOMObject.cpp
Source/WebCore/platform/Supplementable.h
Source/WebCore/platform/Timer.cpp

index fd24792..f27de7a 100644 (file)
@@ -1,3 +1,18 @@
+2019-11-19  Yusuke Suzuki  <ysuzuki@apple.com>
+
+        [IndexedDB] IndexedDB's threading assertion should respect Web thread
+        https://bugs.webkit.org/show_bug.cgi?id=204346
+
+        Reviewed by Daniel Bates.
+
+        * wtf/MainThread.cpp:
+        (WTF::canCurrentThreadAccessThreadLocalData):
+        (WTF::canAccessThreadLocalDataForThread): Deleted.
+        * wtf/MainThread.h:
+        * wtf/cocoa/MainThreadCocoa.mm:
+        (WTF::canCurrentThreadAccessThreadLocalData):
+        (WTF::canAccessThreadLocalDataForThread): Deleted.
+
 2019-11-18  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Remove self-defined C++14 features in StdLibExtras.h
index bc8cfc7..4994575 100644 (file)
@@ -62,7 +62,7 @@ void initializeMainThread()
 }
 
 #if !USE(WEB_THREAD)
-bool canAccessThreadLocalDataForThread(Thread& thread)
+bool canCurrentThreadAccessThreadLocalData(Thread& thread)
 {
     return &thread == &Thread::current();
 }
index 9c3f79f..eba2ca1 100644 (file)
@@ -54,7 +54,7 @@ WTF_EXPORT_PRIVATE void setMainThreadCallbacksPaused(bool paused);
 
 WTF_EXPORT_PRIVATE bool isMainThread();
 
-WTF_EXPORT_PRIVATE bool canAccessThreadLocalDataForThread(Thread&);
+WTF_EXPORT_PRIVATE bool canCurrentThreadAccessThreadLocalData(Thread&);
 
 WTF_EXPORT_PRIVATE bool isMainRunLoop();
 WTF_EXPORT_PRIVATE void callOnMainRunLoop(Function<void()>&&);
@@ -83,7 +83,7 @@ using WTF::callOnMainThread;
 using WTF::callOnMainThreadAndWait;
 using WTF::callOnMainRunLoop;
 using WTF::callOnMainRunLoopAndWait;
-using WTF::canAccessThreadLocalDataForThread;
+using WTF::canCurrentThreadAccessThreadLocalData;
 using WTF::isMainThread;
 using WTF::isMainThreadOrGCThread;
 using WTF::isUIThread;
index 27eb00d..746468d 100644 (file)
@@ -199,7 +199,7 @@ void initializeWebThread()
     });
 }
 
-bool canAccessThreadLocalDataForThread(Thread& thread)
+bool canCurrentThreadAccessThreadLocalData(Thread& thread)
 {
     Thread& currentThread = Thread::current();
     if (&thread == &currentThread)
index bd73c0e..e88deaa 100644 (file)
@@ -1,3 +1,248 @@
+2019-11-19  Yusuke Suzuki  <ysuzuki@apple.com>
+
+        [IndexedDB] IndexedDB's threading assertion should respect Web thread
+        https://bugs.webkit.org/show_bug.cgi?id=204346
+
+        Reviewed by Daniel Bates.
+
+        Previously we are doing pointer-comparison between Thread::current() and origin-thread to
+        assert the thread affinity. But this does not respect Web thread: we can create an object
+        in Web Thread, and touch it in the main thread if web thread lock is correctly held.
+
+        This patch replaces pointer-comparison with WTF::canAccessThreadLocalDataForThread helper
+        function which appropriately respects Web thread status.
+
+        No behavior change.
+
+        * Modules/indexeddb/IDBActiveDOMObject.h:
+        (WebCore::IDBActiveDOMObject::performCallbackOnOriginThread):
+        (WebCore::IDBActiveDOMObject::callFunctionOnOriginThread):
+        * Modules/indexeddb/IDBCursor.cpp:
+        (WebCore::IDBCursor::IDBCursor):
+        (WebCore::IDBCursor::~IDBCursor):
+        (WebCore::IDBCursor::sourcesDeleted const):
+        (WebCore::IDBCursor::transaction const):
+        (WebCore::IDBCursor::update):
+        (WebCore::IDBCursor::advance):
+        (WebCore::IDBCursor::continueFunction):
+        (WebCore::IDBCursor::uncheckedIterateCursor):
+        (WebCore::IDBCursor::deleteFunction):
+        (WebCore::IDBCursor::setGetResult):
+        * Modules/indexeddb/IDBDatabase.cpp:
+        (WebCore::IDBDatabase::~IDBDatabase):
+        (WebCore::IDBDatabase::hasPendingActivity const):
+        (WebCore::IDBDatabase::name const):
+        (WebCore::IDBDatabase::version const):
+        (WebCore::IDBDatabase::objectStoreNames const):
+        (WebCore::IDBDatabase::renameObjectStore):
+        (WebCore::IDBDatabase::renameIndex):
+        (WebCore::IDBDatabase::createObjectStore):
+        (WebCore::IDBDatabase::transaction):
+        (WebCore::IDBDatabase::deleteObjectStore):
+        (WebCore::IDBDatabase::close):
+        (WebCore::IDBDatabase::connectionToServerLost):
+        (WebCore::IDBDatabase::maybeCloseInServer):
+        (WebCore::IDBDatabase::activeDOMObjectName const):
+        (WebCore::IDBDatabase::stop):
+        (WebCore::IDBDatabase::startVersionChangeTransaction):
+        (WebCore::IDBDatabase::didStartTransaction):
+        (WebCore::IDBDatabase::willCommitTransaction):
+        (WebCore::IDBDatabase::didCommitTransaction):
+        (WebCore::IDBDatabase::willAbortTransaction):
+        (WebCore::IDBDatabase::didAbortTransaction):
+        (WebCore::IDBDatabase::didCommitOrAbortTransaction):
+        (WebCore::IDBDatabase::fireVersionChangeEvent):
+        (WebCore::IDBDatabase::dispatchEvent):
+        (WebCore::IDBDatabase::didCreateIndexInfo):
+        (WebCore::IDBDatabase::didDeleteIndexInfo):
+        * Modules/indexeddb/IDBIndex.cpp:
+        (WebCore::IDBIndex::IDBIndex):
+        (WebCore::IDBIndex::~IDBIndex):
+        (WebCore::IDBIndex::name const):
+        (WebCore::IDBIndex::setName):
+        (WebCore::IDBIndex::objectStore):
+        (WebCore::IDBIndex::keyPath const):
+        (WebCore::IDBIndex::unique const):
+        (WebCore::IDBIndex::multiEntry const):
+        (WebCore::IDBIndex::rollbackInfoForVersionChangeAbort):
+        (WebCore::IDBIndex::doOpenCursor):
+        (WebCore::IDBIndex::doOpenKeyCursor):
+        (WebCore::IDBIndex::doCount):
+        (WebCore::IDBIndex::doGet):
+        (WebCore::IDBIndex::doGetKey):
+        (WebCore::IDBIndex::doGetAll):
+        (WebCore::IDBIndex::doGetAllKeys):
+        (WebCore::IDBIndex::markAsDeleted):
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::IDBObjectStore):
+        (WebCore::IDBObjectStore::~IDBObjectStore):
+        (WebCore::IDBObjectStore::name const):
+        (WebCore::IDBObjectStore::setName):
+        (WebCore::IDBObjectStore::keyPath const):
+        (WebCore::IDBObjectStore::indexNames const):
+        (WebCore::IDBObjectStore::transaction):
+        (WebCore::IDBObjectStore::autoIncrement const):
+        (WebCore::IDBObjectStore::doOpenCursor):
+        (WebCore::IDBObjectStore::doOpenKeyCursor):
+        (WebCore::IDBObjectStore::get):
+        (WebCore::IDBObjectStore::getKey):
+        (WebCore::IDBObjectStore::putOrAdd):
+        (WebCore::IDBObjectStore::doDelete):
+        (WebCore::IDBObjectStore::clear):
+        (WebCore::IDBObjectStore::createIndex):
+        (WebCore::IDBObjectStore::index):
+        (WebCore::IDBObjectStore::deleteIndex):
+        (WebCore::IDBObjectStore::doCount):
+        (WebCore::IDBObjectStore::doGetAll):
+        (WebCore::IDBObjectStore::doGetAllKeys):
+        (WebCore::IDBObjectStore::markAsDeleted):
+        (WebCore::IDBObjectStore::rollbackForVersionChangeAbort):
+        * Modules/indexeddb/IDBOpenDBRequest.cpp:
+        (WebCore::IDBOpenDBRequest::~IDBOpenDBRequest):
+        (WebCore::IDBOpenDBRequest::onError):
+        (WebCore::IDBOpenDBRequest::versionChangeTransactionDidFinish):
+        (WebCore::IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit):
+        (WebCore::IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion):
+        (WebCore::IDBOpenDBRequest::dispatchEvent):
+        (WebCore::IDBOpenDBRequest::onSuccess):
+        (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
+        (WebCore::IDBOpenDBRequest::onDeleteDatabaseSuccess):
+        (WebCore::IDBOpenDBRequest::requestCompleted):
+        (WebCore::IDBOpenDBRequest::requestBlocked):
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::~IDBRequest):
+        (WebCore:: const):
+        (WebCore::IDBRequest::setSource):
+        (WebCore::IDBRequest::setVersionChangeTransaction):
+        (WebCore::IDBRequest::transaction const):
+        (WebCore::IDBRequest::sourceObjectStoreIdentifier const):
+        (WebCore::IDBRequest::sourceIndexIdentifier const):
+        (WebCore::IDBRequest::requestedObjectStoreRecordType const):
+        (WebCore::IDBRequest::requestedIndexRecordType const):
+        (WebCore::IDBRequest::eventTargetInterface const):
+        (WebCore::IDBRequest::activeDOMObjectName const):
+        (WebCore::IDBRequest::hasPendingActivity const):
+        (WebCore::IDBRequest::stop):
+        (WebCore::IDBRequest::enqueueEvent):
+        (WebCore::IDBRequest::dispatchEvent):
+        (WebCore::IDBRequest::uncaughtExceptionInEventHandler):
+        (WebCore::IDBRequest::setResult):
+        (WebCore::IDBRequest::setResultToStructuredClone):
+        (WebCore::IDBRequest::setResultToUndefined):
+        (WebCore::IDBRequest::resultCursor):
+        (WebCore::IDBRequest::willIterateCursor):
+        (WebCore::IDBRequest::didOpenOrIterateCursor):
+        (WebCore::IDBRequest::completeRequestAndDispatchEvent):
+        (WebCore::IDBRequest::onError):
+        (WebCore::IDBRequest::onSuccess):
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::IDBTransaction):
+        (WebCore::IDBTransaction::~IDBTransaction):
+        (WebCore::IDBTransaction::objectStoreNames const):
+        (WebCore::IDBTransaction::db):
+        (WebCore::IDBTransaction::error const):
+        (WebCore::IDBTransaction::objectStore):
+        (WebCore::IDBTransaction::abortDueToFailedRequest):
+        (WebCore::IDBTransaction::transitionedToFinishing):
+        (WebCore::IDBTransaction::abort):
+        (WebCore::IDBTransaction::internalAbort):
+        (WebCore::IDBTransaction::abortOnServerAndCancelRequests):
+        (WebCore::IDBTransaction::activeDOMObjectName const):
+        (WebCore::IDBTransaction::hasPendingActivity const):
+        (WebCore::IDBTransaction::stop):
+        (WebCore::IDBTransaction::isActive const):
+        (WebCore::IDBTransaction::isFinishedOrFinishing const):
+        (WebCore::IDBTransaction::addRequest):
+        (WebCore::IDBTransaction::removeRequest):
+        (WebCore::IDBTransaction::scheduleOperation):
+        (WebCore::IDBTransaction::trySchedulePendingOperationTimer):
+        (WebCore::IDBTransaction::pendingOperationTimerFired):
+        (WebCore::IDBTransaction::operationCompletedOnServer):
+        (WebCore::IDBTransaction::scheduleCompletedOperationTimer):
+        (WebCore::IDBTransaction::completedOperationTimerFired):
+        (WebCore::IDBTransaction::commit):
+        (WebCore::IDBTransaction::commitOnServer):
+        (WebCore::IDBTransaction::finishAbortOrCommit):
+        (WebCore::IDBTransaction::didStart):
+        (WebCore::IDBTransaction::notifyDidAbort):
+        (WebCore::IDBTransaction::didAbort):
+        (WebCore::IDBTransaction::didCommit):
+        (WebCore::IDBTransaction::fireOnComplete):
+        (WebCore::IDBTransaction::fireOnAbort):
+        (WebCore::IDBTransaction::enqueueEvent):
+        (WebCore::IDBTransaction::dispatchEvent):
+        (WebCore::IDBTransaction::createObjectStore):
+        (WebCore::IDBTransaction::createObjectStoreOnServer):
+        (WebCore::IDBTransaction::didCreateObjectStoreOnServer):
+        (WebCore::IDBTransaction::renameObjectStore):
+        (WebCore::IDBTransaction::renameObjectStoreOnServer):
+        (WebCore::IDBTransaction::didRenameObjectStoreOnServer):
+        (WebCore::IDBTransaction::createIndex):
+        (WebCore::IDBTransaction::createIndexOnServer):
+        (WebCore::IDBTransaction::didCreateIndexOnServer):
+        (WebCore::IDBTransaction::renameIndex):
+        (WebCore::IDBTransaction::renameIndexOnServer):
+        (WebCore::IDBTransaction::didRenameIndexOnServer):
+        (WebCore::IDBTransaction::requestOpenCursor):
+        (WebCore::IDBTransaction::doRequestOpenCursor):
+        (WebCore::IDBTransaction::openCursorOnServer):
+        (WebCore::IDBTransaction::didOpenCursorOnServer):
+        (WebCore::IDBTransaction::iterateCursor):
+        (WebCore::IDBTransaction::iterateCursorOnServer):
+        (WebCore::IDBTransaction::didIterateCursorOnServer):
+        (WebCore::IDBTransaction::requestGetAllObjectStoreRecords):
+        (WebCore::IDBTransaction::requestGetAllIndexRecords):
+        (WebCore::IDBTransaction::getAllRecordsOnServer):
+        (WebCore::IDBTransaction::didGetAllRecordsOnServer):
+        (WebCore::IDBTransaction::requestGetRecord):
+        (WebCore::IDBTransaction::requestGetValue):
+        (WebCore::IDBTransaction::requestGetKey):
+        (WebCore::IDBTransaction::requestIndexRecord):
+        (WebCore::IDBTransaction::getRecordOnServer):
+        (WebCore::IDBTransaction::didGetRecordOnServer):
+        (WebCore::IDBTransaction::requestCount):
+        (WebCore::IDBTransaction::getCountOnServer):
+        (WebCore::IDBTransaction::didGetCountOnServer):
+        (WebCore::IDBTransaction::requestDeleteRecord):
+        (WebCore::IDBTransaction::deleteRecordOnServer):
+        (WebCore::IDBTransaction::didDeleteRecordOnServer):
+        (WebCore::IDBTransaction::requestClearObjectStore):
+        (WebCore::IDBTransaction::clearObjectStoreOnServer):
+        (WebCore::IDBTransaction::didClearObjectStoreOnServer):
+        (WebCore::IDBTransaction::requestPutOrAdd):
+        (WebCore::IDBTransaction::putOrAddOnServer):
+        (WebCore::IDBTransaction::didPutOrAddOnServer):
+        (WebCore::IDBTransaction::deleteObjectStore):
+        (WebCore::IDBTransaction::deleteObjectStoreOnServer):
+        (WebCore::IDBTransaction::didDeleteObjectStoreOnServer):
+        (WebCore::IDBTransaction::deleteIndex):
+        (WebCore::IDBTransaction::deleteIndexOnServer):
+        (WebCore::IDBTransaction::didDeleteIndexOnServer):
+        (WebCore::IDBTransaction::operationCompletedOnClient):
+        (WebCore::IDBTransaction::establishOnServer):
+        (WebCore::IDBTransaction::activate):
+        (WebCore::IDBTransaction::deactivate):
+        * Modules/indexeddb/client/IDBConnectionProxy.cpp:
+        (WebCore::IDBClient::removeItemsMatchingCurrentThread):
+        (WebCore::IDBClient::setMatchingItemsContextSuspended):
+        * Modules/indexeddb/client/TransactionOperation.h:
+        (WebCore::IDBClient::TransactionOperation::~TransactionOperation):
+        (WebCore::IDBClient::TransactionOperation::perform):
+        (WebCore::IDBClient::TransactionOperation::transitionToCompleteOnThisThread):
+        (WebCore::IDBClient::TransactionOperation::transitionToComplete):
+        (WebCore::IDBClient::TransactionOperation::doComplete):
+        * dom/ActiveDOMObject.cpp:
+        (WebCore::ActiveDOMObject::~ActiveDOMObject):
+        * platform/Supplementable.h:
+        (WebCore::Supplementable::provideSupplement):
+        (WebCore::Supplementable::removeSupplement):
+        (WebCore::Supplementable::requireSupplement):
+        * platform/Timer.cpp:
+        (WebCore::TimerBase::~TimerBase):
+        (WebCore::TimerBase::start):
+        (WebCore::TimerBase::stop):
+        (WebCore::TimerBase::setNextFireTime):
+
 2019-11-19  John Wilander  <wilander@apple.com>
 
         Resource Load Statistics: Count third-party script loads under top frame
index 2b42c06..17842e0 100644 (file)
@@ -38,7 +38,7 @@ public:
     Thread& originThread() const { return m_originThread.get(); }
 
     void contextDestroyed() final {
-        ASSERT(m_originThread.ptr() == &Thread::current());
+        ASSERT(canCurrentThreadAccessThreadLocalData(m_originThread.get()));
 
         Locker<Lock> lock(m_scriptExecutionContextLock);
         ActiveDOMObject::contextDestroyed();
@@ -49,7 +49,7 @@ public:
     {
         ASSERT(&originThread() == &object.originThread());
 
-        if (&object.originThread() == &Thread::current()) {
+        if (canCurrentThreadAccessThreadLocalData(object.originThread())) {
             (object.*method)(arguments...);
             return;
         }
@@ -65,7 +65,7 @@ public:
 
     void callFunctionOnOriginThread(WTF::Function<void ()>&& function)
     {
-        if (&originThread() == &Thread::current()) {
+        if (canCurrentThreadAccessThreadLocalData(originThread())) {
             function();
             return;
         }
index 8771022..368edc2 100644 (file)
@@ -62,24 +62,24 @@ IDBCursor::IDBCursor(IDBObjectStore& objectStore, const IDBCursorInfo& info)
     : m_info(info)
     , m_source(&objectStore)
 {
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 }
 
 IDBCursor::IDBCursor(IDBIndex& index, const IDBCursorInfo& info)
     : m_info(info)
     , m_source(&index)
 {
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 }
 
 IDBCursor::~IDBCursor()
 {
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 }
 
 bool IDBCursor::sourcesDeleted() const
 {
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 
     return WTF::switchOn(m_source,
         [] (const RefPtr<IDBObjectStore>& objectStore) { return objectStore->isDeleted(); },
@@ -97,14 +97,14 @@ IDBObjectStore& IDBCursor::effectiveObjectStore() const
 
 IDBTransaction& IDBCursor::transaction() const
 {
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
     return effectiveObjectStore().transaction();
 }
 
 ExceptionOr<Ref<IDBRequest>> IDBCursor::update(JSGlobalObject& state, JSValue value)
 {
     LOG(IndexedDB, "IDBCursor::update");
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 
     if (sourcesDeleted())
         return Exception { InvalidStateError, "Failed to execute 'update' on 'IDBCursor': The cursor's source or effective object store has been deleted."_s };
@@ -144,7 +144,7 @@ ExceptionOr<Ref<IDBRequest>> IDBCursor::update(JSGlobalObject& state, JSValue va
 ExceptionOr<void> IDBCursor::advance(unsigned count)
 {
     LOG(IndexedDB, "IDBCursor::advance");
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 
     if (!m_request)
         return Exception { InvalidStateError };
@@ -232,7 +232,7 @@ ExceptionOr<void> IDBCursor::continueFunction(JSGlobalObject& execState, JSValue
 ExceptionOr<void> IDBCursor::continueFunction(const IDBKeyData& key)
 {
     LOG(IndexedDB, "IDBCursor::continueFunction (to key %s)", key.loggingString().utf8().data());
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 
     if (!m_request)
         return Exception { InvalidStateError };
@@ -267,7 +267,7 @@ ExceptionOr<void> IDBCursor::continueFunction(const IDBKeyData& key)
 void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, unsigned count)
 {
     ASSERT(m_request);
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 
     m_request->willIterateCursor(*this);
     transaction().iterateCursor(*this, { key, { }, count });
@@ -276,7 +276,7 @@ void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, unsigned count)
 void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, const IDBKeyData& primaryKey)
 {
     ASSERT(m_request);
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 
     m_request->willIterateCursor(*this);
     transaction().iterateCursor(*this, { key, primaryKey, 0 });
@@ -285,7 +285,7 @@ void IDBCursor::uncheckedIterateCursor(const IDBKeyData& key, const IDBKeyData&
 ExceptionOr<Ref<WebCore::IDBRequest>> IDBCursor::deleteFunction(JSGlobalObject& state)
 {
     LOG(IndexedDB, "IDBCursor::deleteFunction");
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 
     if (sourcesDeleted())
         return Exception { InvalidStateError, "Failed to execute 'delete' on 'IDBCursor': The cursor's source or effective object store has been deleted."_s };
@@ -315,7 +315,7 @@ ExceptionOr<Ref<WebCore::IDBRequest>> IDBCursor::deleteFunction(JSGlobalObject&
 bool IDBCursor::setGetResult(IDBRequest& request, const IDBGetResult& getResult)
 {
     LOG(IndexedDB, "IDBCursor::setGetResult - current key %s", getResult.keyData().loggingString().substring(0, 100).utf8().data());
-    ASSERT(&effectiveObjectStore().transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(effectiveObjectStore().transaction().database().originThread()));
 
     auto* context = request.scriptExecutionContext();
     if (!context)
index c663f87..db649b9 100644 (file)
@@ -67,7 +67,7 @@ IDBDatabase::IDBDatabase(ScriptExecutionContext& context, IDBClient::IDBConnecti
 
 IDBDatabase::~IDBDatabase()
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (!m_closedInServer)
         m_connectionProxy->databaseConnectionClosed(*this);
@@ -77,7 +77,7 @@ IDBDatabase::~IDBDatabase()
 
 bool IDBDatabase::hasPendingActivity() const
 {
-    ASSERT(&originThread() == &Thread::current() || Thread::mayBeGCThread());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()) || Thread::mayBeGCThread());
 
     if (m_closedInServer || isContextStopped())
         return false;
@@ -90,19 +90,19 @@ bool IDBDatabase::hasPendingActivity() const
 
 const String IDBDatabase::name() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     return m_info.name();
 }
 
 uint64_t IDBDatabase::version() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     return m_info.version();
 }
 
 Ref<DOMStringList> IDBDatabase::objectStoreNames() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto objectStoreNames = DOMStringList::create();
     for (auto& name : m_info.objectStoreNames())
@@ -113,7 +113,7 @@ Ref<DOMStringList> IDBDatabase::objectStoreNames() const
 
 void IDBDatabase::renameObjectStore(IDBObjectStore& objectStore, const String& newName)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(m_versionChangeTransaction);
     ASSERT(m_info.hasObjectStore(objectStore.info().name()));
 
@@ -124,7 +124,7 @@ void IDBDatabase::renameObjectStore(IDBObjectStore& objectStore, const String& n
 
 void IDBDatabase::renameIndex(IDBIndex& index, const String& newName)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(m_versionChangeTransaction);
     ASSERT(m_info.hasObjectStore(index.objectStore().info().name()));
     ASSERT(m_info.infoForExistingObjectStore(index.objectStore().info().name())->hasIndex(index.info().name()));
@@ -138,7 +138,7 @@ ExceptionOr<Ref<IDBObjectStore>> IDBDatabase::createObjectStore(const String& na
 {
     LOG(IndexedDB, "IDBDatabase::createObjectStore - (%s %s)", m_info.name().utf8().data(), name.utf8().data());
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(!m_versionChangeTransaction || m_versionChangeTransaction->isVersionChange());
 
     if (!m_versionChangeTransaction)
@@ -168,7 +168,7 @@ ExceptionOr<Ref<IDBTransaction>> IDBDatabase::transaction(StringOrVectorOfString
 {
     LOG(IndexedDB, "IDBDatabase::transaction");
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (m_versionChangeTransaction && !m_versionChangeTransaction->isFinishedOrFinishing())
         return Exception { InvalidStateError, "Failed to execute 'transaction' on 'IDBDatabase': A version change transaction is running."_s };
@@ -218,7 +218,7 @@ ExceptionOr<void> IDBDatabase::deleteObjectStore(const String& objectStoreName)
 {
     LOG(IndexedDB, "IDBDatabase::deleteObjectStore");
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (!m_versionChangeTransaction)
         return Exception { InvalidStateError, "Failed to execute 'deleteObjectStore' on 'IDBDatabase': The database is not running a version change transaction."_s };
@@ -239,7 +239,7 @@ void IDBDatabase::close()
 {
     LOG(IndexedDB, "IDBDatabase::close - %" PRIu64, m_databaseConnectionIdentifier);
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (!m_closePending) {
         m_closePending = true;
@@ -262,7 +262,7 @@ void IDBDatabase::connectionToServerLost(const IDBError& error)
 {
     LOG(IndexedDB, "IDBDatabase::connectionToServerLost - %" PRIu64, m_databaseConnectionIdentifier);
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     m_closePending = true;
     m_closedInServer = true;
@@ -292,7 +292,7 @@ void IDBDatabase::maybeCloseInServer()
 {
     LOG(IndexedDB, "IDBDatabase::maybeCloseInServer - %" PRIu64, m_databaseConnectionIdentifier);
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (m_closedInServer)
         return;
@@ -309,7 +309,7 @@ void IDBDatabase::maybeCloseInServer()
 
 const char* IDBDatabase::activeDOMObjectName() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     return "IDBDatabase";
 }
 
@@ -317,7 +317,7 @@ void IDBDatabase::stop()
 {
     LOG(IndexedDB, "IDBDatabase::stop - %" PRIu64, m_databaseConnectionIdentifier);
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     removeAllEventListeners();
 
@@ -340,7 +340,7 @@ Ref<IDBTransaction> IDBDatabase::startVersionChangeTransaction(const IDBTransact
 {
     LOG(IndexedDB, "IDBDatabase::startVersionChangeTransaction %s", info.identifier().loggingString().utf8().data());
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(!m_versionChangeTransaction);
     ASSERT(info.mode() == IDBTransactionMode::Versionchange);
     ASSERT(!m_closePending);
@@ -358,7 +358,7 @@ void IDBDatabase::didStartTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::didStartTransaction %s", transaction.info().identifier().loggingString().utf8().data());
     ASSERT(!m_versionChangeTransaction);
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     // It is possible for the client to have aborted a transaction before the server replies back that it has started.
     if (m_abortingTransactions.contains(transaction.info().identifier()))
@@ -371,7 +371,7 @@ void IDBDatabase::willCommitTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::willCommitTransaction %s", transaction.info().identifier().loggingString().utf8().data());
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto refTransaction = m_activeTransactions.take(transaction.info().identifier());
     ASSERT(refTransaction);
@@ -382,7 +382,7 @@ void IDBDatabase::didCommitTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::didCommitTransaction %s", transaction.info().identifier().loggingString().utf8().data());
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (m_versionChangeTransaction == &transaction)
         m_info.setVersion(transaction.info().newVersion());
@@ -394,7 +394,7 @@ void IDBDatabase::willAbortTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::willAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto refTransaction = m_activeTransactions.take(transaction.info().identifier());
     if (!refTransaction)
@@ -414,7 +414,7 @@ void IDBDatabase::didAbortTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::didAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (transaction.isVersionChange()) {
         ASSERT(transaction.originalDatabaseInfo());
@@ -430,7 +430,7 @@ void IDBDatabase::didCommitOrAbortTransaction(IDBTransaction& transaction)
 {
     LOG(IndexedDB, "IDBDatabase::didCommitOrAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (m_versionChangeTransaction == &transaction)
         m_versionChangeTransaction = nullptr;
@@ -460,7 +460,7 @@ void IDBDatabase::fireVersionChangeEvent(const IDBResourceIdentifier& requestIde
     uint64_t currentVersion = m_info.version();
     LOG(IndexedDB, "IDBDatabase::fireVersionChangeEvent - current version %" PRIu64 ", requested version %" PRIu64 ", connection %" PRIu64 " (%p)", currentVersion, requestedVersion, m_databaseConnectionIdentifier, this);
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (!scriptExecutionContext() || m_closePending) {
         connectionProxy().didFireVersionChangeEvent(m_databaseConnectionIdentifier, requestIdentifier);
@@ -475,7 +475,7 @@ void IDBDatabase::fireVersionChangeEvent(const IDBResourceIdentifier& requestIde
 void IDBDatabase::dispatchEvent(Event& event)
 {
     LOG(IndexedDB, "IDBDatabase::dispatchEvent (%" PRIu64 ") (%p)", m_databaseConnectionIdentifier, this);
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto protectedThis = makeRef(*this);
 
@@ -487,7 +487,7 @@ void IDBDatabase::dispatchEvent(Event& event)
 
 void IDBDatabase::didCreateIndexInfo(const IDBIndexInfo& info)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto* objectStore = m_info.infoForExistingObjectStore(info.objectStoreIdentifier());
     ASSERT(objectStore);
@@ -496,7 +496,7 @@ void IDBDatabase::didCreateIndexInfo(const IDBIndexInfo& info)
 
 void IDBDatabase::didDeleteIndexInfo(const IDBIndexInfo& info)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto* objectStore = m_info.infoForExistingObjectStore(info.objectStoreIdentifier());
     ASSERT(objectStore);
index ea42702..74b0f50 100644 (file)
@@ -47,14 +47,14 @@ IDBIndex::IDBIndex(ScriptExecutionContext& context, const IDBIndexInfo& info, ID
     , m_originalInfo(info)
     , m_objectStore(objectStore)
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     suspendIfNeeded();
 }
 
 IDBIndex::~IDBIndex()
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 }
 
 const char* IDBIndex::activeDOMObjectName() const
@@ -69,13 +69,13 @@ bool IDBIndex::hasPendingActivity() const
 
 const String& IDBIndex::name() const
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
     return m_info.name();
 }
 
 ExceptionOr<void> IDBIndex::setName(const String& name)
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed set property 'name' on 'IDBIndex': The index has been deleted."_s };
@@ -103,31 +103,31 @@ ExceptionOr<void> IDBIndex::setName(const String& name)
 
 IDBObjectStore& IDBIndex::objectStore()
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
     return m_objectStore;
 }
 
 const IDBKeyPath& IDBIndex::keyPath() const
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
     return m_info.keyPath();
 }
 
 bool IDBIndex::unique() const
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
     return m_info.unique();
 }
 
 bool IDBIndex::multiEntry() const
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
     return m_info.multiEntry();
 }
 
 void IDBIndex::rollbackInfoForVersionChangeAbort()
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     // Only rollback to the original info if this index still exists in the rolled-back database info.
     auto* objectStoreInfo = m_objectStore.transaction().database().info().infoForExistingObjectStore(m_objectStore.info().identifier());
@@ -146,7 +146,7 @@ void IDBIndex::rollbackInfoForVersionChangeAbort()
 ExceptionOr<Ref<IDBRequest>> IDBIndex::doOpenCursor(JSGlobalObject& execState, IDBCursorDirection direction, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function)
 {
     LOG(IndexedDB, "IDBIndex::openCursor");
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, "Failed to execute 'openCursor' on 'IDBIndex': The index or its object store has been deleted."_s };
@@ -189,7 +189,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(JSGlobalObject& execState, JSV
 ExceptionOr<Ref<IDBRequest>> IDBIndex::doOpenKeyCursor(JSGlobalObject& execState, IDBCursorDirection direction, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function)
 {
     LOG(IndexedDB, "IDBIndex::openKeyCursor");
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, "Failed to execute 'openKeyCursor' on 'IDBIndex': The index or its object store has been deleted."_s };
@@ -243,7 +243,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::count(JSGlobalObject& execState, JSValue
 
 ExceptionOr<Ref<IDBRequest>> IDBIndex::doCount(JSGlobalObject& execState, const IDBKeyRangeData& range)
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, "Failed to execute 'count' on 'IDBIndex': The index or its object store has been deleted."_s };
@@ -278,7 +278,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::get(JSGlobalObject& execState, JSValue ke
 
 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGet(JSGlobalObject& execState, ExceptionOr<IDBKeyRangeData> range)
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, "Failed to execute 'get' on 'IDBIndex': The index or its object store has been deleted."_s };
@@ -317,7 +317,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::getKey(JSGlobalObject& execState, JSValue
 
 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGetKey(JSGlobalObject& execState, ExceptionOr<IDBKeyRangeData> range)
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, "Failed to execute 'getKey' on 'IDBIndex': The index or its object store has been deleted."_s };
@@ -339,7 +339,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::doGetKey(JSGlobalObject& execState, Excep
 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGetAll(JSGlobalObject& execState, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function)
 {
     LOG(IndexedDB, "IDBIndex::getAll");
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, "Failed to execute 'getAll' on 'IDBIndex': The index or its object store has been deleted."_s };
@@ -376,7 +376,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::getAll(JSGlobalObject& execState, JSValue
 ExceptionOr<Ref<IDBRequest>> IDBIndex::doGetAllKeys(JSGlobalObject& execState, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function)
 {
     LOG(IndexedDB, "IDBIndex::getAllKeys");
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     if (m_deleted || m_objectStore.isDeleted())
         return Exception { InvalidStateError, "Failed to execute 'getAllKeys' on 'IDBIndex': The index or its object store has been deleted."_s };
@@ -412,7 +412,7 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::getAllKeys(JSGlobalObject& execState, JSV
 
 void IDBIndex::markAsDeleted()
 {
-    ASSERT(&m_objectStore.transaction().database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread()));
 
     ASSERT(!m_deleted);
     m_deleted = true;
index 69068a4..3124434 100644 (file)
@@ -60,14 +60,14 @@ IDBObjectStore::IDBObjectStore(ScriptExecutionContext& context, const IDBObjectS
     , m_originalInfo(info)
     , m_transaction(transaction)
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     suspendIfNeeded();
 }
 
 IDBObjectStore::~IDBObjectStore()
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 }
 
 const char* IDBObjectStore::activeDOMObjectName() const
@@ -82,13 +82,13 @@ bool IDBObjectStore::hasPendingActivity() const
 
 const String& IDBObjectStore::name() const
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
     return m_info.name();
 }
 
 ExceptionOr<void> IDBObjectStore::setName(const String& name)
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed set property 'name' on 'IDBObjectStore': The object store has been deleted."_s };
@@ -113,13 +113,13 @@ ExceptionOr<void> IDBObjectStore::setName(const String& name)
 
 const Optional<IDBKeyPath>& IDBObjectStore::keyPath() const
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
     return m_info.keyPath();
 }
 
 Ref<DOMStringList> IDBObjectStore::indexNames() const
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     auto indexNames = DOMStringList::create();
 
@@ -134,20 +134,20 @@ Ref<DOMStringList> IDBObjectStore::indexNames() const
 
 IDBTransaction& IDBObjectStore::transaction()
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
     return m_transaction;
 }
 
 bool IDBObjectStore::autoIncrement() const
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
     return m_info.autoIncrement();
 }
 
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doOpenCursor(JSGlobalObject& execState, IDBCursorDirection direction, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function)
 {
     LOG(IndexedDB, "IDBObjectStore::openCursor");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed to execute 'openCursor' on 'IDBObjectStore': The object store has been deleted."_s };
@@ -185,7 +185,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(JSGlobalObject& execStat
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doOpenKeyCursor(JSGlobalObject& execState, IDBCursorDirection direction, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function)
 {
     LOG(IndexedDB, "IDBObjectStore::openKeyCursor");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed to execute 'openKeyCursor' on 'IDBObjectStore': The object store has been deleted."_s };
@@ -223,7 +223,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(JSGlobalObject& execS
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::get(JSGlobalObject& execState, JSValue key)
 {
     LOG(IndexedDB, "IDBObjectStore::get");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed to execute 'get' on 'IDBObjectStore': The object store has been deleted."_s };
@@ -241,7 +241,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::get(JSGlobalObject& execState, JSVa
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::get(JSGlobalObject& execState, IDBKeyRange* keyRange)
 {
     LOG(IndexedDB, "IDBObjectStore::get");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed to execute 'get' on 'IDBObjectStore': The object store has been deleted."_s };
@@ -259,7 +259,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::get(JSGlobalObject& execState, IDBK
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getKey(JSGlobalObject& execState, JSValue key)
 {
     LOG(IndexedDB, "IDBObjectStore::getKey");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed to execute 'getKey' on 'IDBObjectStore': The object store has been deleted."_s };
@@ -277,7 +277,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getKey(JSGlobalObject& execState, J
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getKey(JSGlobalObject& execState, IDBKeyRange* keyRange)
 {
     LOG(IndexedDB, "IDBObjectStore::getKey");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed to execute 'getKey' on 'IDBObjectStore': The object store has been deleted."_s };
@@ -319,7 +319,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::putOrAdd(JSGlobalObject& state, JSV
     auto scope = DECLARE_CATCH_SCOPE(vm);
 
     LOG(IndexedDB, "IDBObjectStore::putOrAdd");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     auto context = scriptExecutionContextFromExecState(&state);
     if (!context)
@@ -389,7 +389,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::deleteFunction(JSGlobalObject& exec
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doDelete(JSGlobalObject& execState, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function)
 {
     LOG(IndexedDB, "IDBObjectStore::deleteFunction");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
     // the exception for an object store being deleted.
@@ -429,7 +429,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::deleteFunction(JSGlobalObject& exec
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::clear(JSGlobalObject& execState)
 {
     LOG(IndexedDB, "IDBObjectStore::clear");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
     // the exception for an object store being deleted.
@@ -451,7 +451,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::clear(JSGlobalObject& execState)
 ExceptionOr<Ref<IDBIndex>> IDBObjectStore::createIndex(JSGlobalObject&, const String& name, IDBKeyPath&& keyPath, const IndexParameters& parameters)
 {
     LOG(IndexedDB, "IDBObjectStore::createIndex %s (keyPath: %s, unique: %i, multiEntry: %i)", name.utf8().data(), loggingString(keyPath).utf8().data(), parameters.unique, parameters.multiEntry);
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (!m_transaction.isVersionChange())
         return Exception { InvalidStateError, "Failed to execute 'createIndex' on 'IDBObjectStore': The database is not running a version change transaction."_s };
@@ -492,7 +492,7 @@ ExceptionOr<Ref<IDBIndex>> IDBObjectStore::createIndex(JSGlobalObject&, const St
 ExceptionOr<Ref<IDBIndex>> IDBObjectStore::index(const String& indexName)
 {
     LOG(IndexedDB, "IDBObjectStore::index");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (!scriptExecutionContext())
         return Exception { InvalidStateError }; // FIXME: Is this code tested? Is iteven reachable?
@@ -524,7 +524,7 @@ ExceptionOr<Ref<IDBIndex>> IDBObjectStore::index(const String& indexName)
 ExceptionOr<void> IDBObjectStore::deleteIndex(const String& name)
 {
     LOG(IndexedDB, "IDBObjectStore::deleteIndex %s", name.utf8().data());
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed to execute 'deleteIndex' on 'IDBObjectStore': The object store has been deleted."_s };
@@ -576,7 +576,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::count(JSGlobalObject& execState, ID
 
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doCount(JSGlobalObject& execState, const IDBKeyRangeData& range)
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before
     // the exception for an object store being deleted.
@@ -598,7 +598,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doCount(JSGlobalObject& execState,
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doGetAll(JSGlobalObject& execState, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function)
 {
     LOG(IndexedDB, "IDBObjectStore::getAll");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed to execute 'getAll' on 'IDBObjectStore': The object store has been deleted."_s };
@@ -635,7 +635,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAll(JSGlobalObject& execState, J
 ExceptionOr<Ref<IDBRequest>> IDBObjectStore::doGetAllKeys(JSGlobalObject& execState, Optional<uint32_t> count, WTF::Function<ExceptionOr<RefPtr<IDBKeyRange>>()>&& function)
 {
     LOG(IndexedDB, "IDBObjectStore::getAllKeys");
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     if (m_deleted)
         return Exception { InvalidStateError, "Failed to execute 'getAllKeys' on 'IDBObjectStore': The object store has been deleted."_s };
@@ -671,13 +671,13 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::getAllKeys(JSGlobalObject& execStat
 
 void IDBObjectStore::markAsDeleted()
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
     m_deleted = true;
 }
 
 void IDBObjectStore::rollbackForVersionChangeAbort()
 {
-    ASSERT(&m_transaction.database().originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread()));
 
     String currentName = m_info.name();
     m_info = m_originalInfo;
index e588fae..f959cdb 100644 (file)
@@ -66,12 +66,12 @@ IDBOpenDBRequest::IDBOpenDBRequest(ScriptExecutionContext& context, IDBClient::I
 
 IDBOpenDBRequest::~IDBOpenDBRequest()
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 }
 
 void IDBOpenDBRequest::onError(const IDBResultData& data)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     m_domError = data.error().toDOMException();
     enqueueEvent(IDBRequestCompletionEvent::create(eventNames().errorEvent, Event::CanBubble::Yes, Event::IsCancelable::Yes, *this));
@@ -79,7 +79,7 @@ void IDBOpenDBRequest::onError(const IDBResultData& data)
 
 void IDBOpenDBRequest::versionChangeTransactionDidFinish()
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     // 3.3.7 "versionchange" transaction steps
     // When the transaction is finished, after firing complete/abort on the transaction, immediately set request's transaction property to null.
@@ -90,7 +90,7 @@ void IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit()
 {
     LOG(IndexedDB, "IDBOpenDBRequest::fireSuccessAfterVersionChangeCommit() - %s", resourceIdentifier().loggingString().utf8().data());
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(hasPendingActivity());
     m_transaction->addRequest(*this);
 
@@ -104,7 +104,7 @@ void IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion()
 {
     LOG(IndexedDB, "IDBOpenDBRequest::fireErrorAfterVersionChangeCompletion() - %s", resourceIdentifier().loggingString().utf8().data());
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(hasPendingActivity());
 
     IDBError idbError(AbortError);
@@ -125,7 +125,7 @@ void IDBOpenDBRequest::cancelForStop()
 
 void IDBOpenDBRequest::dispatchEvent(Event& event)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto protectedThis = makeRef(*this);
 
@@ -139,7 +139,7 @@ void IDBOpenDBRequest::onSuccess(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBOpenDBRequest::onSuccess()");
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     setResult(IDBDatabase::create(*scriptExecutionContext(), connectionProxy(), resultData));
     m_readyState = ReadyState::Done;
@@ -149,7 +149,7 @@ void IDBOpenDBRequest::onSuccess(const IDBResultData& resultData)
 
 void IDBOpenDBRequest::onUpgradeNeeded(const IDBResultData& resultData)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     Ref<IDBDatabase> database = IDBDatabase::create(*scriptExecutionContext(), connectionProxy(), resultData);
     Ref<IDBTransaction> transaction = database->startVersionChangeTransaction(resultData.transactionInfo(), *this);
@@ -172,7 +172,7 @@ void IDBOpenDBRequest::onUpgradeNeeded(const IDBResultData& resultData)
 
 void IDBOpenDBRequest::onDeleteDatabaseSuccess(const IDBResultData& resultData)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     uint64_t oldVersion = resultData.databaseInfo().version();
 
@@ -188,7 +188,7 @@ void IDBOpenDBRequest::requestCompleted(const IDBResultData& data)
 {
     LOG(IndexedDB, "IDBOpenDBRequest::requestCompleted");
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     m_isBlocked = false;
 
@@ -230,7 +230,7 @@ void IDBOpenDBRequest::requestCompleted(const IDBResultData& data)
 
 void IDBOpenDBRequest::requestBlocked(uint64_t oldVersion, uint64_t newVersion)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(!m_isBlocked);
 
     m_isBlocked = true;
index d81a056..82b373f 100644 (file)
@@ -152,7 +152,7 @@ IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBIndex& index, Indexed
 
 IDBRequest::~IDBRequest()
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     WTF::switchOn(m_result,
         [] (RefPtr<IDBCursor>& cursor) { cursor->clearRequest(); },
@@ -170,7 +170,7 @@ ExceptionOr<IDBRequest::Result> IDBRequest::result() const
 
 ExceptionOr<DOMException*> IDBRequest::error() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (!isDone())
         return Exception { InvalidStateError, "Failed to read the 'error' property from 'IDBRequest': The request has not finished."_s };
@@ -180,14 +180,14 @@ ExceptionOr<DOMException*> IDBRequest::error() const
 
 void IDBRequest::setSource(IDBCursor& cursor)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     m_source = Source { &cursor };
 }
 
 void IDBRequest::setVersionChangeTransaction(IDBTransaction& transaction)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(!m_transaction);
     ASSERT(transaction.isVersionChange());
     ASSERT(!transaction.isFinishedOrFinishing());
@@ -197,13 +197,13 @@ void IDBRequest::setVersionChangeTransaction(IDBTransaction& transaction)
 
 RefPtr<WebCore::IDBTransaction> IDBRequest::transaction() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     return m_shouldExposeTransactionToDOM ? m_transaction : nullptr;
 }
 
 uint64_t IDBRequest::sourceObjectStoreIdentifier() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (!m_source)
         return 0;
@@ -217,7 +217,7 @@ uint64_t IDBRequest::sourceObjectStoreIdentifier() const
 
 uint64_t IDBRequest::sourceIndexIdentifier() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (!m_source)
         return 0;
@@ -231,14 +231,14 @@ uint64_t IDBRequest::sourceIndexIdentifier() const
 
 IndexedDB::ObjectStoreRecordType IDBRequest::requestedObjectStoreRecordType() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     return m_requestedObjectStoreRecordType;
 }
 
 IndexedDB::IndexRecordType IDBRequest::requestedIndexRecordType() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(m_source);
     ASSERT(WTF::holds_alternative<RefPtr<IDBIndex>>(m_source.value()));
 
@@ -247,27 +247,27 @@ IndexedDB::IndexRecordType IDBRequest::requestedIndexRecordType() const
 
 EventTargetInterface IDBRequest::eventTargetInterface() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     return IDBRequestEventTargetInterfaceType;
 }
 
 const char* IDBRequest::activeDOMObjectName() const
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     return "IDBRequest";
 }
 
 bool IDBRequest::hasPendingActivity() const
 {
-    ASSERT(&originThread() == &Thread::current() || Thread::mayBeGCThread());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()) || Thread::mayBeGCThread());
     return !m_contextStopped && m_hasPendingActivity;
 }
 
 void IDBRequest::stop()
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(!m_contextStopped);
 
     cancelForStop();
@@ -286,7 +286,7 @@ void IDBRequest::cancelForStop()
 
 void IDBRequest::enqueueEvent(Ref<Event>&& event)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     if (m_contextStopped)
         return;
 
@@ -298,7 +298,7 @@ void IDBRequest::dispatchEvent(Event& event)
 {
     LOG(IndexedDB, "IDBRequest::dispatchEvent - %s (%p)", event.type().string().utf8().data(), this);
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(m_hasPendingActivity);
     ASSERT(!m_contextStopped);
 
@@ -349,7 +349,7 @@ void IDBRequest::uncaughtExceptionInEventHandler()
 {
     LOG(IndexedDB, "IDBRequest::uncaughtExceptionInEventHandler");
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     if (m_dispatchingEvent) {
         ASSERT(!m_hasUncaughtException);
@@ -362,7 +362,7 @@ void IDBRequest::uncaughtExceptionInEventHandler()
 
 void IDBRequest::setResult(const IDBKeyData& keyData)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto* context = scriptExecutionContext();
     if (!context)
@@ -376,7 +376,7 @@ void IDBRequest::setResult(const IDBKeyData& keyData)
 
 void IDBRequest::setResult(const Vector<IDBKeyData>& keyDatas)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto* context = scriptExecutionContext();
     if (!context)
@@ -390,7 +390,7 @@ void IDBRequest::setResult(const Vector<IDBKeyData>& keyDatas)
 
 void IDBRequest::setResult(const IDBGetAllResult& result)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto* context = scriptExecutionContext();
     if (!context)
@@ -404,7 +404,7 @@ void IDBRequest::setResult(const IDBGetAllResult& result)
 
 void IDBRequest::setResult(uint64_t number)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto* context = scriptExecutionContext();
     if (!context)
@@ -418,7 +418,7 @@ void IDBRequest::setResult(uint64_t number)
 
 void IDBRequest::setResultToStructuredClone(const IDBGetResult& result)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     LOG(IndexedDB, "IDBRequest::setResultToStructuredClone");
 
@@ -434,7 +434,7 @@ void IDBRequest::setResultToStructuredClone(const IDBGetResult& result)
 
 void IDBRequest::setResultToUndefined()
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto* context = scriptExecutionContext();
     if (!context)
@@ -448,7 +448,7 @@ void IDBRequest::setResultToUndefined()
 
 IDBCursor* IDBRequest::resultCursor()
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     return WTF::switchOn(m_result,
         [] (const RefPtr<IDBCursor>& cursor) -> IDBCursor* { return cursor.get(); },
@@ -458,7 +458,7 @@ IDBCursor* IDBRequest::resultCursor()
 
 void IDBRequest::willIterateCursor(IDBCursor& cursor)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(isDone());
     ASSERT(scriptExecutionContext());
     ASSERT(m_transaction);
@@ -486,7 +486,7 @@ void IDBRequest::willIterateCursor(IDBCursor& cursor)
 
 void IDBRequest::didOpenOrIterateCursor(const IDBResultData& resultData)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(m_pendingCursor);
 
     auto* context = scriptExecutionContext();
@@ -513,7 +513,7 @@ void IDBRequest::didOpenOrIterateCursor(const IDBResultData& resultData)
 
 void IDBRequest::completeRequestAndDispatchEvent(const IDBResultData& resultData)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     m_readyState = ReadyState::Done;
 
@@ -528,7 +528,7 @@ void IDBRequest::onError()
 {
     LOG(IndexedDB, "IDBRequest::onError");
 
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(!m_idbError.isNull());
 
     m_domError = m_idbError.toDOMException();
@@ -538,13 +538,13 @@ void IDBRequest::onError()
 void IDBRequest::onSuccess()
 {
     LOG(IndexedDB, "IDBRequest::onSuccess");
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     enqueueEvent(Event::create(eventNames().successEvent, Event::CanBubble::No, Event::IsCancelable::No));
 }
 
 void IDBRequest::setResult(Ref<IDBDatabase>&& database)
 {
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
 
     auto* context = scriptExecutionContext();
     if (!context)
index d9ad732..006c741 100644 (file)
@@ -85,7 +85,7 @@ IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo&
 
 {
     LOG(IndexedDB, "IDBTransaction::IDBTransaction - %s", m_info.loggingString().utf8().data());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ++numberOfIDBTransactions;
 
@@ -113,7 +113,7 @@ IDBTransaction::IDBTransaction(IDBDatabase& database, const IDBTransactionInfo&
 IDBTransaction::~IDBTransaction()
 {
     --numberOfIDBTransactions;
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 }
 
 IDBClient::IDBConnectionProxy& IDBTransaction::connectionProxy()
@@ -123,7 +123,7 @@ IDBClient::IDBConnectionProxy& IDBTransaction::connectionProxy()
 
 Ref<DOMStringList> IDBTransaction::objectStoreNames() const
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     const Vector<String> names = isVersionChange() ? m_database->info().objectStoreNames() : m_info.objectStores();
 
@@ -137,20 +137,20 @@ Ref<DOMStringList> IDBTransaction::objectStoreNames() const
 
 IDBDatabase* IDBTransaction::db()
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     return m_database.ptr();
 }
 
 DOMException* IDBTransaction::error() const
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     return m_domError.get();
 }
 
 ExceptionOr<Ref<IDBObjectStore>> IDBTransaction::objectStore(const String& objectStoreName)
 {
     LOG(IndexedDB, "IDBTransaction::objectStore");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (!scriptExecutionContext())
         return Exception { InvalidStateError };
@@ -190,7 +190,7 @@ ExceptionOr<Ref<IDBObjectStore>> IDBTransaction::objectStore(const String& objec
 void IDBTransaction::abortDueToFailedRequest(DOMException& error)
 {
     LOG(IndexedDB, "IDBTransaction::abortDueToFailedRequest");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (isFinishedOrFinishing())
         return;
@@ -201,7 +201,7 @@ void IDBTransaction::abortDueToFailedRequest(DOMException& error)
 
 void IDBTransaction::transitionedToFinishing(IndexedDB::TransactionState state)
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT(!isFinishedOrFinishing());
     m_state = state;
@@ -211,7 +211,7 @@ void IDBTransaction::transitionedToFinishing(IndexedDB::TransactionState state)
 ExceptionOr<void> IDBTransaction::abort()
 {
     LOG(IndexedDB, "IDBTransaction::abort");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (isFinishedOrFinishing())
         return Exception { InvalidStateError, "Failed to execute 'abort' on 'IDBTransaction': The transaction is inactive or finished."_s };
@@ -224,7 +224,7 @@ ExceptionOr<void> IDBTransaction::abort()
 void IDBTransaction::internalAbort()
 {
     LOG(IndexedDB, "IDBTransaction::internalAbort");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(!isFinishedOrFinishing());
 
     m_database->willAbortTransaction(*this);
@@ -290,7 +290,7 @@ void IDBTransaction::abortInProgressOperations(const IDBError& error)
 void IDBTransaction::abortOnServerAndCancelRequests(IDBClient::TransactionOperation& operation)
 {
     LOG(IndexedDB, "IDBTransaction::abortOnServerAndCancelRequests");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(m_pendingTransactionOperationQueue.isEmpty());
 
     m_database->connectionProxy().abortTransaction(*this);
@@ -319,20 +319,20 @@ void IDBTransaction::abortOnServerAndCancelRequests(IDBClient::TransactionOperat
 
 const char* IDBTransaction::activeDOMObjectName() const
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     return "IDBTransaction";
 }
 
 bool IDBTransaction::hasPendingActivity() const
 {
-    ASSERT(&m_database->originThread() == &Thread::current() || Thread::mayBeGCThread());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()) || Thread::mayBeGCThread());
     return !m_contextStopped && m_state != IndexedDB::TransactionState::Finished;
 }
 
 void IDBTransaction::stop()
 {
     LOG(IndexedDB, "IDBTransaction::stop - %s", m_info.loggingString().utf8().data());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     // IDBDatabase::stop() calls IDBTransaction::stop() for each of its active transactions.
     // Since the order of calling ActiveDOMObject::stop() is random, we might already have been stopped.
@@ -354,13 +354,13 @@ void IDBTransaction::stop()
 
 bool IDBTransaction::isActive() const
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     return m_state == IndexedDB::TransactionState::Active;
 }
 
 bool IDBTransaction::isFinishedOrFinishing() const
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     return m_state == IndexedDB::TransactionState::Committing
         || m_state == IndexedDB::TransactionState::Aborting
@@ -369,13 +369,13 @@ bool IDBTransaction::isFinishedOrFinishing() const
 
 void IDBTransaction::addRequest(IDBRequest& request)
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     m_openRequests.add(&request);
 }
 
 void IDBTransaction::removeRequest(IDBRequest& request)
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     m_openRequests.remove(&request);
 
     trySchedulePendingOperationTimer();
@@ -384,7 +384,7 @@ void IDBTransaction::removeRequest(IDBRequest& request)
 void IDBTransaction::scheduleOperation(Ref<IDBClient::TransactionOperation>&& operation)
 {
     ASSERT(!m_transactionOperationMap.contains(operation->identifier()));
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     auto identifier = operation->identifier();
     m_pendingTransactionOperationQueue.append(operation.copyRef());
@@ -395,7 +395,7 @@ void IDBTransaction::scheduleOperation(Ref<IDBClient::TransactionOperation>&& op
 
 void IDBTransaction::trySchedulePendingOperationTimer()
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (!m_startedOnServer)
         return;
@@ -415,7 +415,7 @@ void IDBTransaction::trySchedulePendingOperationTimer()
 void IDBTransaction::pendingOperationTimerFired()
 {
     LOG(IndexedDB, "IDBTransaction::pendingOperationTimerFired (%p)", this);
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     // We want to batch operations together without spinning the runloop for performance,
     // but don't want to affect responsiveness of the main thread.
@@ -441,8 +441,8 @@ void IDBTransaction::pendingOperationTimerFired()
 
 void IDBTransaction::operationCompletedOnServer(const IDBResultData& data, IDBClient::TransactionOperation& operation)
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
-    ASSERT(&operation.originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
+    ASSERT(canCurrentThreadAccessThreadLocalData(operation.originThread()));
 
     m_completedOnServerQueue.append({ &operation, data });
 
@@ -452,7 +452,7 @@ void IDBTransaction::operationCompletedOnServer(const IDBResultData& data, IDBCl
 
 void IDBTransaction::scheduleCompletedOperationTimer()
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (!m_completedOperationTimer.isActive())
         m_completedOperationTimer.startOneShot(0_s);
@@ -461,7 +461,7 @@ void IDBTransaction::scheduleCompletedOperationTimer()
 void IDBTransaction::completedOperationTimerFired()
 {
     LOG(IndexedDB, "IDBTransaction::completedOperationTimerFired (%p)", this);
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (m_completedOnServerQueue.isEmpty() || m_currentlyCompletingRequest)
         return;
@@ -505,7 +505,7 @@ void IDBTransaction::finishedDispatchEventForRequest(IDBRequest& request)
 void IDBTransaction::commit()
 {
     LOG(IndexedDB, "IDBTransaction::commit");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(!isFinishedOrFinishing());
 
     transitionedToFinishing(IndexedDB::TransactionState::Committing);
@@ -520,7 +520,7 @@ void IDBTransaction::commit()
 void IDBTransaction::commitOnServer(IDBClient::TransactionOperation& operation)
 {
     LOG(IndexedDB, "IDBTransaction::commitOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().commitTransaction(*this);
 
@@ -535,7 +535,7 @@ void IDBTransaction::commitOnServer(IDBClient::TransactionOperation& operation)
 void IDBTransaction::finishAbortOrCommit()
 {
     ASSERT(m_state != IndexedDB::TransactionState::Finished);
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_state = IndexedDB::TransactionState::Finished;
 }
@@ -543,7 +543,7 @@ void IDBTransaction::finishAbortOrCommit()
 void IDBTransaction::didStart(const IDBError& error)
 {
     LOG(IndexedDB, "IDBTransaction::didStart");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->didStartTransaction(*this);
 
@@ -561,7 +561,7 @@ void IDBTransaction::didStart(const IDBError& error)
 
 void IDBTransaction::notifyDidAbort(const IDBError& error)
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->didAbortTransaction(*this);
     m_idbError = error;
@@ -576,7 +576,7 @@ void IDBTransaction::notifyDidAbort(const IDBError& error)
 void IDBTransaction::didAbort(const IDBError& error)
 {
     LOG(IndexedDB, "IDBTransaction::didAbort");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (m_state == IndexedDB::TransactionState::Finished)
         return;
@@ -589,7 +589,7 @@ void IDBTransaction::didAbort(const IDBError& error)
 void IDBTransaction::didCommit(const IDBError& error)
 {
     LOG(IndexedDB, "IDBTransaction::didCommit");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(m_state == IndexedDB::TransactionState::Committing);
 
     if (error.isNull()) {
@@ -606,21 +606,21 @@ void IDBTransaction::didCommit(const IDBError& error)
 void IDBTransaction::fireOnComplete()
 {
     LOG(IndexedDB, "IDBTransaction::fireOnComplete");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     enqueueEvent(Event::create(eventNames().completeEvent, Event::CanBubble::No, Event::IsCancelable::No));
 }
 
 void IDBTransaction::fireOnAbort()
 {
     LOG(IndexedDB, "IDBTransaction::fireOnAbort");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     enqueueEvent(Event::create(eventNames().abortEvent, Event::CanBubble::Yes, Event::IsCancelable::No));
 }
 
 void IDBTransaction::enqueueEvent(Ref<Event>&& event)
 {
     ASSERT(m_state != IndexedDB::TransactionState::Finished);
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (!scriptExecutionContext() || m_contextStopped)
         return;
@@ -633,7 +633,7 @@ void IDBTransaction::dispatchEvent(Event& event)
 {
     LOG(IndexedDB, "IDBTransaction::dispatchEvent");
 
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(scriptExecutionContext());
     ASSERT(!m_contextStopped);
     ASSERT(event.target() == this);
@@ -664,7 +664,7 @@ Ref<IDBObjectStore> IDBTransaction::createObjectStore(const IDBObjectStoreInfo&
     LOG(IndexedDB, "IDBTransaction::createObjectStore");
     ASSERT(isVersionChange());
     ASSERT(scriptExecutionContext());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     Locker<Lock> locker(m_referencedObjectStoreLock);
 
@@ -685,7 +685,7 @@ Ref<IDBObjectStore> IDBTransaction::createObjectStore(const IDBObjectStoreInfo&
 void IDBTransaction::createObjectStoreOnServer(IDBClient::TransactionOperation& operation, const IDBObjectStoreInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::createObjectStoreOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(isVersionChange());
 
     m_database->connectionProxy().createObjectStore(operation, info);
@@ -694,7 +694,7 @@ void IDBTransaction::createObjectStoreOnServer(IDBClient::TransactionOperation&
 void IDBTransaction::didCreateObjectStoreOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didCreateObjectStoreOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::CreateObjectStoreSuccess || resultData.type() == IDBResultType::Error);
 }
 
@@ -706,7 +706,7 @@ void IDBTransaction::renameObjectStore(IDBObjectStore& objectStore, const String
 
     ASSERT(isVersionChange());
     ASSERT(scriptExecutionContext());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT(m_referencedObjectStores.contains(objectStore.info().name()));
     ASSERT(!m_referencedObjectStores.contains(newName));
@@ -727,7 +727,7 @@ void IDBTransaction::renameObjectStore(IDBObjectStore& objectStore, const String
 void IDBTransaction::renameObjectStoreOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier, const String& newName)
 {
     LOG(IndexedDB, "IDBTransaction::renameObjectStoreOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(isVersionChange());
 
     m_database->connectionProxy().renameObjectStore(operation, objectStoreIdentifier, newName);
@@ -736,7 +736,7 @@ void IDBTransaction::renameObjectStoreOnServer(IDBClient::TransactionOperation&
 void IDBTransaction::didRenameObjectStoreOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didRenameObjectStoreOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::RenameObjectStoreSuccess || resultData.type() == IDBResultType::Error);
 }
 
@@ -744,7 +744,7 @@ std::unique_ptr<IDBIndex> IDBTransaction::createIndex(IDBObjectStore& objectStor
 {
     LOG(IndexedDB, "IDBTransaction::createIndex");
     ASSERT(isVersionChange());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (!scriptExecutionContext())
         return nullptr;
@@ -762,7 +762,7 @@ std::unique_ptr<IDBIndex> IDBTransaction::createIndex(IDBObjectStore& objectStor
 void IDBTransaction::createIndexOnServer(IDBClient::TransactionOperation& operation, const IDBIndexInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::createIndexOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(isVersionChange());
 
     m_database->connectionProxy().createIndex(operation, info);
@@ -771,7 +771,7 @@ void IDBTransaction::createIndexOnServer(IDBClient::TransactionOperation& operat
 void IDBTransaction::didCreateIndexOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didCreateIndexOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (resultData.type() == IDBResultType::CreateIndexSuccess)
         return;
@@ -793,7 +793,7 @@ void IDBTransaction::renameIndex(IDBIndex& index, const String& newName)
 
     ASSERT(isVersionChange());
     ASSERT(scriptExecutionContext());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT(m_referencedObjectStores.contains(index.objectStore().info().name()));
     ASSERT(m_referencedObjectStores.get(index.objectStore().info().name()) == &index.objectStore());
@@ -814,7 +814,7 @@ void IDBTransaction::renameIndex(IDBIndex& index, const String& newName)
 void IDBTransaction::renameIndexOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier, const uint64_t& indexIdentifier, const String& newName)
 {
     LOG(IndexedDB, "IDBTransaction::renameIndexOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(isVersionChange());
 
     m_database->connectionProxy().renameIndex(operation, objectStoreIdentifier, indexIdentifier, newName);
@@ -823,14 +823,14 @@ void IDBTransaction::renameIndexOnServer(IDBClient::TransactionOperation& operat
 void IDBTransaction::didRenameIndexOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didRenameIndexOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::RenameIndexSuccess || resultData.type() == IDBResultType::Error);
 }
 
 Ref<IDBRequest> IDBTransaction::requestOpenCursor(JSGlobalObject& state, IDBObjectStore& objectStore, const IDBCursorInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::requestOpenCursor");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (info.cursorType() == IndexedDB::CursorType::KeyOnly)
         return doRequestOpenCursor(state, IDBCursor::create(objectStore, info));
@@ -841,7 +841,7 @@ Ref<IDBRequest> IDBTransaction::requestOpenCursor(JSGlobalObject& state, IDBObje
 Ref<IDBRequest> IDBTransaction::requestOpenCursor(JSGlobalObject& state, IDBIndex& index, const IDBCursorInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::requestOpenCursor");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (info.cursorType() == IndexedDB::CursorType::KeyOnly)
         return doRequestOpenCursor(state, IDBCursor::create(index, info));
@@ -852,7 +852,7 @@ Ref<IDBRequest> IDBTransaction::requestOpenCursor(JSGlobalObject& state, IDBInde
 Ref<IDBRequest> IDBTransaction::doRequestOpenCursor(JSGlobalObject& state, Ref<IDBCursor>&& cursor)
 {
     ASSERT(isActive());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -872,7 +872,7 @@ Ref<IDBRequest> IDBTransaction::doRequestOpenCursor(JSGlobalObject& state, Ref<I
 void IDBTransaction::openCursorOnServer(IDBClient::TransactionOperation& operation, const IDBCursorInfo& info)
 {
     LOG(IndexedDB, "IDBTransaction::openCursorOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().openCursor(operation, info);
 }
@@ -880,7 +880,7 @@ void IDBTransaction::openCursorOnServer(IDBClient::TransactionOperation& operati
 void IDBTransaction::didOpenCursorOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didOpenCursorOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     completeCursorRequest(request, resultData);
 }
@@ -890,7 +890,7 @@ void IDBTransaction::iterateCursor(IDBCursor& cursor, const IDBIterateCursorData
     LOG(IndexedDB, "IDBTransaction::iterateCursor");
     ASSERT(isActive());
     ASSERT(cursor.request());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     addRequest(*cursor.request());
 
@@ -906,7 +906,7 @@ void IDBTransaction::iterateCursor(IDBCursor& cursor, const IDBIterateCursorData
 void IDBTransaction::iterateCursorOnServer(IDBClient::TransactionOperation& operation, const IDBIterateCursorData& data)
 {
     LOG(IndexedDB, "IDBTransaction::iterateCursorOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().iterateCursor(operation, data);
 }
@@ -914,7 +914,7 @@ void IDBTransaction::iterateCursorOnServer(IDBClient::TransactionOperation& oper
 void IDBTransaction::didIterateCursorOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didIterateCursorOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     completeCursorRequest(request, resultData);
 }
@@ -923,7 +923,7 @@ Ref<IDBRequest> IDBTransaction::requestGetAllObjectStoreRecords(JSC::JSGlobalObj
 {
     LOG(IndexedDB, "IDBTransaction::requestGetAllObjectStoreRecords");
     ASSERT(isActive());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -946,7 +946,7 @@ Ref<IDBRequest> IDBTransaction::requestGetAllIndexRecords(JSC::JSGlobalObject& s
 {
     LOG(IndexedDB, "IDBTransaction::requestGetAllIndexRecords");
     ASSERT(isActive());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -968,7 +968,7 @@ Ref<IDBRequest> IDBTransaction::requestGetAllIndexRecords(JSC::JSGlobalObject& s
 void IDBTransaction::getAllRecordsOnServer(IDBClient::TransactionOperation& operation, const IDBGetAllRecordsData& getAllRecordsData)
 {
     LOG(IndexedDB, "IDBTransaction::getAllRecordsOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().getAllRecords(operation, getAllRecordsData);
 }
@@ -976,7 +976,7 @@ void IDBTransaction::getAllRecordsOnServer(IDBClient::TransactionOperation& oper
 void IDBTransaction::didGetAllRecordsOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didGetAllRecordsOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (resultData.type() == IDBResultType::Error) {
         completeNoncursorRequest(request, resultData);
@@ -1003,7 +1003,7 @@ Ref<IDBRequest> IDBTransaction::requestGetRecord(JSGlobalObject& state, IDBObjec
     LOG(IndexedDB, "IDBTransaction::requestGetRecord");
     ASSERT(isActive());
     ASSERT(!getRecordData.keyRangeData.isNull);
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1025,7 +1025,7 @@ Ref<IDBRequest> IDBTransaction::requestGetRecord(JSGlobalObject& state, IDBObjec
 Ref<IDBRequest> IDBTransaction::requestGetValue(JSGlobalObject& state, IDBIndex& index, const IDBKeyRangeData& range)
 {
     LOG(IndexedDB, "IDBTransaction::requestGetValue");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     return requestIndexRecord(state, index, IndexedDB::IndexRecordType::Value, range);
 }
@@ -1033,7 +1033,7 @@ Ref<IDBRequest> IDBTransaction::requestGetValue(JSGlobalObject& state, IDBIndex&
 Ref<IDBRequest> IDBTransaction::requestGetKey(JSGlobalObject& state, IDBIndex& index, const IDBKeyRangeData& range)
 {
     LOG(IndexedDB, "IDBTransaction::requestGetValue");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     return requestIndexRecord(state, index, IndexedDB::IndexRecordType::Key, range);
 }
@@ -1043,7 +1043,7 @@ Ref<IDBRequest> IDBTransaction::requestIndexRecord(JSGlobalObject& state, IDBInd
     LOG(IndexedDB, "IDBTransaction::requestGetValue");
     ASSERT(isActive());
     ASSERT(!range.isNull);
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1065,7 +1065,7 @@ Ref<IDBRequest> IDBTransaction::requestIndexRecord(JSGlobalObject& state, IDBInd
 void IDBTransaction::getRecordOnServer(IDBClient::TransactionOperation& operation, const IDBGetRecordData& getRecordData)
 {
     LOG(IndexedDB, "IDBTransaction::getRecordOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().getRecord(operation, getRecordData);
 }
@@ -1073,7 +1073,7 @@ void IDBTransaction::getRecordOnServer(IDBClient::TransactionOperation& operatio
 void IDBTransaction::didGetRecordOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didGetRecordOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (resultData.type() == IDBResultType::Error) {
         completeNoncursorRequest(request, resultData);
@@ -1108,7 +1108,7 @@ Ref<IDBRequest> IDBTransaction::requestCount(JSGlobalObject& state, IDBObjectSto
     LOG(IndexedDB, "IDBTransaction::requestCount (IDBObjectStore)");
     ASSERT(isActive());
     ASSERT(!range.isNull);
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1130,7 +1130,7 @@ Ref<IDBRequest> IDBTransaction::requestCount(JSGlobalObject& state, IDBIndex& in
     LOG(IndexedDB, "IDBTransaction::requestCount (IDBIndex)");
     ASSERT(isActive());
     ASSERT(!range.isNull);
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1150,7 +1150,7 @@ Ref<IDBRequest> IDBTransaction::requestCount(JSGlobalObject& state, IDBIndex& in
 void IDBTransaction::getCountOnServer(IDBClient::TransactionOperation& operation, const IDBKeyRangeData& keyRange)
 {
     LOG(IndexedDB, "IDBTransaction::getCountOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().getCount(operation, keyRange);
 }
@@ -1158,7 +1158,7 @@ void IDBTransaction::getCountOnServer(IDBClient::TransactionOperation& operation
 void IDBTransaction::didGetCountOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didGetCountOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     request.setResult(resultData.resultInteger());
     completeNoncursorRequest(request, resultData);
@@ -1169,7 +1169,7 @@ Ref<IDBRequest> IDBTransaction::requestDeleteRecord(JSGlobalObject& state, IDBOb
     LOG(IndexedDB, "IDBTransaction::requestDeleteRecord");
     ASSERT(isActive());
     ASSERT(!range.isNull);
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1188,7 +1188,7 @@ Ref<IDBRequest> IDBTransaction::requestDeleteRecord(JSGlobalObject& state, IDBOb
 void IDBTransaction::deleteRecordOnServer(IDBClient::TransactionOperation& operation, const IDBKeyRangeData& keyRange)
 {
     LOG(IndexedDB, "IDBTransaction::deleteRecordOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().deleteRecord(operation, keyRange);
 }
@@ -1196,7 +1196,7 @@ void IDBTransaction::deleteRecordOnServer(IDBClient::TransactionOperation& opera
 void IDBTransaction::didDeleteRecordOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didDeleteRecordOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     request.setResultToUndefined();
     completeNoncursorRequest(request, resultData);
@@ -1206,7 +1206,7 @@ Ref<IDBRequest> IDBTransaction::requestClearObjectStore(JSGlobalObject& state, I
 {
     LOG(IndexedDB, "IDBTransaction::requestClearObjectStore");
     ASSERT(isActive());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1228,7 +1228,7 @@ Ref<IDBRequest> IDBTransaction::requestClearObjectStore(JSGlobalObject& state, I
 void IDBTransaction::clearObjectStoreOnServer(IDBClient::TransactionOperation& operation, const uint64_t& objectStoreIdentifier)
 {
     LOG(IndexedDB, "IDBTransaction::clearObjectStoreOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().clearObjectStore(operation, objectStoreIdentifier);
 }
@@ -1236,7 +1236,7 @@ void IDBTransaction::clearObjectStoreOnServer(IDBClient::TransactionOperation& o
 void IDBTransaction::didClearObjectStoreOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didClearObjectStoreOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     request.setResultToUndefined();
     completeNoncursorRequest(request, resultData);
@@ -1248,7 +1248,7 @@ Ref<IDBRequest> IDBTransaction::requestPutOrAdd(JSGlobalObject& state, IDBObject
     ASSERT(isActive());
     ASSERT(!isReadOnly());
     ASSERT(objectStore.info().autoIncrement() || key);
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     ASSERT_UNUSED(state, scriptExecutionContext() == scriptExecutionContextFromExecState(&state));
 
@@ -1268,7 +1268,7 @@ Ref<IDBRequest> IDBTransaction::requestPutOrAdd(JSGlobalObject& state, IDBObject
 void IDBTransaction::putOrAddOnServer(IDBClient::TransactionOperation& operation, RefPtr<IDBKey> key, RefPtr<SerializedScriptValue> value, const IndexedDB::ObjectStoreOverwriteMode& overwriteMode)
 {
     LOG(IndexedDB, "IDBTransaction::putOrAddOnServer");
-    ASSERT(&originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
     ASSERT(!isReadOnly());
     ASSERT(value);
 
@@ -1301,7 +1301,7 @@ void IDBTransaction::putOrAddOnServer(IDBClient::TransactionOperation& operation
     operation.setNextRequestCanGoToServer(false);
 
     value->writeBlobsToDiskForIndexedDB([protectedThis = makeRef(*this), this, protectedOperation = Ref<IDBClient::TransactionOperation>(operation), keyData = IDBKeyData(key.get()).isolatedCopy(), overwriteMode](IDBValue&& idbValue) mutable {
-        ASSERT(&originThread() == &Thread::current());
+        ASSERT(canCurrentThreadAccessThreadLocalData(originThread()));
         ASSERT(isMainThread());
         if (idbValue.data().data()) {
             m_database->connectionProxy().putOrAdd(protectedOperation.get(), WTFMove(keyData), idbValue, overwriteMode);
@@ -1320,7 +1320,7 @@ void IDBTransaction::putOrAddOnServer(IDBClient::TransactionOperation& operation
 void IDBTransaction::didPutOrAddOnServer(IDBRequest& request, const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didPutOrAddOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (auto* result = resultData.resultKey())
         request.setResult(*result);
@@ -1332,7 +1332,7 @@ void IDBTransaction::didPutOrAddOnServer(IDBRequest& request, const IDBResultDat
 void IDBTransaction::deleteObjectStore(const String& objectStoreName)
 {
     LOG(IndexedDB, "IDBTransaction::deleteObjectStore");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(isVersionChange());
 
     Locker<Lock> locker(m_referencedObjectStoreLock);
@@ -1355,7 +1355,7 @@ void IDBTransaction::deleteObjectStoreOnServer(IDBClient::TransactionOperation&
 {
     LOG(IndexedDB, "IDBTransaction::deleteObjectStoreOnServer");
     ASSERT(isVersionChange());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().deleteObjectStore(operation, objectStoreName);
 }
@@ -1363,14 +1363,14 @@ void IDBTransaction::deleteObjectStoreOnServer(IDBClient::TransactionOperation&
 void IDBTransaction::didDeleteObjectStoreOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didDeleteObjectStoreOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteObjectStoreSuccess || resultData.type() == IDBResultType::Error);
 }
 
 void IDBTransaction::deleteIndex(uint64_t objectStoreIdentifier, const String& indexName)
 {
     LOG(IndexedDB, "IDBTransaction::deleteIndex");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT(isVersionChange());
 
     LOG(IndexedDBOperations, "IDB delete index operation: %s (%" PRIu64 ")", indexName.utf8().data(), objectStoreIdentifier);
@@ -1385,7 +1385,7 @@ void IDBTransaction::deleteIndexOnServer(IDBClient::TransactionOperation& operat
 {
     LOG(IndexedDB, "IDBTransaction::deleteIndexOnServer");
     ASSERT(isVersionChange());
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().deleteIndex(operation, objectStoreIdentifier, indexName);
 }
@@ -1393,7 +1393,7 @@ void IDBTransaction::deleteIndexOnServer(IDBClient::TransactionOperation& operat
 void IDBTransaction::didDeleteIndexOnServer(const IDBResultData& resultData)
 {
     LOG(IndexedDB, "IDBTransaction::didDeleteIndexOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
     ASSERT_UNUSED(resultData, resultData.type() == IDBResultType::DeleteIndexSuccess || resultData.type() == IDBResultType::Error);
 }
 
@@ -1401,8 +1401,8 @@ void IDBTransaction::operationCompletedOnClient(IDBClient::TransactionOperation&
 {
     LOG(IndexedDB, "IDBTransaction::operationCompletedOnClient");
 
-    ASSERT(&m_database->originThread() == &Thread::current());
-    ASSERT(&operation.originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
+    ASSERT(canCurrentThreadAccessThreadLocalData(operation.originThread()));
     ASSERT(m_transactionOperationMap.get(operation.identifier()) == &operation);
     ASSERT(m_transactionOperationsInProgressQueue.first() == &operation);
 
@@ -1415,14 +1415,14 @@ void IDBTransaction::operationCompletedOnClient(IDBClient::TransactionOperation&
 void IDBTransaction::establishOnServer()
 {
     LOG(IndexedDB, "IDBTransaction::establishOnServer");
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     m_database->connectionProxy().establishTransaction(*this);
 }
 
 void IDBTransaction::activate()
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (isFinishedOrFinishing())
         return;
@@ -1432,7 +1432,7 @@ void IDBTransaction::activate()
 
 void IDBTransaction::deactivate()
 {
-    ASSERT(&m_database->originThread() == &Thread::current());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_database->originThread()));
 
     if (m_state == IndexedDB::TransactionState::Active)
         m_state = IndexedDB::TransactionState::Inactive;
index c60e012..dc5781b 100644 (file)
@@ -548,6 +548,8 @@ void IDBConnectionProxy::forgetTransaction(IDBTransaction& transaction)
 template<typename KeyType, typename ValueType>
 void removeItemsMatchingCurrentThread(HashMap<KeyType, ValueType>& map)
 {
+    // FIXME: Revisit when introducing WebThread aware thread comparison.
+    // https://bugs.webkit.org/show_bug.cgi?id=204345
     auto& currentThread = Thread::current();
 
     Vector<KeyType> keys;
@@ -564,6 +566,8 @@ void removeItemsMatchingCurrentThread(HashMap<KeyType, ValueType>& map)
 template<typename KeyType, typename ValueType>
 void setMatchingItemsContextSuspended(ScriptExecutionContext& currentContext, HashMap<KeyType, ValueType>& map, bool isContextSuspended)
 {
+    // FIXME: Revisit when introducing WebThread aware thread comparison.
+    // https://bugs.webkit.org/show_bug.cgi?id=204345
     auto& currentThread = Thread::current();
     for (auto& iterator : map) {
         if (&iterator.value->originThread() != &currentThread)
index 9e73a01..3e13702 100644 (file)
@@ -51,12 +51,12 @@ class TransactionOperation : public ThreadSafeRefCounted<TransactionOperation> {
 public:
     virtual ~TransactionOperation()
     {
-        ASSERT(m_originThread.ptr() == &Thread::current());
+        ASSERT(canCurrentThreadAccessThreadLocalData(m_originThread.get()));
     }
 
     void perform()
     {
-        ASSERT(m_originThread.ptr() == &Thread::current());
+        ASSERT(canCurrentThreadAccessThreadLocalData(m_originThread.get()));
         ASSERT(m_performFunction);
         m_performFunction();
         m_performFunction = { };
@@ -64,7 +64,7 @@ public:
 
     void transitionToCompleteOnThisThread(const IDBResultData& data)
     {
-        ASSERT(m_originThread.ptr() == &Thread::current());
+        ASSERT(canCurrentThreadAccessThreadLocalData(m_originThread.get()));
         m_transaction->operationCompletedOnServer(data, *this);
     }
 
@@ -72,7 +72,7 @@ public:
     {
         ASSERT(isMainThread());
 
-        if (m_originThread.ptr() == &Thread::current())
+        if (canCurrentThreadAccessThreadLocalData(m_originThread.get()))
             transitionToCompleteOnThisThread(data);
         else {
             m_transaction->performCallbackOnOriginThread(*this, &TransactionOperation::transitionToCompleteOnThisThread, data);
@@ -83,7 +83,7 @@ public:
 
     void doComplete(const IDBResultData& data)
     {
-        ASSERT(m_originThread.ptr() == &Thread::current());
+        ASSERT(canCurrentThreadAccessThreadLocalData(m_originThread.get()));
 
         if (m_performFunction)
             m_performFunction = { };
index 6e558ce..82f3458 100644 (file)
@@ -67,7 +67,7 @@ ActiveDOMObject::ActiveDOMObject(Document& document)
 
 ActiveDOMObject::~ActiveDOMObject()
 {
-    ASSERT(canAccessThreadLocalDataForThread(m_creationThread));
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_creationThread));
 
     // ActiveDOMObject may be inherited by a sub-class whose life-cycle
     // exceeds that of the associated ScriptExecutionContext. In those cases,
index 6c2619c..2240a39 100644 (file)
@@ -98,20 +98,20 @@ class Supplementable {
 public:
     void provideSupplement(const char* key, std::unique_ptr<Supplement<T>> supplement)
     {
-        ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
+        ASSERT(canCurrentThreadAccessThreadLocalData(m_thread.get()));
         ASSERT(!m_supplements.get(key));
         m_supplements.set(key, WTFMove(supplement));
     }
 
     void removeSupplement(const char* key)
     {
-        ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
+        ASSERT(canCurrentThreadAccessThreadLocalData(m_thread.get()));
         m_supplements.remove(key);
     }
 
     Supplement<T>* requireSupplement(const char* key)
     {
-        ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
+        ASSERT(canCurrentThreadAccessThreadLocalData(m_thread.get()));
         return m_supplements.get(key);
     }
 
index add48e6..4dbaeb6 100644 (file)
@@ -258,8 +258,8 @@ TimerBase::TimerBase()
 
 TimerBase::~TimerBase()
 {
-    ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
-    RELEASE_ASSERT(canAccessThreadLocalDataForThread(m_thread.get()) || shouldSuppressThreadSafetyCheck());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_thread.get()));
+    RELEASE_ASSERT(canCurrentThreadAccessThreadLocalData(m_thread.get()) || shouldSuppressThreadSafetyCheck());
     stop();
     ASSERT(!inHeap());
     if (m_heapItem)
@@ -269,7 +269,7 @@ TimerBase::~TimerBase()
 
 void TimerBase::start(Seconds nextFireInterval, Seconds repeatInterval)
 {
-    ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_thread.get()));
 
     m_repeatInterval = repeatInterval;
     setNextFireTime(MonotonicTime::now() + nextFireInterval);
@@ -277,7 +277,7 @@ void TimerBase::start(Seconds nextFireInterval, Seconds repeatInterval)
 
 void TimerBase::stop()
 {
-    ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_thread.get()));
 
     m_repeatInterval = 0_s;
     setNextFireTime(MonotonicTime { });
@@ -461,8 +461,8 @@ void TimerBase::updateHeapIfNeeded(MonotonicTime oldTime)
 
 void TimerBase::setNextFireTime(MonotonicTime newTime)
 {
-    ASSERT(canAccessThreadLocalDataForThread(m_thread.get()));
-    RELEASE_ASSERT(canAccessThreadLocalDataForThread(m_thread.get()) || shouldSuppressThreadSafetyCheck());
+    ASSERT(canCurrentThreadAccessThreadLocalData(m_thread.get()));
+    RELEASE_ASSERT(canCurrentThreadAccessThreadLocalData(m_thread.get()) || shouldSuppressThreadSafetyCheck());
     bool timerHasBeenDeleted = std::isnan(m_unalignedNextFireTime);
     RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(!timerHasBeenDeleted);