| Index: third_party/WebKit/Source/modules/indexeddb/IDBTransaction.cpp
|
| diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBTransaction.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBTransaction.cpp
|
| index aa6524d1ebddae195ea237a791b8b3d7d2c62beb..8c5d4c898940c00da541d7785b683c06ddc6bb6c 100644
|
| --- a/third_party/WebKit/Source/modules/indexeddb/IDBTransaction.cpp
|
| +++ b/third_party/WebKit/Source/modules/indexeddb/IDBTransaction.cpp
|
| @@ -118,9 +118,7 @@ DEFINE_TRACE(IDBTransaction)
|
| visitor->trace(m_error);
|
| visitor->trace(m_requestList);
|
| visitor->trace(m_objectStoreMap);
|
| - visitor->trace(m_createdObjectStores);
|
| visitor->trace(m_deletedObjectStores);
|
| - visitor->trace(m_objectStoreCleanupMap);
|
| EventTargetWithInlineData::trace(visitor);
|
| ActiveDOMObject::trace(visitor);
|
| }
|
| @@ -163,18 +161,17 @@ IDBObjectStore* IDBTransaction::objectStore(const String& name, ExceptionState&
|
| const IDBDatabaseMetadata& metadata = m_database->metadata();
|
|
|
| IDBObjectStore* objectStore = IDBObjectStore::create(metadata.objectStores.get(objectStoreId), this);
|
| + DCHECK(!m_objectStoreMap.contains(name));
|
| m_objectStoreMap.set(name, objectStore);
|
| - m_objectStoreCleanupMap.set(objectStore, objectStore->metadata());
|
| return objectStore;
|
| }
|
|
|
| void IDBTransaction::objectStoreCreated(const String& name, IDBObjectStore* objectStore)
|
| {
|
| - ASSERT(m_state != Finished);
|
| - ASSERT(isVersionChange());
|
| + DCHECK(m_state != Finished);
|
| + DCHECK(isVersionChange());
|
| + DCHECK(!m_objectStoreMap.contains(name));
|
| m_objectStoreMap.set(name, objectStore);
|
| - m_objectStoreCleanupMap.set(objectStore, objectStore->metadata());
|
| - m_createdObjectStores.add(objectStore);
|
| }
|
|
|
| void IDBTransaction::objectStoreDeleted(const String& name)
|
| @@ -186,7 +183,6 @@ void IDBTransaction::objectStoreDeleted(const String& name)
|
| IDBObjectStore* objectStore = it->value;
|
| m_objectStoreMap.remove(name);
|
| objectStore->markDeleted();
|
| - m_objectStoreCleanupMap.set(objectStore, objectStore->metadata());
|
| m_deletedObjectStores.add(objectStore);
|
| }
|
| }
|
| @@ -219,9 +215,16 @@ void IDBTransaction::abort(ExceptionState& exceptionState)
|
| request->abort();
|
| m_requestList.clear();
|
|
|
| - for (IDBObjectStore* store : m_createdObjectStores) {
|
| - store->abort();
|
| - store->markDeleted();
|
| + if (isVersionChange()) {
|
| + // Marking created object stores as deleted.
|
| + for (auto storeMapIterator : m_objectStoreMap) {
|
| + IDBObjectStore* store = storeMapIterator.value;
|
| + auto it = m_previousMetadata.objectStores.find(store->id());
|
| + if (it == m_previousMetadata.objectStores.end()) {
|
| + store->versionChangeTransactionAborted();
|
| + store->markDeleted();
|
| + }
|
| + }
|
| }
|
|
|
| if (backendDB())
|
| @@ -261,24 +264,43 @@ void IDBTransaction::onAbort(DOMException* error)
|
| request->abort();
|
| m_requestList.clear();
|
|
|
| - // Newly created stores must be marked as deleted.
|
| - for (IDBObjectStore* store : m_createdObjectStores)
|
| - store->markDeleted();
|
| + if (isVersionChange()) {
|
| + for (IDBObjectStore* store : m_deletedObjectStores) {
|
| + if (!m_previousMetadata.objectStores.contains(store->id()))
|
| + store->markDeleted();
|
| + store->versionChangeTransactionAborted();
|
| + }
|
| +
|
| + for (const auto& storeMapIterator : m_objectStoreMap) {
|
| + IDBObjectStore* store = storeMapIterator.value;
|
| +
|
| + // Newly created stores must be marked as deleted.
|
| + if (!m_previousMetadata.objectStores.contains(store->id()))
|
| + store->markDeleted();
|
|
|
| - // Used stores may need to mark indexes as deleted.
|
| - for (auto& it : m_objectStoreCleanupMap)
|
| - it.key->abort();
|
| + // Modified stores may need to mark indexes as deleted.
|
| + store->versionChangeTransactionAborted();
|
| + }
|
| + }
|
|
|
| m_state = Finishing;
|
| }
|
|
|
| if (isVersionChange()) {
|
| - for (auto& it : m_objectStoreCleanupMap)
|
| - it.key->setMetadata(it.value);
|
| + for (IDBObjectStore* store : m_deletedObjectStores) {
|
| + const auto& it = m_previousMetadata.objectStores.find(store->id());
|
| + if (it != m_previousMetadata.objectStores.end())
|
| + store->rollbackMetadata(it->value);
|
| + }
|
| + for (const auto& storeMapIterator : m_objectStoreMap) {
|
| + IDBObjectStore* store = storeMapIterator.value;
|
| + const auto& it = m_previousMetadata.objectStores.find(store->id());
|
| + if (it != m_previousMetadata.objectStores.end())
|
| + store->rollbackMetadata(it->value);
|
| + }
|
| m_database->setMetadata(m_previousMetadata);
|
| m_database->close();
|
| }
|
| - m_objectStoreCleanupMap.clear();
|
|
|
| // Enqueue events before notifying database, as database may close which enqueues more events and order matters.
|
| enqueueEvent(Event::createBubble(EventTypeNames::abort));
|
| @@ -296,7 +318,6 @@ void IDBTransaction::onComplete()
|
|
|
| ASSERT(m_state != Finished);
|
| m_state = Finishing;
|
| - m_objectStoreCleanupMap.clear();
|
|
|
| // Enqueue events before notifying database, as database may close which enqueues more events and order matters.
|
| enqueueEvent(Event::create(EventTypeNames::complete));
|
| @@ -383,7 +404,6 @@ DispatchEventResult IDBTransaction::dispatchEventInternal(Event* event)
|
| m_objectStoreMap.clear();
|
| for (auto& it : m_deletedObjectStores)
|
| it->transactionFinished();
|
| - m_createdObjectStores.clear();
|
| m_deletedObjectStores.clear();
|
|
|
| HeapVector<Member<EventTarget>> targets;
|
|
|