Modern IDB: Add transactions and create/delete object store to SQLite backend
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jan 2016 20:37:42 +0000 (20:37 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jan 2016 20:37:42 +0000 (20:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153359

Reviewed by Alex Christensen.

Source/WebCore:

No new tests (Covered by many tests now passing).

* Modules/indexeddb/server/IDBBackingStore.h: Change deleteObjectStore to work on an ID instead of name.

* Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
(WebCore::IDBServer::MemoryIDBBackingStore::deleteObjectStore):
(WebCore::IDBServer::MemoryIDBBackingStore::takeObjectStoreByIdentifier):
(WebCore::IDBServer::MemoryIDBBackingStore::takeObjectStoreByName): Deleted.
* Modules/indexeddb/server/MemoryIDBBackingStore.h:

Clean up filename generation a bit to actually match the previous directory structure.
Add begin/commit/abort transaction support.
Add create/delete object store support:
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::filenameForDatabaseName):
(WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabaseDirectory):
(WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabasePath):
(WebCore::IDBServer::SQLiteIDBBackingStore::getOrEstablishDatabaseInfo):
(WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction):
(WebCore::IDBServer::SQLiteIDBBackingStore::abortTransaction):
(WebCore::IDBServer::SQLiteIDBBackingStore::commitTransaction):
(WebCore::IDBServer::SQLiteIDBBackingStore::createObjectStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteObjectStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteBackingStore):
* Modules/indexeddb/server/SQLiteIDBBackingStore.h:

Clean up SQLiteIDBTransaction to fit with the new WebCore backing store model, which is slightly
different from the old WebKit2 backing store model:
* Modules/indexeddb/server/SQLiteIDBTransaction.cpp:
(WebCore::IDBServer::SQLiteIDBTransaction::SQLiteIDBTransaction):
(WebCore::IDBServer::SQLiteIDBTransaction::begin):
(WebCore::IDBServer::SQLiteIDBTransaction::commit):
(WebCore::IDBServer::SQLiteIDBTransaction::abort):
(WebCore::IDBServer::SQLiteIDBTransaction::reset):
(WebCore::IDBServer::SQLiteIDBTransaction::rollback): Deleted.
* Modules/indexeddb/server/SQLiteIDBTransaction.h:
(WebCore::IDBServer::SQLiteIDBTransaction::transactionIdentifier):
(WebCore::IDBServer::SQLiteIDBTransaction::mode):

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::deleteObjectStore):
(WebCore::IDBServer::UniqueIDBDatabase::performDeleteObjectStore):
(WebCore::IDBServer::UniqueIDBDatabase::didPerformDeleteObjectStore):
* Modules/indexeddb/server/UniqueIDBDatabase.h:

* Modules/indexeddb/shared/IDBDatabaseInfo.cpp:
(WebCore::IDBDatabaseInfo::deleteObjectStore):
* Modules/indexeddb/shared/IDBDatabaseInfo.h:

* Modules/indexeddb/shared/IDBObjectStoreInfo.h:
(WebCore::IDBObjectStoreInfo::maxIndexID):

* Modules/indexeddb/shared/IDBTransactionInfo.h:
(WebCore::IDBTransactionInfo::identifier):

LayoutTests:

* platform/mac-wk1/TestExpectations:

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk1/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h
Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp
Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h
Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h
Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.cpp
Source/WebCore/Modules/indexeddb/server/SQLiteIDBTransaction.h
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h
Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.cpp
Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.h
Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.h
Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.h

index 5932055..346fd85 100644 (file)
@@ -1,3 +1,12 @@
+2016-01-22  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Add transactions and create/delete object store to SQLite backend
+        https://bugs.webkit.org/show_bug.cgi?id=153359
+
+        Reviewed by Alex Christensen.
+
+        * platform/mac-wk1/TestExpectations:
+
 2016-01-22  Chris Fleizach  <cfleizach@apple.com>
 
         AX: <code> group and friends should have a custom subrole
index 07dddbe..5cbd73b 100644 (file)
@@ -441,8 +441,6 @@ imported/w3c/indexeddb/transaction_bubble-and-capture.htm [ Failure ]
 imported/w3c/indexeddb/value.htm [ Failure ]
 imported/w3c/indexeddb/value_recursive.htm [ Failure ]
 imported/w3c/indexeddb/writer-starvation.htm [ Failure ]
-storage/indexeddb/aborted-versionchange-closes.html [ Failure ]
-storage/indexeddb/basics.html [ Failure ]
 storage/indexeddb/closed-cursor.html [ Failure ]
 storage/indexeddb/create-and-remove-object-store.html [ Failure ]
 storage/indexeddb/create-object-store-options.html [ Failure ]
@@ -468,21 +466,11 @@ storage/indexeddb/cursor-skip-deleted.html [ Failure ]
 storage/indexeddb/cursor-update-value-argument-required.html [ Failure ]
 storage/indexeddb/cursor-update.html [ Failure ]
 storage/indexeddb/cursor-value.html [ Failure ]
-storage/indexeddb/database-basics.html [ Failure ]
 storage/indexeddb/database-close.html [ Failure ]
-storage/indexeddb/database-closepending-flag.html [ Failure ]
-storage/indexeddb/database-deletepending-flag.html [ Failure ]
-storage/indexeddb/database-odd-names.html [ Failure ]
 storage/indexeddb/database-wrapper.html [ Failure ]
-storage/indexeddb/delete-in-upgradeneeded-close-in-open-success.html [ Failure ]
 storage/indexeddb/delete-range.html [ Failure ]
 storage/indexeddb/deleteIndex.html [ Failure ]
 storage/indexeddb/deleted-objects.html [ Failure ]
-storage/indexeddb/deletedatabase-blocked.html [ Failure ]
-storage/indexeddb/deletedatabase-delayed-by-open-and-versionchange.html [ Failure ]
-storage/indexeddb/deletedatabase-not-blocked.html [ Failure ]
-storage/indexeddb/deletedatabase-transaction.html [ Failure ]
-storage/indexeddb/dont-wedge.html [ Failure ]
 storage/indexeddb/duplicates.html [ Failure ]
 storage/indexeddb/error-causes-abort-by-default.html [ Failure ]
 storage/indexeddb/exception-in-event-aborts.html [ Failure ]
@@ -496,28 +484,10 @@ storage/indexeddb/index-duplicate-keypaths.html [ Failure ]
 storage/indexeddb/index-multientry.html [ Failure ]
 storage/indexeddb/index-population.html [ Failure ]
 storage/indexeddb/index-unique.html [ Failure ]
-storage/indexeddb/intversion-blocked.html [ Failure ]
-storage/indexeddb/intversion-close-between-events.html [ Failure ]
-storage/indexeddb/intversion-close-in-oncomplete.html [ Failure ]
-storage/indexeddb/intversion-close-in-upgradeneeded.html [ Failure ]
-storage/indexeddb/intversion-encoding.html [ Failure ]
-storage/indexeddb/intversion-gated-on-delete.html [ Failure ]
-storage/indexeddb/intversion-long-queue.html [ Failure ]
-storage/indexeddb/intversion-omit-parameter.html [ Failure ]
-storage/indexeddb/intversion-open-in-upgradeneeded.html [ Failure ]
-storage/indexeddb/intversion-open-with-version.html [ Failure ]
-storage/indexeddb/intversion-pending-version-changes-ascending.html [ Failure ]
-storage/indexeddb/intversion-pending-version-changes-descending.html [ Failure ]
-storage/indexeddb/intversion-pending-version-changes-same.html [ Failure ]
-storage/indexeddb/intversion-persistence.html [ Failure ]
-storage/indexeddb/intversion-revert-on-abort.html [ Failure ]
-storage/indexeddb/intversion-two-opens-no-versions.html [ Failure ]
-storage/indexeddb/intversion-upgrades.html [ Failure ]
 storage/indexeddb/key-generator.html [ Failure ]
 storage/indexeddb/key-sort-order-across-types.html [ Failure ]
 storage/indexeddb/key-sort-order-date.html [ Failure ]
 storage/indexeddb/key-type-array.html [ Failure ]
-storage/indexeddb/key-type-binary.html [ Failure ]
 storage/indexeddb/key-type-infinity.html [ Failure ]
 storage/indexeddb/keypath-arrays.html [ Failure ]
 storage/indexeddb/keypath-edges.html [ Failure ]
@@ -534,10 +504,8 @@ storage/indexeddb/modern/aborted-put.html [ Failure ]
 storage/indexeddb/modern/autoincrement-abort.html [ Failure ]
 storage/indexeddb/modern/basic-add.html [ Failure ]
 storage/indexeddb/modern/basic-put.html [ Failure ]
-storage/indexeddb/modern/blocked-open-db-requests.html [ Failure ]
 storage/indexeddb/modern/create-index-failures.html [ Failure ]
 storage/indexeddb/modern/createobjectstore-basic.html [ Failure ]
-storage/indexeddb/modern/createobjectstore-failures.html [ Failure ]
 storage/indexeddb/modern/cursor-1.html [ Failure ]
 storage/indexeddb/modern/cursor-2.html [ Failure ]
 storage/indexeddb/modern/cursor-3.html [ Failure ]
@@ -552,7 +520,6 @@ storage/indexeddb/modern/deletedatabase-2.html [ Failure ]
 storage/indexeddb/modern/deleteindex-1.html [ Failure ]
 storage/indexeddb/modern/deleteindex-2.html [ Failure ]
 storage/indexeddb/modern/deleteobjectstore-1.html [ Failure ]
-storage/indexeddb/modern/double-open.html [ Failure ]
 storage/indexeddb/modern/get-index-failures.html [ Failure ]
 storage/indexeddb/modern/get-keyrange.html [ Failure ]
 storage/indexeddb/modern/idbdatabase-deleteobjectstore-failures.html [ Failure ]
@@ -583,18 +550,13 @@ storage/indexeddb/modern/objectstore-attributes.html [ Failure ]
 storage/indexeddb/modern/objectstore-cursor-advance-failures.html [ Failure ]
 storage/indexeddb/modern/objectstore-cursor-continue-failures.html [ Failure ]
 storage/indexeddb/modern/opencursor-failures.html [ Failure ]
-storage/indexeddb/modern/opendatabase-success-after-versionchange.html [ Failure ]
-storage/indexeddb/modern/opendatabase-versions.html [ Failure ]
 storage/indexeddb/modern/request-readystate.html [ Failure ]
 storage/indexeddb/modern/transaction-scheduler-1.html [ Failure ]
 storage/indexeddb/modern/transaction-scheduler-2.html [ Failure ]
 storage/indexeddb/modern/transaction-scheduler-3.html [ Failure ]
-storage/indexeddb/modern/transaction-scheduler-4.html [ Failure ]
 storage/indexeddb/modern/transaction-scheduler-5.html [ Failure ]
 storage/indexeddb/modern/transaction-scheduler-6.html [ Failure ]
 storage/indexeddb/modern/transactions-stop-on-navigation.html [ Failure ]
-storage/indexeddb/modern/versionchange-abort-then-reopen.html [ Failure ]
-storage/indexeddb/modern/versionchange-event.html [ Failure ]
 storage/indexeddb/mozilla/add-twice-failure.html [ Failure ]
 storage/indexeddb/mozilla/autoincrement-indexes.html [ Failure ]
 storage/indexeddb/mozilla/bad-keypath.html [ Failure ]
@@ -606,7 +568,6 @@ storage/indexeddb/mozilla/cursor-update-updates-indexes.html [ Failure ]
 storage/indexeddb/mozilla/cursors.html [ Failure ]
 storage/indexeddb/mozilla/delete-result.html [ Failure ]
 storage/indexeddb/mozilla/event-source.html [ Failure ]
