Modern IDB:Make in-memory ObjectStore cursors work.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Nov 2015 23:17:46 +0000 (23:17 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Nov 2015 23:17:46 +0000 (23:17 +0000)
commitd59cbe2969d8789b2559e15b1f9de91c05533c8e
tree3e6dc9b9e2cbd7f4109fdbdd06ca06e18b753526
parentb9e7b2377222161974089fd53fa13550a8d19f41
Modern IDB:Make in-memory ObjectStore cursors work.
https://bugs.webkit.org/show_bug.cgi?id=151196

Reviewed by Darin Adler.

Source/WebCore:

Tests: storage/indexeddb/modern/cursor-2.html
       storage/indexeddb/modern/cursor-3.html
       storage/indexeddb/modern/cursor-4.html
       storage/indexeddb/modern/cursor-5.html
       storage/indexeddb/modern/cursor-6.html
       storage/indexeddb/modern/cursor-7.html
       storage/indexeddb/modern/cursor-8.html
       storage/indexeddb/modern/objectstore-cursor-advance-failures.html
       storage/indexeddb/modern/objectstore-cursor-continue-failures.html

Object store cursors directly hold on to a std::set<>::iterator to act as the cursor.

The object store tells all of its cursors when it is cleared or records are deleted
so the cursors can invalidate their iterators as needed.

In case of such invalidation, the cursor hangs on to the current key value so it can
pick up where it left off in case it is iterated.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:

* Modules/indexeddb/IDBGetResult.h:
(WebCore::IDBGetResult::isolatedCopy):

* Modules/indexeddb/IDBKeyRangeData.cpp:
(WebCore::IDBKeyRangeData::containsKey):
(WebCore::IDBKeyRangeData::loggingString):
* Modules/indexeddb/IDBKeyRangeData.h:

* Modules/indexeddb/client/IDBAnyImpl.cpp:
(WebCore::IDBClient::IDBAny::modernIDBCursor):

* Modules/indexeddb/client/IDBCursorImpl.cpp:
(WebCore::IDBClient::IDBCursor::update):
(WebCore::IDBClient::IDBCursor::advance):
(WebCore::IDBClient::IDBCursor::continueFunction):
(WebCore::IDBClient::IDBCursor::setGetResult):
* Modules/indexeddb/client/IDBCursorImpl.h:

* Modules/indexeddb/client/IDBRequestImpl.cpp:
(WebCore::IDBClient::IDBRequest::dispatchEvent):
(WebCore::IDBClient::IDBRequest::didOpenOrIterateCursor):
* Modules/indexeddb/client/IDBRequestImpl.h:
(WebCore::IDBClient::IDBRequest::pendingCursor):

* Modules/indexeddb/client/IDBTransactionImpl.cpp:
(WebCore::IDBClient::IDBTransaction::addRequest): Deleted.

* Modules/indexeddb/client/TransactionOperation.cpp:
(WebCore::IDBClient::TransactionOperation::TransactionOperation):
* Modules/indexeddb/client/TransactionOperation.h:
(WebCore::IDBClient::TransactionOperation::cursorIdentifier):

* Modules/indexeddb/server/IDBBackingStore.h:

* Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
(WebCore::IDBServer::MemoryBackingStoreTransaction::objectStoreCleared):
(WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
* Modules/indexeddb/server/MemoryBackingStoreTransaction.h:

* Modules/indexeddb/server/MemoryCursor.cpp: Added.
(WebCore::IDBServer::cursorMap):
(WebCore::IDBServer::MemoryCursor::MemoryCursor):
(WebCore::IDBServer::MemoryCursor::~MemoryCursor):
(WebCore::IDBServer::MemoryCursor::cursorForIdentifier):
* Modules/indexeddb/server/MemoryCursor.h: Added.

* Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
(WebCore::IDBServer::MemoryIDBBackingStore::openCursor):
(WebCore::IDBServer::MemoryIDBBackingStore::iterateCursor):
* Modules/indexeddb/server/MemoryIDBBackingStore.h:

* Modules/indexeddb/server/MemoryObjectStore.cpp:
(WebCore::IDBServer::MemoryObjectStore::clear):
(WebCore::IDBServer::MemoryObjectStore::replaceKeyValueStore):
(WebCore::IDBServer::MemoryObjectStore::deleteRecord):
(WebCore::IDBServer::MemoryObjectStore::addRecord):
(WebCore::IDBServer::MemoryObjectStore::updateCursorsForPutRecord):
(WebCore::IDBServer::MemoryObjectStore::updateCursorsForDeleteRecord):
(WebCore::IDBServer::MemoryObjectStore::maybeOpenCursor):
* Modules/indexeddb/server/MemoryObjectStore.h:
(WebCore::IDBServer::MemoryObjectStore::orderedKeys):

* Modules/indexeddb/server/MemoryObjectStoreCursor.cpp: Added.
(WebCore::IDBServer::MemoryObjectStoreCursor::create):
(WebCore::IDBServer::MemoryObjectStoreCursor::MemoryObjectStoreCursor):
(WebCore::IDBServer::MemoryObjectStoreCursor::objectStoreCleared):
(WebCore::IDBServer::MemoryObjectStoreCursor::keyDeleted):
(WebCore::IDBServer::MemoryObjectStoreCursor::keyAdded):
(WebCore::IDBServer::MemoryObjectStoreCursor::setFirstInRemainingRange):
(WebCore::IDBServer::MemoryObjectStoreCursor::firstForwardIteratorInRemainingRange):
(WebCore::IDBServer::MemoryObjectStoreCursor::firstReverseIteratorInRemainingRange):
(WebCore::IDBServer::MemoryObjectStoreCursor::currentData):
(WebCore::IDBServer::MemoryObjectStoreCursor::incrementForwardIterator):
(WebCore::IDBServer::MemoryObjectStoreCursor::incrementReverseIterator):
(WebCore::IDBServer::MemoryObjectStoreCursor::hasValidPosition):
(WebCore::IDBServer::MemoryObjectStoreCursor::iterate):
* Modules/indexeddb/server/MemoryObjectStoreCursor.h: Added.

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::iterateCursor):
(WebCore::IDBServer::UniqueIDBDatabase::performIterateCursor):
* Modules/indexeddb/server/UniqueIDBDatabase.h:

* Modules/indexeddb/shared/IDBCursorInfo.h:
(WebCore::IDBCursorInfo::range):

* Modules/indexeddb/shared/IDBRequestData.cpp:
(WebCore::IDBRequestData::IDBRequestData):
(WebCore::IDBRequestData::cursorIdentifier):
* Modules/indexeddb/shared/IDBRequestData.h:

LayoutTests:

* storage/indexeddb/modern/cursor-1-expected.txt:
* storage/indexeddb/modern/cursor-2-expected.txt: Added.
* storage/indexeddb/modern/cursor-2.html: Added.
* storage/indexeddb/modern/cursor-3-expected.txt: Added.
* storage/indexeddb/modern/cursor-3.html: Added.
* storage/indexeddb/modern/cursor-4-expected.txt: Added.
* storage/indexeddb/modern/cursor-4.html: Added.
* storage/indexeddb/modern/cursor-5-expected.txt: Added.
* storage/indexeddb/modern/cursor-5.html: Added.
* storage/indexeddb/modern/cursor-6-expected.txt: Added.
* storage/indexeddb/modern/cursor-6.html: Added.
* storage/indexeddb/modern/cursor-7-expected.txt: Added.
* storage/indexeddb/modern/cursor-7.html: Added.
* storage/indexeddb/modern/cursor-8-expected.txt: Added.
* storage/indexeddb/modern/cursor-8.html: Added.
* storage/indexeddb/modern/objectstore-cursor-advance-failures-expected.txt: Added.
* storage/indexeddb/modern/objectstore-cursor-advance-failures.html: Added.
* storage/indexeddb/modern/objectstore-cursor-continue-failures-expected.txt: Added.
* storage/indexeddb/modern/objectstore-cursor-continue-failures.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
50 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/modern/cursor-1-expected.txt
LayoutTests/storage/indexeddb/modern/cursor-2-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-2.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-3-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-3.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-4-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-4.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-5-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-5.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-6-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-6.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-7-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-7.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-8-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/cursor-8.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/objectstore-cursor-advance-failures-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/objectstore-cursor-advance-failures.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/objectstore-cursor-continue-failures-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/objectstore-cursor-continue-failures.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBGetResult.h
Source/WebCore/Modules/indexeddb/IDBKeyRangeData.cpp
Source/WebCore/Modules/indexeddb/IDBKeyRangeData.h
Source/WebCore/Modules/indexeddb/client/IDBAnyImpl.cpp
Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.cpp
Source/WebCore/Modules/indexeddb/client/IDBCursorImpl.h
Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.cpp
Source/WebCore/Modules/indexeddb/client/IDBRequestImpl.h
Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp
Source/WebCore/Modules/indexeddb/client/TransactionOperation.cpp
Source/WebCore/Modules/indexeddb/client/TransactionOperation.h
Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h
Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp
Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h
Source/WebCore/Modules/indexeddb/server/MemoryCursor.cpp [new file with mode: 0644]
Source/WebCore/Modules/indexeddb/server/MemoryCursor.h [new file with mode: 0644]
Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp
Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h
Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp
Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h
Source/WebCore/Modules/indexeddb/server/MemoryObjectStoreCursor.cpp [new file with mode: 0644]
Source/WebCore/Modules/indexeddb/server/MemoryObjectStoreCursor.h [new file with mode: 0644]
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.h
Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.h
Source/WebCore/Modules/indexeddb/shared/IDBRequestData.cpp
Source/WebCore/Modules/indexeddb/shared/IDBRequestData.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj