SQLiteIDBCursor::SQLiteIDBCursor(SQLiteIDBTransaction& transaction, const IDBCursorInfo& info) : m_transaction(&transaction) , m_cursorIdentifier(info.identifier()) , m_objectStoreID(info.objectStoreIdentifier()) , m_indexID(info.cursorSource() == IndexedDB::CursorSource::Index ? info.sourceIdentifier() : IDBIndexMetadata::InvalidId) , m_cursorDirection(info.cursorDirection()) , m_keyRange(info.range()) { ASSERT(m_objectStoreID); }
IDBError MemoryIDBBackingStore::openCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBCursorInfo& info, IDBGetResult& outData) { LOG(IndexedDB, "MemoryIDBBackingStore::openCursor"); ASSERT(!MemoryCursor::cursorForIdentifier(info.identifier())); if (!m_transactions.contains(transactionIdentifier)) return { IDBDatabaseException::UnknownError, ASCIILiteral("No backing store transaction found in which to open a cursor") }; switch (info.cursorSource()) { case IndexedDB::CursorSource::ObjectStore: { auto* objectStore = m_objectStoresByIdentifier.get(info.sourceIdentifier()); if (!objectStore) return { IDBDatabaseException::UnknownError, ASCIILiteral("No backing store object store found") }; MemoryCursor* cursor = objectStore->maybeOpenCursor(info); if (!cursor) return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not create object store cursor in backing store") }; cursor->currentData(outData); break; } case IndexedDB::CursorSource::Index: auto* objectStore = m_objectStoresByIdentifier.get(info.objectStoreIdentifier()); if (!objectStore) return { IDBDatabaseException::UnknownError, ASCIILiteral("No backing store object store found") }; auto* index = objectStore->indexForIdentifier(info.sourceIdentifier()); if (!index) return { IDBDatabaseException::UnknownError, ASCIILiteral("No backing store index found") }; MemoryCursor* cursor = index->maybeOpenCursor(info); if (!cursor) return { IDBDatabaseException::UnknownError, ASCIILiteral("Could not create index cursor in backing store") }; cursor->currentData(outData); break; } return { }; }