-storage/indexeddb/mozilla/global-data.html [ Failure ]
 storage/indexeddb/mozilla/index-prev-no-duplicate.html [ Failure ]
 storage/indexeddb/mozilla/indexes.html [ Failure ]
 storage/indexeddb/mozilla/key-requirements.html [ Failure ]
@@ -615,15 +576,12 @@ storage/indexeddb/mozilla/object-identity.html [ Failure ]
 storage/indexeddb/mozilla/object-store-inline-autoincrement-key-added-on-put.html [ Failure ]
 storage/indexeddb/mozilla/object-store-remove-values.html [ Failure ]
 storage/indexeddb/mozilla/odd-result-order.html [ Failure ]
-storage/indexeddb/mozilla/open-database-null-name.html [ Failure ]
 storage/indexeddb/mozilla/put-get-values.html [ Failure ]
-storage/indexeddb/mozilla/readonly-transactions.html [ Failure ]
 storage/indexeddb/mozilla/readwrite-transactions.html [ Failure ]
 storage/indexeddb/mozilla/readyState.html [ Failure ]
 storage/indexeddb/mozilla/remove-objectstore.html [ Failure ]
 storage/indexeddb/mutating-cursor.html [ Failure ]
 storage/indexeddb/noblobs.html [ Failure ]
-storage/indexeddb/object-lookups-in-versionchange.html [ Failure ]
 storage/indexeddb/objectstore-autoincrement.html [ Failure ]
 storage/indexeddb/objectstore-basics.html [ Failure ]
 storage/indexeddb/objectstore-clear.html [ Failure ]
@@ -633,50 +591,36 @@ storage/indexeddb/objectstore-removeobjectstore.html [ Failure ]
 storage/indexeddb/odd-strings.html [ Failure ]
 storage/indexeddb/open-cursor.html [ Failure ]
 storage/indexeddb/open-during-transaction.html [ Failure ]
-storage/indexeddb/open-ordering.html [ Failure ]
 storage/indexeddb/opencursor-key.html [ Failure ]
 storage/indexeddb/optional-arguments.html [ Failure ]
 storage/indexeddb/pending-activity.html [ Failure ]
-storage/indexeddb/persistence.html [ Failure ]
 storage/indexeddb/prefetch-bugfix-108071.html [ Failure ]
-storage/indexeddb/prefetch-invalidation.html [ Failure ]
 storage/indexeddb/prefetch-race.html [ Failure ]
 storage/indexeddb/queued-commands.html [ Failure ]
 storage/indexeddb/readonly.html [ Failure ]
 storage/indexeddb/request-continue-abort.html [ Failure ]
 storage/indexeddb/request-event-propagation.html [ Failure ]
 storage/indexeddb/request-result-cache.html [ Failure ]
-storage/indexeddb/set_version_blocked.html [ Failure ]
-storage/indexeddb/setversion-blocked-by-versionchange-close.html [ Failure ]
-storage/indexeddb/setversion-not-blocked.html [ Failure ]
 storage/indexeddb/structured-clone.html [ Failure ]
 storage/indexeddb/transaction-abort.html [ Failure ]
 storage/indexeddb/transaction-active-flag.html [ Failure ]
 storage/indexeddb/transaction-after-close.html [ Failure ]
 storage/indexeddb/transaction-and-objectstore-calls.html [ Failure ]
 storage/indexeddb/transaction-basics.html [ Failure ]
-storage/indexeddb/transaction-complete-with-js-recursion-cross-frame.html [ Failure ]
-storage/indexeddb/transaction-complete-with-js-recursion.html [ Failure ]
 storage/indexeddb/transaction-coordination-across-databases.html [ Failure ]
 storage/indexeddb/transaction-coordination-within-database.html [ Failure ]
-storage/indexeddb/transaction-crash-on-abort.html [ Failure ]
 storage/indexeddb/transaction-error.html [ Failure ]
 storage/indexeddb/transaction-event-propagation.html [ Failure ]
-storage/indexeddb/transaction-ordering.html [ Failure ]
 storage/indexeddb/transaction-overlapping.html [ Failure ]
 storage/indexeddb/transaction-read-only.html [ Failure ]
 storage/indexeddb/transaction-readwrite-exclusive.html [ Failure ]
 storage/indexeddb/transaction-rollback.html [ Failure ]
 storage/indexeddb/transaction-scope-sequencing.html [ Failure ]
-storage/indexeddb/unblocked-version-changes.html [ Failure ]
 storage/indexeddb/value-undefined.html [ Failure ]
 storage/indexeddb/values-odd-types.html [ Failure ]
-storage/indexeddb/version-change-abort.html [ Failure ]
-storage/indexeddb/version-change-event.html [ Failure ]
 storage/indexeddb/version-change-exclusive.html [ Failure ]
-storage/indexeddb/versionchangerequest-activedomobject.html [ Failure ]
 
-#SQLite backend tests that timeout
+# SQLite backend tests that timeout
 crypto/subtle/rsa-indexeddb.html [ Skip ]
 imported/w3c/indexeddb/idbcursor-advance-continue-async.htm [ Skip ]
 imported/w3c/indexeddb/idbcursor-advance-invalid.htm [ Skip ]
@@ -687,7 +631,16 @@ imported/w3c/indexeddb/idbfactory_open12.htm [ Skip ]
 imported/w3c/indexeddb/idbindex-multientry-big.htm [ Skip ]
 imported/w3c/indexeddb/idbobjectstore_openCursor_invalid.htm [ Skip ]
 imported/w3c/indexeddb/keypath.htm [ Skip ]
+storage/indexeddb/deletedatabase-transaction.html [ Skip ]
+storage/indexeddb/modern/blocked-open-db-requests.html [ Skip ]
+storage/indexeddb/modern/transaction-scheduler-4.html [ Skip ]
+storage/indexeddb/prefetch-invalidation.html [ Skip ]
 storage/indexeddb/primary-key-unique-to-objectstore.html [ Skip ]
