RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, IDBKeyRange* keyRange, ExceptionCode& ec) { LOG(IndexedDB, "IDBObjectStore::deleteFunction"); if (m_transaction->isReadOnly()) { ec = static_cast<ExceptionCode>(IDBExceptionCode::ReadOnlyError); return nullptr; } if (!m_transaction->isActive()) { ec = static_cast<ExceptionCode>(IDBExceptionCode::TransactionInactiveError); return nullptr; } if (m_deleted) { ec = INVALID_STATE_ERR; return nullptr; } IDBKeyRangeData keyRangeData(keyRange); if (!keyRangeData.isValid()) { ec = static_cast<ExceptionCode>(IDBExceptionCode::DataError); return nullptr; } Ref<IDBRequest> request = m_transaction->requestDeleteRecord(*context, *this, keyRangeData); return WTF::move(request); }
RefPtr<WebCore::IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext* context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) { LOG(IndexedDB, "IDBObjectStore::deleteFunction"); if (!m_transaction->isActive()) { ec.code = IDBDatabaseException::TransactionInactiveError; ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The transaction is inactive or finished."); return nullptr; } if (m_transaction->isReadOnly()) { ec.code = IDBDatabaseException::ReadOnlyError; ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The transaction is read-only."); return nullptr; } if (m_deleted) { ec.code = IDBDatabaseException::InvalidStateError; return nullptr; } IDBKeyRangeData keyRangeData(keyRange); if (!keyRangeData.isValid()) { ec.code = IDBDatabaseException::DataError; ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key range."); return nullptr; } Ref<IDBRequest> request = m_transaction->requestDeleteRecord(*context, *this, keyRangeData); return WTF::move(request); }
RefPtr<WebCore::IDBRequest> IDBObjectStore::get(ScriptExecutionContext* context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) { LOG(IndexedDB, "IDBObjectStore::get"); if (!context) { ec.code = IDBDatabaseException::InvalidStateError; return nullptr; } if (!m_transaction->isActive()) { ec.code = IDBDatabaseException::TransactionInactiveError; return nullptr; } if (m_deleted) { ec.code = IDBDatabaseException::InvalidStateError; return nullptr; } IDBKeyRangeData keyRangeData(keyRange); if (!keyRangeData.isValid()) { ec.code = IDBDatabaseException::DataError; return nullptr; } Ref<IDBRequest> request = m_transaction->requestGetRecord(*context, *this, keyRangeData); return WTF::move(request); }
RefPtr<IDBRequest> IDBObjectStore::doDelete(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) { LOG(IndexedDB, "IDBObjectStore::deleteFunction"); ASSERT(currentThread() == m_transaction->database().originThreadID()); // The IDB spec for several IDBObjectStore methods states that transaction related exceptions should fire before // the exception for an object store being deleted. // However, a handful of W3C IDB tests expect the deleted exception even though the transaction inactive exception also applies. // Additionally, Chrome and Edge agree with the test, as does Legacy IDB in WebKit. // Until this is sorted out, we'll agree with the test and the majority share browsers. if (m_deleted) { ec.code = IDBDatabaseException::InvalidStateError; ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The object store has been deleted."); return nullptr; } if (!m_transaction->isActive()) { ec.code = IDBDatabaseException::TransactionInactiveError; ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The transaction is inactive or finished."); return nullptr; } if (m_transaction->isReadOnly()) { ec.code = IDBDatabaseException::ReadOnlyError; ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The transaction is read-only."); return nullptr; } IDBKeyRangeData keyRangeData(keyRange); if (!keyRangeData.isValid()) { ec.code = IDBDatabaseException::DataError; ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key range."); return nullptr; } return m_transaction->requestDeleteRecord(context, *this, keyRangeData); }
RefPtr<IDBRequest> IDBObjectStore::get(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec) { LOG(IndexedDB, "IDBObjectStore::get"); ASSERT(currentThread() == m_transaction->database().originThreadID()); if (!m_transaction->isActive()) { ec.code = IDBDatabaseException::TransactionInactiveError; return nullptr; } if (m_deleted) { ec.code = IDBDatabaseException::InvalidStateError; ec.message = ASCIILiteral("Failed to execute 'get' on 'IDBObjectStore': The object store has been deleted."); return nullptr; } IDBKeyRangeData keyRangeData(keyRange); if (!keyRangeData.isValid()) { ec.code = IDBDatabaseException::DataError; return nullptr; } return m_transaction->requestGetRecord(context, *this, keyRangeData); }