RefPtr<WebCore::IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext* context, ExceptionCode& ec) { LOG(IndexedDB, "IDBCursor::deleteFunction"); if (!context) { ec = IDBDatabaseException::InvalidStateError; return nullptr; } if (sourcesDeleted()) { ec = IDBDatabaseException::InvalidStateError; return nullptr; } if (!transaction().isActive()) { ec = IDBDatabaseException::TransactionInactiveError; return nullptr; } if (transaction().isReadOnly()) { ec = IDBDatabaseException::ReadOnlyError; return nullptr; } if (!m_gotValue) { ec = IDBDatabaseException::InvalidStateError; return nullptr; } return effectiveObjectStore().deleteFunction(context, m_deprecatedCurrentPrimaryKey.jsValue(), ec); }
void IDBCursor::advance(unsigned long count, ExceptionCode& ec) { LOG(IndexedDB, "IDBCursor::advance"); if (!m_request) { ec = IDBDatabaseException::InvalidStateError; return; } if (!count) { ec = TypeError; return; } if (sourcesDeleted()) { ec = IDBDatabaseException::InvalidStateError; return; } if (!transaction().isActive()) { ec = IDBDatabaseException::TransactionInactiveError; return; } if (!m_gotValue) { ec = IDBDatabaseException::InvalidStateError; return; } m_gotValue = false; uncheckedIteratorCursor(IDBKeyData(), count); }
RefPtr<WebCore::IDBRequest> IDBCursor::update(JSC::ExecState& exec, Deprecated::ScriptValue& value, ExceptionCode& ec) { LOG(IndexedDB, "IDBCursor::update"); if (sourcesDeleted()) { ec = IDBDatabaseException::InvalidStateError; return nullptr; } if (!transaction().isActive()) { ec = IDBDatabaseException::TransactionInactiveError; return nullptr; } if (transaction().isReadOnly()) { ec = IDBDatabaseException::ReadOnlyError; return nullptr; } if (!m_gotValue) { ec = IDBDatabaseException::InvalidStateError; return nullptr; } if (isKeyCursor()) { ec = IDBDatabaseException::InvalidStateError; return nullptr; } return effectiveObjectStore().put(exec, value.jsValue(), m_deprecatedCurrentPrimaryKey.jsValue(), ec); }
RefPtr<WebCore::IDBRequest> IDBCursor::update(JSC::ExecState& exec, Deprecated::ScriptValue& value, ExceptionCodeWithMessage& ec) { LOG(IndexedDB, "IDBCursor::update"); if (sourcesDeleted()) { ec.code = IDBDatabaseException::InvalidStateError; return nullptr; } if (!transaction().isActive()) { ec.code = IDBDatabaseException::TransactionInactiveError; ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The transaction is inactive or finished."); return nullptr; } if (transaction().isReadOnly()) { ec.code = IDBDatabaseException::ReadOnlyError; ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The record may not be updated inside a read-only transaction."); return nullptr; } if (!m_gotValue) { ec.code = IDBDatabaseException::InvalidStateError; return nullptr; } if (isKeyCursor()) { ec.code = IDBDatabaseException::InvalidStateError; ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The cursor is a key cursor."); return nullptr; } auto& objectStore = effectiveObjectStore(); auto& keyPath = objectStore.info().keyPath(); const bool usesInLineKeys = !keyPath.isNull(); if (usesInLineKeys) { RefPtr<IDBKey> keyPathKey = maybeCreateIDBKeyFromScriptValueAndKeyPath(exec, value, keyPath); IDBKeyData keyPathKeyData(keyPathKey.get()); if (!keyPathKey || keyPathKeyData != m_currentPrimaryKeyData) { ec.code = IDBDatabaseException::DataError; ec.message = ASCIILiteral("Failed to execute 'update' on 'IDBCursor': The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key."); return nullptr; } } auto request = effectiveObjectStore().putForCursorUpdate(exec, value.jsValue(), m_deprecatedCurrentPrimaryKey.jsValue(), ec); if (ec.code) return nullptr; ASSERT(request); request->setSource(*this); return request; }
void IDBCursor::continueFunction(const IDBKeyData& key, ExceptionCodeWithMessage& ec) { LOG(IndexedDB, "IDBCursor::continueFunction"); if (!m_request) { ec.code = IDBDatabaseException::InvalidStateError; return; } if (sourcesDeleted()) { ec.code = IDBDatabaseException::InvalidStateError; return; } if (!transaction().isActive()) { ec.code = IDBDatabaseException::TransactionInactiveError; ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The transaction is inactive or finished."); return; } if (!m_gotValue) { ec.code = IDBDatabaseException::InvalidStateError; ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The cursor is being iterated or has iterated past its end."); return; } if (!key.isNull() && !key.isValid()) { ec.code = IDBDatabaseException::DataError; ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The parameter is not a valid key."); return; } if (m_info.isDirectionForward()) { if (!key.isNull() && key.compare(m_currentPrimaryKeyData) <= 0) { ec.code = IDBDatabaseException::DataError; ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The parameter is less than or equal to this cursor's position."); return; } } else if (!key.isNull() && key.compare(m_currentPrimaryKeyData) >= 0) { ec.code = IDBDatabaseException::DataError; ec.message = ASCIILiteral("Failed to execute 'continue' on 'IDBCursor': The parameter is greater than or equal to this cursor's position."); return; } m_gotValue = false; uncheckedIteratorCursor(key, 0); }
void IDBCursor::continueFunction(const IDBKeyData& key, ExceptionCode& ec) { LOG(IndexedDB, "IDBCursor::continueFunction"); if (!m_request) { ec = IDBDatabaseException::InvalidStateError; return; } if (sourcesDeleted()) { ec = IDBDatabaseException::InvalidStateError; return; } if (!transaction().isActive()) { ec = IDBDatabaseException::TransactionInactiveError; return; } if (!m_gotValue) { ec = IDBDatabaseException::InvalidStateError; return; } if (!key.isNull() && !key.isValid()) { ec = IDBDatabaseException::DataError; return; } if (m_info.isDirectionForward()) { if (!key.isNull() && key.compare(m_currentPrimaryKeyData) <= 0) { ec = IDBDatabaseException::DataError; return; } } else if (!key.isNull() && key.compare(m_currentPrimaryKeyData) >= 0) { ec = IDBDatabaseException::DataError; return; } m_gotValue = false; uncheckedIteratorCursor(key, 0); }
RefPtr<WebCore::IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext* context, ExceptionCodeWithMessage& ec) { LOG(IndexedDB, "IDBCursor::deleteFunction"); if (!context) { ec.code = IDBDatabaseException::InvalidStateError; return nullptr; } if (sourcesDeleted()) { ec.code = IDBDatabaseException::InvalidStateError; return nullptr; } if (!transaction().isActive()) { ec.code = IDBDatabaseException::TransactionInactiveError; ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The transaction is inactive or finished."); return nullptr; } if (transaction().isReadOnly()) { ec.code = IDBDatabaseException::ReadOnlyError; ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The record may not be deleted inside a read-only transaction."); return nullptr; } if (!m_gotValue) { ec.code = IDBDatabaseException::InvalidStateError; return nullptr; } if (isKeyCursor()) { ec.code = IDBDatabaseException::InvalidStateError; ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBCursor': The cursor is a key cursor."); return nullptr; } return effectiveObjectStore().deleteFunction(context, m_deprecatedCurrentPrimaryKey.jsValue(), ec); }
void IDBCursor::advance(unsigned long count, ExceptionCodeWithMessage& ec) { LOG(IndexedDB, "IDBCursor::advance"); if (!m_request) { ec.code = IDBDatabaseException::InvalidStateError; return; } if (!count) { ec.code = TypeError; ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': A count argument with value 0 (zero) was supplied, must be greater than 0."); return; } if (sourcesDeleted()) { ec.code = IDBDatabaseException::InvalidStateError; return; } if (!transaction().isActive()) { ec.code = IDBDatabaseException::TransactionInactiveError; ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': The transaction is inactive or finished."); return; } if (!m_gotValue) { ec.code = IDBDatabaseException::InvalidStateError; ec.message = ASCIILiteral("Failed to execute 'advance' on 'IDBCursor': The cursor is being iterated or has iterated past its end."); return; } m_gotValue = false; uncheckedIteratorCursor(IDBKeyData(), count); }