void IDBTransaction::objectStoreDeleted(const String& name) { ASSERT(m_state != Finished); ASSERT(isVersionChange()); IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name); if (it != m_objectStoreMap.end()) { IDBObjectStore* objectStore = it->value; m_objectStoreMap.remove(name); objectStore->markDeleted(); m_objectStoreCleanupMap.set(objectStore, objectStore->metadata()); m_deletedObjectStores.add(objectStore); } }
void IDBTransaction::objectStoreDeleted(const int64_t objectStoreId, const String& name) { DCHECK_NE(m_state, Finished) << "A finished transaction deleted an object store"; DCHECK_EQ(m_mode, WebIDBTransactionModeVersionChange) << "A non-versionchange transaction deleted an object store"; IDBObjectStoreMap::iterator it = m_objectStoreMap.find(name); if (it == m_objectStoreMap.end()) { // No IDBObjectStore instance was created for the deleted store in this // transaction. This happens if IDBDatabase.deleteObjectStore() is called // with the name of a store that wasn't instantated. We need to be able to // revert the metadata change if the transaction aborts, in order to return // correct values from IDB{Database, Transaction}.objectStoreNames. DCHECK(m_database->metadata().objectStores.contains(objectStoreId)); RefPtr<IDBObjectStoreMetadata> metadata = m_database->metadata().objectStores.get(objectStoreId); DCHECK(metadata.get()); DCHECK_EQ(metadata->name, name); m_deletedObjectStores.append(std::move(metadata)); } else { IDBObjectStore* objectStore = it->value; m_objectStoreMap.remove(name); objectStore->markDeleted(); if (objectStore->id() > m_oldDatabaseMetadata.maxObjectStoreId) { // The store was created and deleted in this transaction, so it will // not be restored even if the transaction aborts. We have just // removed our last reference to it. DCHECK(!m_oldStoreMetadata.contains(objectStore)); objectStore->clearIndexCache(); } else { // The store was created before this transaction, and we created an // IDBObjectStore instance for it. When that happened, we must have // snapshotted the store's metadata as well. DCHECK(m_oldStoreMetadata.contains(objectStore)); } } }