haikuwebkit/Source/WebKitLegacy/Storage
Sihui Liu 50e5506e95 Implement IDBTransaction.commit()
https://bugs.webkit.org/show_bug.cgi?id=227815
<rdar://problem/80651270>

Reviewed by Brady Eidson.

LayoutTests/imported/w3c:

* web-platform-tests/IndexedDB/idb-explicit-commit-throw.any-expected.txt:
* web-platform-tests/IndexedDB/idb-explicit-commit-throw.any.worker-expected.txt:
* web-platform-tests/IndexedDB/idb-explicit-commit.any-expected.txt: Some test is timed out as our backend does
not support running multiple transactions simultaneously now.
* web-platform-tests/IndexedDB/idb-explicit-commit.any.worker-expected.txt: Ditto.
* web-platform-tests/IndexedDB/idlharness.any-expected.txt:
* web-platform-tests/IndexedDB/idlharness.any.worker-expected.txt:

Source/WebCore:

Spec: https://www.w3.org/TR/IndexedDB/#dom-idbtransaction-commit

Commit request for IDBTransaction is created automatically after all its requests are completed and success
events of those requests are fired. IDBTransaction.commit() lets client create commit request, without waiting
for the result of requests, so the commit can happen sooner.

In our implementation, if pending requests before the commit request are completed successfully, commit request
will be executed directly in the backend and dose not affect by things happening in request event handler. If
some pending request before the commit request has error, the commit request will be treated as abort request,
as commit() means no client operation, including error handling, should happen after it.

Rebaselined existing tests.

* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::didStartTransaction):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent):
(WebCore::IDBRequest::willAbortTransactionAfterDispatchingEvent const):
* Modules/indexeddb/IDBRequest.h:
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::abortDueToFailedRequest):
(WebCore::IDBTransaction::abort):
(WebCore::IDBTransaction::abortInternal):
(WebCore::IDBTransaction::stop):
(WebCore::IDBTransaction::handleOperationsCompletedOnServer):
(WebCore::IDBTransaction::commit): If commit() is called in event handler for error event, and the error is
handled before the call, we will create a commit requet. Otherwise, it is ignored as transaction will abort
due to the error.
(WebCore::IDBTransaction::commitInternal):
(WebCore::IDBTransaction::commitOnServer):
(WebCore::IDBTransaction::didCommit): didCommit used to be called after all requests are done and events are
fired. As commit request can now be handled and replied before other requests, we need to make sure complete
event of transaction is fired after success event of requests, by tracking completion of the last request before
commit request.
(WebCore::IDBTransaction::operationCompletedOnClient):
(WebCore::IDBTransaction::autoCommit):
(WebCore::IDBTransaction::internalAbort): Deleted.
* Modules/indexeddb/IDBTransaction.h:
* Modules/indexeddb/IDBTransaction.idl:
* Modules/indexeddb/client/IDBConnectionProxy.cpp:
(WebCore::IDBClient::IDBConnectionProxy::commitTransaction):
* Modules/indexeddb/client/IDBConnectionProxy.h:
* Modules/indexeddb/client/IDBConnectionToServer.cpp:
(WebCore::IDBClient::IDBConnectionToServer::commitTransaction):
* Modules/indexeddb/client/IDBConnectionToServer.h:
* Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::commitTransaction):
* Modules/indexeddb/server/IDBServer.h:
* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.cpp:
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::commit):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::createObjectStore):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::deleteObjectStore):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::renameObjectStore):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::clearObjectStore):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::createIndex):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::deleteIndex):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::renameIndex):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::putOrAdd):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::getRecord):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::getAllRecords):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::getCount):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::deleteRecord):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::openCursor):
(WebCore::IDBServer::UniqueIDBDatabaseTransaction::iterateCursor):
* Modules/indexeddb/server/UniqueIDBDatabaseTransaction.h:
* loader/EmptyClients.cpp:

Source/WebKit:

* NetworkProcess/IndexedDB/WebIDBServer.cpp:
(WebKit::WebIDBServer::commitTransaction):
* NetworkProcess/IndexedDB/WebIDBServer.h:
* NetworkProcess/IndexedDB/WebIDBServer.messages.in:
* WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
(WebKit::WebIDBConnectionToServer::commitTransaction):
* WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h:

Source/WebKitLegacy:

* Storage/InProcessIDBServer.cpp:
(InProcessIDBServer::commitTransaction):
* Storage/InProcessIDBServer.h:


Canonical link: https://commits.webkit.org/239788@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280053 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-19 23:09:48 +00:00
..
InProcessIDBServer.cpp Implement IDBTransaction.commit() 2021-07-19 23:09:48 +00:00
InProcessIDBServer.h Implement IDBTransaction.commit() 2021-07-19 23:09:48 +00:00
StorageAreaImpl.cpp Copy-on-write semantics should be an internal implementation detail of StorageMap 2021-04-27 20:55:02 +00:00
StorageAreaImpl.h Copy-on-write semantics should be an internal implementation detail of StorageMap 2021-04-27 20:55:02 +00:00
StorageAreaSync.cpp Replace LockHolder with Locker in local variables 2021-05-22 16:49:42 +00:00
StorageAreaSync.h Drop CheckedLock / CheckedCondition aliases 2021-05-24 18:29:01 +00:00
StorageNamespaceImpl.cpp
StorageNamespaceImpl.h
StorageSyncManager.cpp
StorageSyncManager.h
StorageThread.cpp
StorageThread.h
StorageTracker.cpp Next step toward using std::optional directly instead of through WTF::Optional typedef 2021-05-28 01:26:23 +00:00
StorageTracker.h Rename FileSystem::getFileSize() to FileSystem::fileSize() 2021-05-14 16:10:38 +00:00
StorageTrackerClient.h
WebDatabaseProvider.cpp Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
WebDatabaseProvider.h Pass PAL::SessionID by value instead of reference 2021-06-14 21:36:12 +00:00
WebStorageNamespaceProvider.cpp
WebStorageNamespaceProvider.h