+storage/indexeddb/transaction-ordering.html [ Skip ]
+
+# SQLite backend tests that ASSERT
+storage/indexeddb/database-odd-names.html [ Skip ]
+storage/indexeddb/dont-wedge.html [ Skip ]
 
 ### END OF (3) IndexedDB failures with SQLite
 ########################################
index 74e992d..95486c2 100644 (file)
@@ -1,3 +1,65 @@
+2016-01-22  Brady Eidson  <beidson@apple.com>
+
+        Modern IDB: Add transactions and create/delete object store to SQLite backend
+        https://bugs.webkit.org/show_bug.cgi?id=153359
+
+        Reviewed by Alex Christensen.
+
+        No new tests (Covered by many tests now passing).
+
+        * Modules/indexeddb/server/IDBBackingStore.h: Change deleteObjectStore to work on an ID instead of name.
+
+        * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+        (WebCore::IDBServer::MemoryIDBBackingStore::deleteObjectStore):
+        (WebCore::IDBServer::MemoryIDBBackingStore::takeObjectStoreByIdentifier):
+        (WebCore::IDBServer::MemoryIDBBackingStore::takeObjectStoreByName): Deleted.
+        * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+
+        Clean up filename generation a bit to actually match the previous directory structure.
+        Add begin/commit/abort transaction support.
+        Add create/delete object store support:
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::filenameForDatabaseName):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabaseDirectory):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabasePath):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::getOrEstablishDatabaseInfo):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::abortTransaction):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::commitTransaction):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::createObjectStore):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteObjectStore):
+        (WebCore::IDBServer::SQLiteIDBBackingStore::deleteBackingStore):
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+        
+        Clean up SQLiteIDBTransaction to fit with the new WebCore backing store model, which is slightly
+        different from the old WebKit2 backing store model:
+        * Modules/indexeddb/server/SQLiteIDBTransaction.cpp:
+        (WebCore::IDBServer::SQLiteIDBTransaction::SQLiteIDBTransaction):
+        (WebCore::IDBServer::SQLiteIDBTransaction::begin):
+        (WebCore::IDBServer::SQLiteIDBTransaction::commit):
+        (WebCore::IDBServer::SQLiteIDBTransaction::abort):
+        (WebCore::IDBServer::SQLiteIDBTransaction::reset):
+        (WebCore::IDBServer::SQLiteIDBTransaction::rollback): Deleted.
+        * Modules/indexeddb/server/SQLiteIDBTransaction.h:
+        (WebCore::IDBServer::SQLiteIDBTransaction::transactionIdentifier):
+        (WebCore::IDBServer::SQLiteIDBTransaction::mode):
+        
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::UniqueIDBDatabase::deleteObjectStore):
+        (WebCore::IDBServer::UniqueIDBDatabase::performDeleteObjectStore):
+        (WebCore::IDBServer::UniqueIDBDatabase::didPerformDeleteObjectStore):
+        * Modules/indexeddb/server/UniqueIDBDatabase.h:
+        
+        * Modules/indexeddb/shared/IDBDatabaseInfo.cpp:
+        (WebCore::IDBDatabaseInfo::deleteObjectStore):
+        * Modules/indexeddb/shared/IDBDatabaseInfo.h:
+        
+        * Modules/indexeddb/shared/IDBObjectStoreInfo.h:
+        (WebCore::IDBObjectStoreInfo::maxIndexID):
+        
+        * Modules/indexeddb/shared/IDBTransactionInfo.h:
+        (WebCore::IDBTransactionInfo::identifier):
+
 2016-01-22  Antti Koivisto  <antti@apple.com>
 
         Style resolver initialization cleanups
index 94c04af..7708792 100644 (file)
@@ -61,7 +61,7 @@ public:
     virtual IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) = 0;
 
     virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) = 0;
-    virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName) = 0;
+    virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0;
     virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) = 0;
     virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) = 0;
     virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& indexName) = 0;
index d63e694..90f795b 100644 (file)
@@ -145,24 +145,24 @@ IDBError MemoryIDBBackingStore::createObjectStore(const IDBResourceIdentifier& t
     return IDBError();
 }
 
-IDBError MemoryIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName)
+IDBError MemoryIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
 {
     LOG(IndexedDB, "MemoryIDBBackingStore::deleteObjectStore");
 
     ASSERT(m_databaseInfo);
-    if (!m_databaseInfo->hasObjectStore(objectStoreName))
+    if (!m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier))
         return IDBError(IDBDatabaseException::ConstraintError);
 
     auto transaction = m_transactions.get(transactionIdentifier);
     ASSERT(transaction);
     ASSERT(transaction->isVersionChange());
 
-    auto objectStore = takeObjectStoreByName(objectStoreName);
+    auto objectStore = takeObjectStoreByIdentifier(objectStoreIdentifier);
     ASSERT(objectStore);
     if (!objectStore)
         return IDBError(IDBDatabaseException::ConstraintError);
 
-    m_databaseInfo->deleteObjectStore(objectStoreName);
+    m_databaseInfo->deleteObjectStore(objectStore->info().name());
     transaction->objectStoreDeleted(*objectStore);
 
     return IDBError();
@@ -469,16 +469,16 @@ void MemoryIDBBackingStore::unregisterObjectStore(MemoryObjectStore& objectStore
     m_objectStoresByIdentifier.remove(objectStore.info().identifier());
 }
 
