MemoryObjectStoreCursor::MemoryObjectStoreCursor(MemoryObjectStore& objectStore, const IDBCursorInfo& info)
    : MemoryCursor(info)
    , m_objectStore(objectStore)
    , m_remainingRange(info.range())
{
    LOG(IndexedDB, "MemoryObjectStoreCursor::MemoryObjectStoreCursor %s", info.range().loggingString().utf8().data());

    auto* orderedKeys = objectStore.orderedKeys();
    if (!orderedKeys)
        return;

    setFirstInRemainingRange(*orderedKeys);
}
Esempio n. 2
0
Ref<IDBRequest> IDBTransaction::requestOpenCursor(ScriptExecutionContext& context, IDBIndex& index, const IDBCursorInfo& info)
{
    LOG(IndexedDB, "IDBTransaction::requestOpenCursor");

    if (info.cursorType() == IndexedDB::CursorType::KeyOnly)
        return doRequestOpenCursor(context, IDBCursor::create(*this, index, info));

    return doRequestOpenCursor(context, IDBCursorWithValue::create(*this, index, info));
}
Esempio n. 3
0
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 { };
}
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);
}