Changeset 287129 in webkit
- Timestamp:
- Dec 16, 2021, 3:31:09 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287128 r287129 1 2021-12-15 Antoine Quint <graouts@webkit.org> 2 3 ActiveDOMObject::suspendIfNeeded() should not be called within constructors 4 https://bugs.webkit.org/show_bug.cgi?id=233945 5 6 Reviewed by Darin Adler. 7 8 Step 2 where we convert the IDB code to use suspendIfNeeded() only within create() methods. This required 9 adding such methods and making the constructor private for IDBIndex and IDBObjectStore. 10 11 * Modules/indexeddb/IDBDatabase.cpp: 12 (WebCore::IDBDatabase::create): 13 (WebCore::IDBDatabase::IDBDatabase): 14 * Modules/indexeddb/IDBDatabaseNameAndVersionRequest.cpp: 15 (WebCore::IDBDatabaseNameAndVersionRequest::create): 16 (WebCore::IDBDatabaseNameAndVersionRequest::IDBDatabaseNameAndVersionRequest): 17 * Modules/indexeddb/IDBIndex.cpp: 18 (WebCore::IDBIndex::create): 19 (WebCore::IDBIndex::IDBIndex): 20 * Modules/indexeddb/IDBIndex.h: 21 * Modules/indexeddb/IDBObjectStore.cpp: 22 (WebCore::IDBObjectStore::create): 23 (WebCore::IDBObjectStore::IDBObjectStore): 24 (WebCore::IDBObjectStore::index): 25 * Modules/indexeddb/IDBObjectStore.h: 26 * Modules/indexeddb/IDBOpenDBRequest.cpp: 27 (WebCore::IDBOpenDBRequest::createDeleteRequest): 28 (WebCore::IDBOpenDBRequest::createOpenRequest): 29 * Modules/indexeddb/IDBRequest.cpp: 30 (WebCore::IDBRequest::create): 31 (WebCore::IDBRequest::createObjectStoreGet): 32 (WebCore::IDBRequest::createIndexGet): 33 (WebCore::IDBRequest::IDBRequest): 34 * Modules/indexeddb/IDBTransaction.cpp: 35 (WebCore::IDBTransaction::create): 36 (WebCore::IDBTransaction::IDBTransaction): 37 (WebCore::IDBTransaction::objectStore): 38 (WebCore::IDBTransaction::createObjectStore): 39 (WebCore::IDBTransaction::createIndex): 40 1 41 2021-12-16 Vitaly Dyachkov <obyknovenius@me.com> 2 42 -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
r284095 r287129 49 49 Ref<IDBDatabase> IDBDatabase::create(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBResultData& resultData) 50 50 { 51 return adoptRef(*new IDBDatabase(context, connectionProxy, resultData)); 51 auto database = adoptRef(*new IDBDatabase(context, connectionProxy, resultData)); 52 database->suspendIfNeeded(); 53 return database; 52 54 } 53 55 … … 60 62 { 61 63 LOG(IndexedDB, "IDBDatabase::IDBDatabase - Creating database %s with version %" PRIu64 " connection %" PRIu64 " (%p)", m_info.name().utf8().data(), m_info.version(), m_databaseConnectionIdentifier, this); 62 suspendIfNeeded();63 64 m_connectionProxy->registerDatabaseConnection(*this); 64 65 } -
trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseNameAndVersionRequest.cpp
r278253 r287129 37 37 Ref<IDBDatabaseNameAndVersionRequest> IDBDatabaseNameAndVersionRequest::create(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, InfoCallback&& callback) 38 38 { 39 return adoptRef(*new IDBDatabaseNameAndVersionRequest(context, connectionProxy, WTFMove(callback))); 39 auto result = adoptRef(*new IDBDatabaseNameAndVersionRequest(context, connectionProxy, WTFMove(callback))); 40 result->suspendIfNeeded(); 41 return result; 40 42 } 41 43 … … 47 49 { 48 50 ASSERT(canCurrentThreadAccessThreadLocalData(originThread())); 49 50 suspendIfNeeded();51 51 } 52 52 -
trunk/Source/WebCore/Modules/indexeddb/IDBIndex.cpp
r284857 r287129 43 43 WTF_MAKE_ISO_ALLOCATED_IMPL(IDBIndex); 44 44 45 UniqueRef<IDBIndex> IDBIndex::create(ScriptExecutionContext& context, const IDBIndexInfo& info, IDBObjectStore& objectStore) 46 { 47 auto result = UniqueRef(*new IDBIndex(context, info, objectStore)); 48 result->suspendIfNeeded(); 49 return result; 50 } 51 45 52 IDBIndex::IDBIndex(ScriptExecutionContext& context, const IDBIndexInfo& info, IDBObjectStore& objectStore) 46 53 : ActiveDOMObject(&context) … … 50 57 { 51 58 ASSERT(canCurrentThreadAccessThreadLocalData(m_objectStore.transaction().database().originThread())); 52 53 suspendIfNeeded();54 59 } 55 60 -
trunk/Source/WebCore/Modules/indexeddb/IDBIndex.h
r284857 r287129 30 30 #include "IDBRequest.h" 31 31 #include <wtf/IsoMalloc.h> 32 #include <wtf/UniqueRef.h> 32 33 33 34 namespace JSC { … … 44 45 WTF_MAKE_ISO_ALLOCATED(IDBIndex); 45 46 public: 46 IDBIndex(ScriptExecutionContext&, const IDBIndexInfo&, IDBObjectStore&);47 static UniqueRef<IDBIndex> create(ScriptExecutionContext&, const IDBIndexInfo&, IDBObjectStore&); 47 48 48 49 virtual ~IDBIndex(); … … 86 87 87 88 private: 89 IDBIndex(ScriptExecutionContext&, const IDBIndexInfo&, IDBObjectStore&); 90 88 91 ExceptionOr<Ref<IDBRequest>> doCount(const IDBKeyRangeData&); 89 92 ExceptionOr<Ref<IDBRequest>> doGet(ExceptionOr<IDBKeyRangeData>); -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
r284857 r287129 56 56 WTF_MAKE_ISO_ALLOCATED_IMPL(IDBObjectStore); 57 57 58 UniqueRef<IDBObjectStore> IDBObjectStore::create(ScriptExecutionContext& context, const IDBObjectStoreInfo& info, IDBTransaction& transaction) 59 { 60 auto result = UniqueRef(*new IDBObjectStore(context, info, transaction)); 61 result->suspendIfNeeded(); 62 return result; 63 } 64 58 65 IDBObjectStore::IDBObjectStore(ScriptExecutionContext& context, const IDBObjectStoreInfo& info, IDBTransaction& transaction) 59 66 : ActiveDOMObject(&context) … … 63 70 { 64 71 ASSERT(canCurrentThreadAccessThreadLocalData(m_transaction.database().originThread())); 65 66 suspendIfNeeded();67 72 } 68 73 … … 521 526 return Exception { NotFoundError, "Failed to execute 'index' on 'IDBObjectStore': The specified index was not found."_s }; 522 527 523 auto index = makeUnique<IDBIndex>(*scriptExecutionContext(), *info, *this);524 525 Ref <IDBIndex> referencedIndex { *index};526 527 m_referencedIndexes.set(indexName, WTFMove(index));528 auto index = IDBIndex::create(*scriptExecutionContext(), *info, *this); 529 530 Ref referencedIndex { index.get() }; 531 532 m_referencedIndexes.set(indexName, index.moveToUniquePtr()); 528 533 529 534 return referencedIndex; -
trunk/Source/WebCore/Modules/indexeddb/IDBObjectStore.h
r284857 r287129 33 33 #include <wtf/IsoMalloc.h> 34 34 #include <wtf/Lock.h> 35 #include <wtf/UniqueRef.h> 35 36 36 37 namespace JSC { … … 60 61 WTF_MAKE_ISO_ALLOCATED(IDBObjectStore); 61 62 public: 62 IDBObjectStore(ScriptExecutionContext&, const IDBObjectStoreInfo&, IDBTransaction&);63 static UniqueRef<IDBObjectStore> create(ScriptExecutionContext&, const IDBObjectStoreInfo&, IDBTransaction&); 63 64 ~IDBObjectStore(); 64 65 … … 114 115 115 116 private: 117 IDBObjectStore(ScriptExecutionContext&, const IDBObjectStoreInfo&, IDBTransaction&); 118 116 119 enum class InlineKeyCheck { Perform, DoNotPerform }; 117 120 ExceptionOr<Ref<IDBRequest>> putOrAdd(JSC::JSGlobalObject&, JSC::JSValue, RefPtr<IDBKey>, IndexedDB::ObjectStoreOverwriteMode, InlineKeyCheck, RefPtr<SerializedScriptValue>&& = nullptr); -
trunk/Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp
r282755 r287129 47 47 Ref<IDBOpenDBRequest> IDBOpenDBRequest::createDeleteRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBDatabaseIdentifier& databaseIdentifier) 48 48 { 49 return adoptRef(*new IDBOpenDBRequest(context, connectionProxy, databaseIdentifier, 0, IndexedDB::RequestType::Delete)); 49 auto result = adoptRef(*new IDBOpenDBRequest(context, connectionProxy, databaseIdentifier, 0, IndexedDB::RequestType::Delete)); 50 result->suspendIfNeeded(); 51 return result; 50 52 } 51 53 52 54 Ref<IDBOpenDBRequest> IDBOpenDBRequest::createOpenRequest(ScriptExecutionContext& context, IDBClient::IDBConnectionProxy& connectionProxy, const IDBDatabaseIdentifier& databaseIdentifier, uint64_t version) 53 55 { 54 return adoptRef(*new IDBOpenDBRequest(context, connectionProxy, databaseIdentifier, version, IndexedDB::RequestType::Open)); 56 auto result = adoptRef(*new IDBOpenDBRequest(context, connectionProxy, databaseIdentifier, version, IndexedDB::RequestType::Open)); 57 result->suspendIfNeeded(); 58 return result; 55 59 } 56 60 -
trunk/Source/WebCore/Modules/indexeddb/IDBRequest.cpp
r284213 r287129 58 58 Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBTransaction& transaction) 59 59 { 60 return adoptRef(*new IDBRequest(context, objectStore, transaction)); 60 auto request = adoptRef(*new IDBRequest(context, objectStore, transaction)); 61 request->suspendIfNeeded(); 62 return request; 61 63 } 62 64 63 65 Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction) 64 66 { 65 return adoptRef(*new IDBRequest(context, cursor, transaction)); 67 auto request = adoptRef(*new IDBRequest(context, cursor, transaction)); 68 request->suspendIfNeeded(); 69 return request; 66 70 } 67 71 68 72 Ref<IDBRequest> IDBRequest::create(ScriptExecutionContext& context, IDBIndex& index, IDBTransaction& transaction) 69 73 { 70 return adoptRef(*new IDBRequest(context, index, transaction)); 74 auto request = adoptRef(*new IDBRequest(context, index, transaction)); 75 request->suspendIfNeeded(); 76 return request; 71 77 } 72 78 73 79 Ref<IDBRequest> IDBRequest::createObjectStoreGet(ScriptExecutionContext& context, IDBObjectStore& objectStore, IndexedDB::ObjectStoreRecordType type, IDBTransaction& transaction) 74 80 { 75 return adoptRef(*new IDBRequest(context, objectStore, type, transaction)); 81 auto request = adoptRef(*new IDBRequest(context, objectStore, type, transaction)); 82 request->suspendIfNeeded(); 83 return request; 76 84 } 77 85 78 86 Ref<IDBRequest> IDBRequest::createIndexGet(ScriptExecutionContext& context, IDBIndex& index, IndexedDB::IndexRecordType requestedRecordType, IDBTransaction& transaction) 79 87 { 80 return adoptRef(*new IDBRequest(context, index, requestedRecordType, transaction)); 88 auto request = adoptRef(*new IDBRequest(context, index, requestedRecordType, transaction)); 89 request->suspendIfNeeded(); 90 return request; 81 91 } 82 92 … … 88 98 , m_requestType(requestType) 89 99 { 90 suspendIfNeeded();91 100 } 92 101 … … 99 108 , m_connectionProxy(transaction.database().connectionProxy()) 100 109 { 101 suspendIfNeeded();102 110 } 103 111 … … 110 118 , m_connectionProxy(transaction.database().connectionProxy()) 111 119 { 112 suspendIfNeeded();113 114 120 WTF::switchOn(cursor.source(), 115 121 [this] (const auto& value) { this->m_source = IDBRequest::Source { value }; } … … 127 133 , m_connectionProxy(transaction.database().connectionProxy()) 128 134 { 129 suspendIfNeeded();130 135 } 131 136 … … 139 144 , m_requestedObjectStoreRecordType(type) 140 145 { 141 suspendIfNeeded();142 146 } 143 147 -
trunk/Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
r284761 r287129 66 66 Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info) 67 67 { 68 return adoptRef(*new IDBTransaction(database, info, nullptr)); 68 auto transaction = adoptRef(*new IDBTransaction(database, info, nullptr)); 69 transaction->suspendIfNeeded(); 70 return transaction; 69 71 } 70 72 71 73 Ref<IDBTransaction> IDBTransaction::create(IDBDatabase& database, const IDBTransactionInfo& info, IDBOpenDBRequest& request) 72 74 { 73 return adoptRef(*new IDBTransaction(database, info, &request)); 75 auto transaction = adoptRef(*new IDBTransaction(database, info, &request)); 76 transaction->suspendIfNeeded(); 77 return transaction; 74 78 } 75 79 … … 103 107 establishOnServer(); 104 108 } 105 106 suspendIfNeeded();107 109 } 108 110 … … 176 178 return Exception { NotFoundError, "Failed to execute 'objectStore' on 'IDBTransaction': The specified object store was not found."_s }; 177 179 178 auto objectStore = makeUnique<IDBObjectStore>(*scriptExecutionContext(), *info, *this);179 auto* rawObjectStore = objectStore.get();180 m_referencedObjectStores.set(objectStoreName, WTFMove(objectStore));181 182 return Ref<IDBObjectStore>(*rawObjectStore);180 auto objectStore = IDBObjectStore::create(*scriptExecutionContext(), *info, *this); 181 Ref objectStoreRef { objectStore.get() }; 182 m_referencedObjectStores.set(objectStoreName, objectStore.moveToUniquePtr()); 183 184 return objectStoreRef; 183 185 } 184 186 … … 660 662 Locker locker { m_referencedObjectStoreLock }; 661 663 662 auto objectStore = makeUnique<IDBObjectStore>(*scriptExecutionContext(), info, *this);663 auto* rawObjectStore = objectStore.get();664 m_referencedObjectStores.set(info.name(), WTFMove(objectStore));664 auto objectStore = IDBObjectStore::create(*scriptExecutionContext(), info, *this); 665 Ref objectStoreRef { objectStore.get() }; 666 m_referencedObjectStores.set(info.name(), objectStore.moveToUniquePtr()); 665 667 666 668 LOG(IndexedDBOperations, "IDB create object store operation: %s", info.condensedLoggingString().utf8().data()); … … 671 673 }), IsWriteOperation::Yes); 672 674 673 return *rawObjectStore;675 return objectStoreRef; 674 676 } 675 677 … … 748 750 }), IsWriteOperation::Yes); 749 751 750 return makeUnique<IDBIndex>(*scriptExecutionContext(), info, objectStore);752 return IDBIndex::create(*scriptExecutionContext(), info, objectStore).moveToUniquePtr(); 751 753 } 752 754
Note:
See TracChangeset
for help on using the changeset viewer.