-RefPtr<MemoryObjectStore> MemoryIDBBackingStore::takeObjectStoreByName(const String& name)
+RefPtr<MemoryObjectStore> MemoryIDBBackingStore::takeObjectStoreByIdentifier(uint64_t identifier)
 {
-    auto objectStoreByName = m_objectStoresByName.take(name);
-    if (!objectStoreByName)
+    auto objectStoreByIdentifier = m_objectStoresByIdentifier.take(identifier);
+    if (!objectStoreByIdentifier)
         return nullptr;
 
-    auto objectStore = m_objectStoresByIdentifier.take(objectStoreByName->info().identifier());
-    ASSERT(objectStore);
+    auto objectStore = m_objectStoresByName.take(objectStoreByIdentifier->info().name());
+    ASSERT_UNUSED(objectStore, objectStore);
 
-    return objectStore;
+    return objectStoreByIdentifier;
 }
 
 void MemoryIDBBackingStore::deleteBackingStore()
index 0b06abe..54f04f9 100644 (file)
@@ -53,7 +53,7 @@ public:
     virtual IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier) override final;
     virtual IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) override final;
     virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) override final;
-    virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName) override final;
+    virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) override final;
     virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) override final;
     virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) override final;
     virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& indexName) override final;
@@ -77,7 +77,7 @@ public:
 private:
     MemoryIDBBackingStore(const IDBDatabaseIdentifier&);
 
-    RefPtr<MemoryObjectStore> takeObjectStoreByName(const String& name);
+    RefPtr<MemoryObjectStore> takeObjectStoreByIdentifier(uint64_t identifier);
 
     IDBDatabaseIdentifier m_identifier;
     std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
index 03f804f..6ba7e41 100644 (file)
 #if ENABLE(INDEXED_DATABASE)
 
 #include "FileSystem.h"
+#include "IDBBindingUtilities.h"
 #include "IDBDatabaseException.h"
 #include "IDBKeyData.h"
 #include "IDBSerialization.h"
 #include "IDBTransactionInfo.h"
+#include "IndexKey.h"
 #include "Logging.h"
 #include "SQLiteDatabase.h"
 #include "SQLiteFileSystem.h"
@@ -41,6 +43,8 @@
 #include "SQLiteTransaction.h"
 #include <wtf/NeverDestroyed.h>
 
+using namespace JSC;
+
 namespace WebCore {
 namespace IDBServer {
 
@@ -390,6 +394,33 @@ std::unique_ptr<IDBDatabaseInfo> SQLiteIDBBackingStore::extractExistingDatabaseI
     return databaseInfo;
 }
 
+String SQLiteIDBBackingStore::filenameForDatabaseName() const
+{
+    ASSERT(!m_identifier.databaseName().isNull());
+
+    if (m_identifier.databaseName().isEmpty())
+        return "%00";
+
+    String filename = encodeForFileName(m_identifier.databaseName());
+    filename.replace('.', "%2E");
+
+    return filename;
+}
+
+String SQLiteIDBBackingStore::fullDatabaseDirectory() const
+{
+    ASSERT(!m_identifier.databaseName().isNull());
+
+    return pathByAppendingComponent(m_absoluteDatabaseDirectory, filenameForDatabaseName());
+}
+
+String SQLiteIDBBackingStore::fullDatabasePath() const
+{
+    ASSERT(!m_identifier.databaseName().isNull());
+
+    return pathByAppendingComponent(fullDatabaseDirectory(), "IndexedDB.sqlite3");
+}
+
 const IDBDatabaseInfo& SQLiteIDBBackingStore::getOrEstablishDatabaseInfo()
 {
     LOG(IndexedDB, "SQLiteIDBBackingStore::getOrEstablishDatabaseInfo - database %s", m_identifier.databaseName().utf8().data());
@@ -399,9 +430,8 @@ const IDBDatabaseInfo& SQLiteIDBBackingStore::getOrEstablishDatabaseInfo()
 
     m_databaseInfo = std::make_unique<IDBDatabaseInfo>(m_identifier.databaseName(), 0);
 
-    makeAllDirectories(m_absoluteDatabaseDirectory);
-
-    String dbFilename = pathByAppendingComponent(m_absoluteDatabaseDirectory, "IndexedDB.sqlite3");
+    makeAllDirectories(fullDatabaseDirectory());
+    String dbFilename = fullDatabasePath();
 
     m_sqliteDB = std::make_unique<SQLiteDatabase>();
     if (!m_sqliteDB->open(dbFilename)) {
@@ -437,38 +467,175 @@ const IDBDatabaseInfo& SQLiteIDBBackingStore::getOrEstablishDatabaseInfo()
 IDBError SQLiteIDBBackingStore::beginTransaction(const IDBTransactionInfo& info)
 {
     LOG(IndexedDB, "SQLiteIDBBackingStore::beginTransaction - %s", info.identifier().loggingString().utf8().data());
-    UNUSED_PARAM(info);
 
-    return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") };
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB->isOpen());
+
+    auto addResult = m_transactions.add(info.identifier(), nullptr);
+    if (!addResult.isNewEntry) {
+        LOG_ERROR("Attempt to establish transaction identifier that already exists");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to establish transaction identifier that already exists") };
+    }
+
+    addResult.iterator->value = std::make_unique<SQLiteIDBTransaction>(*this, info);
+    return addResult.iterator->value->begin(*m_sqliteDB);
 }
 
 IDBError SQLiteIDBBackingStore::abortTransaction(const IDBResourceIdentifier& identifier)
 {
     LOG(IndexedDB, "SQLiteIDBBackingStore::abortTransaction - %s", identifier.loggingString().utf8().data());
-    UNUSED_PARAM(identifier);
 
-    return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") };
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB->isOpen());
+
+    auto transaction = m_transactions.take(identifier);
+    if (!transaction) {
+        LOG_ERROR("Attempt to commit a transaction that hasn't been established");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to abort a transaction that hasn't been established") };
+    }
+
+    return transaction->abort();
 }
 
 IDBError SQLiteIDBBackingStore::commitTransaction(const IDBResourceIdentifier& identifier)
 {
     LOG(IndexedDB, "SQLiteIDBBackingStore::commitTransaction - %s", identifier.loggingString().utf8().data());
-    UNUSED_PARAM(identifier);
 
-    return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") };
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB->isOpen());
+
+    auto transaction = m_transactions.take(identifier);
+    if (!transaction) {
+        LOG_ERROR("Attempt to commit a transaction that hasn't been established");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to commit a transaction that hasn't been established") };
+    }
+
+    return transaction->commit();
 }
 
