void IDBTransaction::finished() { #if DCHECK_IS_ON() DCHECK(!m_finishCalled); m_finishCalled = true; #endif // DCHECK_IS_ON() m_database->transactionFinished(this); // Remove references to the IDBObjectStore and IDBIndex instances held by // this transaction, so Oilpan can garbage-collect the instances that aren't // used by JavaScript. for (auto& it : m_objectStoreMap) { IDBObjectStore* objectStore = it.value; if (!isVersionChange() || objectStore->isNewlyCreated()) { DCHECK(!m_oldStoreMetadata.contains(objectStore)); objectStore->clearIndexCache(); } else { // We'll call clearIndexCache() on this store in the loop below. DCHECK(m_oldStoreMetadata.contains(objectStore)); } } m_objectStoreMap.clear(); for (auto& it : m_oldStoreMetadata) { IDBObjectStore* objectStore = it.key; objectStore->clearIndexCache(); } m_oldStoreMetadata.clear(); m_deletedIndexes.clear(); m_deletedObjectStores.clear(); }
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)); } } }