-IDBError SQLiteIDBBackingStore::createObjectStore(const IDBResourceIdentifier&, const IDBObjectStoreInfo& info)
+IDBError SQLiteIDBBackingStore::createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo& info)
 {
     LOG(IndexedDB, "SQLiteIDBBackingStore::createObjectStore - adding OS %s with ID %" PRIu64, info.name().utf8().data(), info.identifier());
-    UNUSED_PARAM(info);
 
-    return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") };
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB->isOpen());
+
+    auto* transaction = m_transactions.get(transactionIdentifier);
+    if (!transaction || !transaction->inProgress()) {
+        LOG_ERROR("Attempt to create an object store without an in-progress transaction");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to create an object store without an in-progress transaction") };
+    }
+    if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
+        LOG_ERROR("Attempt to create an object store in a non-version-change transaction");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to create an object store in a non-version-change transaction") };
+    }
+
+    RefPtr<SharedBuffer> keyPathBlob = serializeIDBKeyPath(info.keyPath());
+    if (!keyPathBlob) {
+        LOG_ERROR("Unable to serialize IDBKeyPath to save in database for new object store");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to serialize IDBKeyPath to save in database for new object store") };
+    }
+
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("INSERT INTO ObjectStoreInfo VALUES (?, ?, ?, ?, ?);"));
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindInt64(1, info.identifier()) != SQLITE_OK
+            || sql.bindText(2, info.name()) != SQLITE_OK
+            || sql.bindBlob(3, keyPathBlob->data(), keyPathBlob->size()) != SQLITE_OK
+            || sql.bindInt(4, info.autoIncrement()) != SQLITE_OK
+            || sql.bindInt64(5, info.maxIndexID()) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR("Could not add object store '%s' to ObjectStoreInfo table (%i) - %s", info.name().utf8().data(), m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not create object store") };
+        }
+    }
+
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("INSERT INTO KeyGenerators VALUES (?, 0);"));
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindInt64(1, info.identifier()) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR("Could not seed initial key generator value for ObjectStoreInfo table (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not seed initial key generator value for object store") };
+        }
+    }
+
+    return { };
 }
 
-IDBError SQLiteIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier&, const String&)
+IDBError SQLiteIDBBackingStore::deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
 {
-    return { IDBDatabaseException::UnknownError, ASCIILiteral("Not implemented") };
+    LOG(IndexedDB, "SQLiteIDBBackingStore::deleteObjectStore - object store %" PRIu64, objectStoreIdentifier);
+
+    ASSERT(m_sqliteDB);
+    ASSERT(m_sqliteDB->isOpen());
+
+    auto* transaction = m_transactions.get(transactionIdentifier);
+    if (!transaction || !transaction->inProgress()) {
+        LOG_ERROR("Attempt to delete an object store without an in-progress transaction");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to delete an object store without an in-progress transaction") };
+    }
+    if (transaction->mode() != IndexedDB::TransactionMode::VersionChange) {
+        LOG_ERROR("Attempt to delete an object store in a non-version-change transaction");
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to delete an object store in a non-version-change transaction") };
+    }
+
+    // Delete the ObjectStore record
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("DELETE FROM ObjectStoreInfo WHERE id = ?;"));
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindInt64(1, objectStoreIdentifier) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR("Could not delete object store id %" PRIi64 " from ObjectStoreInfo table (%i) - %s", objectStoreIdentifier, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not delete object store") };
+        }
+    }
+
+    // Delete the ObjectStore's key generator record if there is one.
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("DELETE FROM KeyGenerators WHERE objectStoreID = ?;"));
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindInt64(1, objectStoreIdentifier) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR("Could not delete object store from KeyGenerators table (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not delete key generator for deleted object store") };
+        }
+    }
+
+    // Delete all associated records
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("DELETE FROM Records WHERE objectStoreID = ?;"));
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindInt64(1, objectStoreIdentifier) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR("Could not delete records for object store %" PRIi64 " (%i) - %s", objectStoreIdentifier, m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not delete records for deleted object store") };
+        }
+    }
+
+    // Delete all associated Indexes
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("DELETE FROM IndexInfo WHERE objectStoreID = ?;"));
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindInt64(1, objectStoreIdentifier) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR("Could not delete index from IndexInfo table (%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not delete IDBIndex for deleted object store") };
+        }
+    }
+
+    // Delete all associated Index records
+    {
+        SQLiteStatement sql(*m_sqliteDB, ASCIILiteral("DELETE FROM IndexRecords WHERE objectStoreID = ?;"));
+        if (sql.prepare() != SQLITE_OK
+            || sql.bindInt64(1, objectStoreIdentifier) != SQLITE_OK
+            || sql.step() != SQLITE_DONE) {
+            LOG_ERROR("Could not delete index records(%i) - %s", m_sqliteDB->lastError(), m_sqliteDB->lastErrorMsg());
+            return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not delete IDBIndex records for deleted object store") };
+        }
+    }
+
+    return true;
 }
 
 IDBError SQLiteIDBBackingStore::clearObjectStore(const IDBResourceIdentifier&, uint64_t)
@@ -543,7 +710,7 @@ IDBError SQLiteIDBBackingStore::iterateCursor(const IDBResourceIdentifier&, cons
 
 void SQLiteIDBBackingStore::deleteBackingStore()
 {
-    String dbFilename = pathByAppendingComponent(m_absoluteDatabaseDirectory, "IndexedDB.sqlite3");
+    String dbFilename = fullDatabasePath();
 
     LOG(IndexedDB, "SQLiteIDBBackingStore::deleteBackingStore deleting file '%s' on disk", dbFilename.utf8().data());
 
index a6bd9be..be2cfc2 100644 (file)
@@ -55,7 +55,7 @@ public:
     virtual IDBError abortTransaction(const IDBResourceIdentifier& transactionIdentifier) override final;
     virtual IDBError commitTransaction(const IDBResourceIdentifier& transactionIdentifier) override final;
     virtual IDBError createObjectStore(const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&) override final;
-    virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName) override final;
+    virtual IDBError deleteObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) override final;
     virtual IDBError clearObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier) override final;
     virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) override final;
     virtual IDBError deleteIndex(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& indexName) override final;
@@ -76,6 +76,10 @@ public:
     void unregisterCursor(SQLiteIDBCursor&);
 
 private:
+    String filenameForDatabaseName() const;
+    String fullDatabaseDirectory() const;
+    String fullDatabasePath() const;
+
     bool ensureValidRecordsTable();
     std::unique_ptr<IDBDatabaseInfo> createAndPopulateInitialDatabaseInfo();
     std::unique_ptr<IDBDatabaseInfo> extractExistingDatabaseInfo();
index f7ce8ef..1484fce 100644 (file)
@@ -36,9 +36,8 @@
 namespace WebCore {
 namespace IDBServer {
 
-SQLiteIDBTransaction::SQLiteIDBTransaction(SQLiteIDBBackingStore& backingStore, const IDBResourceIdentifier& transactionIdentifier, IndexedDB::TransactionMode mode)
-    : m_identifier(transactionIdentifier)
-    , m_mode(mode)
+SQLiteIDBTransaction::SQLiteIDBTransaction(SQLiteIDBBackingStore& backingStore, const IDBTransactionInfo& info)
+    : m_info(info)
     , m_backingStore(backingStore)
 {
 }
@@ -53,43 +52,51 @@ SQLiteIDBTransaction::~SQLiteIDBTransaction()
 }
 
 
-bool SQLiteIDBTransaction::begin(SQLiteDatabase& database)
+IDBError SQLiteIDBTransaction::begin(SQLiteDatabase& database)
 {
     ASSERT(!m_sqliteTransaction);
-    m_sqliteTransaction = std::make_unique<SQLiteTransaction>(database, m_mode == IndexedDB::TransactionMode::ReadOnly);
 
+    m_sqliteTransaction = std::make_unique<SQLiteTransaction>(database, m_info.mode() == IndexedDB::TransactionMode::ReadOnly);
     m_sqliteTransaction->begin();
 
-    return m_sqliteTransaction->inProgress();
+    if (m_sqliteTransaction->inProgress())
+        return { };
+
+    return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not start SQLite transaction in database backend") };
 }
 
-bool SQLiteIDBTransaction::commit()
+IDBError SQLiteIDBTransaction::commit()
 {
-    // It's okay to not have a SQLite transaction or not have started it yet because it's okay for a WebProcess
-    // to request the commit of a transaction immediately after creating it before it has even been used.
     if (!m_sqliteTransaction || !m_sqliteTransaction->inProgress())
-        return false;
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("No SQLite transaction in progress to commit") };
 
     m_sqliteTransaction->commit();
 
-    return !m_sqliteTransaction->inProgress();
+    if (m_sqliteTransaction->inProgress())
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to commit SQLite transaction in database backend") };
+
+    reset();
+    return { };
 }
 
-bool SQLiteIDBTransaction::reset()
+IDBError SQLiteIDBTransaction::abort()
 {
-    m_sqliteTransaction = nullptr;
-    clearCursors();
+    if (!m_sqliteTransaction || !m_sqliteTransaction->inProgress())
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("No SQLite transaction in progress to abort") };
 
-    return true;
-}
+    m_sqliteTransaction->rollback();
 
-bool SQLiteIDBTransaction::rollback()
-{
-    ASSERT(m_sqliteTransaction);
     if (m_sqliteTransaction->inProgress())
-        m_sqliteTransaction->rollback();
+        return { IDBDatabaseException::UnknownError, ASCIILiteral("Unable to abort SQLite transaction in database backend") };
+
+    reset();
+    return { };
+}
 
-    return true;
+void SQLiteIDBTransaction::reset()
+{
+    m_sqliteTransaction = nullptr;
+    clearCursors();
 }
 
 SQLiteIDBCursor* SQLiteIDBTransaction::maybeOpenCursor(const IDBCursorInfo& info)
index 4968543..efb84a9 100644 (file)
@@ -28,7 +28,9 @@
 
 #if ENABLE(INDEXED_DATABASE)
 
+#include "IDBError.h"
 #include "IDBResourceIdentifier.h"
+#include "IDBTransactionInfo.h"
 #include "IndexedDB.h"
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
@@ -48,31 +50,30 @@ class SQLiteIDBCursor;
 class SQLiteIDBTransaction {
     WTF_MAKE_NONCOPYABLE(SQLiteIDBTransaction);
 public:
-    SQLiteIDBTransaction(SQLiteIDBBackingStore&, const IDBResourceIdentifier& transactionIdentifier, IndexedDB::TransactionMode);
+    SQLiteIDBTransaction(SQLiteIDBBackingStore&, const IDBTransactionInfo&);
     ~SQLiteIDBTransaction();
 
-    const IDBResourceIdentifier& transactionIdentifier() const { return m_identifier; }
+    const IDBResourceIdentifier& transactionIdentifier() const { return m_info.identifier(); }
 
-    bool begin(SQLiteDatabase&);
-    bool commit();
-    bool reset();
-    bool rollback();
+    IDBError begin(SQLiteDatabase&);
+    IDBError commit();
+    IDBError abort();
 
     SQLiteIDBCursor* maybeOpenCursor(const IDBCursorInfo&);
 
     void closeCursor(SQLiteIDBCursor&);
     void notifyCursorsOfChanges(int64_t objectStoreID);
 
-    IndexedDB::TransactionMode mode() const { return m_mode; }
+    IndexedDB::TransactionMode mode() const { return m_info.mode(); }
     bool inProgress() const;
 
     SQLiteTransaction* sqliteTransaction() const { return m_sqliteTransaction.get(); }
 
 private:
     void clearCursors();
+    void reset();
 
-    IDBResourceIdentifier m_identifier;
-    IndexedDB::TransactionMode m_mode;
+    IDBTransactionInfo m_info;
 
     SQLiteIDBBackingStore& m_backingStore;
     std::unique_ptr<SQLiteTransaction> m_sqliteTransaction;
index f69802e..ef3139c 100644 (file)
@@ -502,28 +502,35 @@ void UniqueIDBDatabase::deleteObjectStore(UniqueIDBDatabaseTransaction& transact
     LOG(IndexedDB, "(main) UniqueIDBDatabase::deleteObjectStore");
 
     uint64_t callbackID = storeCallback(callback);
-    m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performDeleteObjectStore, callbackID, transaction.info().identifier(), objectStoreName));
+
+    auto* info = m_databaseInfo->infoForExistingObjectStore(objectStoreName);
+    if (!info) {
+        performErrorCallback(callbackID, { IDBDatabaseException::UnknownError, ASCIILiteral("Attempt to delete non-existant object store") });
+        return;
+    }
+
+    m_server.postDatabaseTask(createCrossThreadTask(*this, &UniqueIDBDatabase::performDeleteObjectStore, callbackID, transaction.info().identifier(), info->identifier()));
 }
 
-void UniqueIDBDatabase::performDeleteObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName)
+void UniqueIDBDatabase::performDeleteObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier)
 {
     ASSERT(!isMainThread());
     LOG(IndexedDB, "(db) UniqueIDBDatabase::performDeleteObjectStore");
 
     ASSERT(m_backingStore);
-    m_backingStore->deleteObjectStore(transactionIdentifier, objectStoreName);
+    m_backingStore->deleteObjectStore(transactionIdentifier, objectStoreIdentifier);
 
     IDBError error;
-    m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformDeleteObjectStore, callbackIdentifier, error, objectStoreName));
+    m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformDeleteObjectStore, callbackIdentifier, error, objectStoreIdentifier));
 }
 
-void UniqueIDBDatabase::didPerformDeleteObjectStore(uint64_t callbackIdentifier, const IDBError& error, const String& objectStoreName)
+void UniqueIDBDatabase::didPerformDeleteObjectStore(uint64_t callbackIdentifier, const IDBError& error, uint64_t objectStoreIdentifier)
 {
     ASSERT(isMainThread());
     LOG(IndexedDB, "(main) UniqueIDBDatabase::didPerformDeleteObjectStore");
 
     if (error.isNull())
-        m_databaseInfo->deleteObjectStore(objectStoreName);
+        m_databaseInfo->deleteObjectStore(objectStoreIdentifier);
 
     performErrorCallback(callbackIdentifier, error);
 }
index a3fec21..e7d2fe2 100644 (file)
@@ -131,7 +131,7 @@ private:
     void performAbortTransaction(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier);
     void beginTransactionInBackingStore(const IDBTransactionInfo&);
     void performCreateObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const IDBObjectStoreInfo&);
-    void performDeleteObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const String& objectStoreName);
+    void performDeleteObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier);
     void performClearObjectStore(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier);
     void performCreateIndex(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&);
     void performDeleteIndex(uint64_t callbackIdentifier, const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const String& indexName);
@@ -148,7 +148,7 @@ private:
     void didDeleteBackingStore();
     void didOpenBackingStore(const IDBDatabaseInfo&);
     void didPerformCreateObjectStore(uint64_t callbackIdentifier, const IDBError&, const IDBObjectStoreInfo&);
-    void didPerformDeleteObjectStore(uint64_t callbackIdentifier, const IDBError&, const String& objectStoreName);
+    void didPerformDeleteObjectStore(uint64_t callbackIdentifier, const IDBError&, uint64_t objectStoreIdentifier);
     void didPerformClearObjectStore(uint64_t callbackIdentifier, const IDBError&);
     void didPerformCreateIndex(uint64_t callbackIdentifier, const IDBError&, const IDBIndexInfo&);
     void didPerformDeleteIndex(uint64_t callbackIdentifier, const IDBError&, uint64_t objectStoreIdentifier, const String& indexName);
index 44aa47e..9de5f42 100644 (file)
@@ -135,6 +135,11 @@ void IDBDatabaseInfo::deleteObjectStore(const String& objectStoreName)
     m_objectStoreMap.remove(info->identifier());
 }
 
+void IDBDatabaseInfo::deleteObjectStore(uint64_t objectStoreIdentifier)
+{
+    m_objectStoreMap.remove(objectStoreIdentifier);
+}
+
 #ifndef NDEBUG
 String IDBDatabaseInfo::loggingString() const
 {
index b330345..a1315aa 100644 (file)
@@ -57,6 +57,7 @@ public:
     Vector<String> objectStoreNames() const;
 
     void deleteObjectStore(const String& objectStoreName);
+    void deleteObjectStore(uint64_t objectStoreIdentifier);
 
 #ifndef NDEBUG
     String loggingString() const;
index ffbd03e..6f0f31f 100644 (file)
@@ -46,6 +46,7 @@ public:
     const String& name() const { return m_name; }
     const IDBKeyPath& keyPath() const { return m_keyPath; }
     bool autoIncrement() const { return m_autoIncrement; }
+    uint64_t maxIndexID() const { return m_maxIndexID; }
 
     IDBObjectStoreInfo isolatedCopy() const;
 
index bbec74b..ed8a384 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     IDBTransactionInfo isolatedCopy() const;
 
-    IDBResourceIdentifier identifier() const { return m_identifier; }
+    const IDBResourceIdentifier& identifier() const { return m_identifier; }
 
     IndexedDB::TransactionMode mode() const { return m_mode; }
     uint64_t newVersion() const { return m_newVersion; }