SQLTransactionState SQLTransaction::deliverTransactionErrorCallback() { // Spec 4.3.2.10: If exists, invoke error callback with the last // error to have occurred in this transaction. OwnPtr<SQLTransactionErrorCallback> errorCallback = m_errorCallbackWrapper.unwrap(); if (errorCallback) { // If we get here with an empty m_transactionError, then the backend // must be waiting in the idle state waiting for this state to finish. // Hence, it's thread safe to fetch the backend transactionError without // a lock. if (!m_transactionError) { ASSERT(m_backend->transactionError()); m_transactionError = SQLErrorData::create(*m_backend->transactionError()); } ASSERT(m_transactionError); RefPtrWillBeRawPtr<SQLError> error = SQLError::create(*m_transactionError); errorCallback->handleEvent(error.get()); m_transactionError = nullptr; } clearCallbackWrappers(); // Spec 4.3.2.10: Rollback the transaction. return SQLTransactionState::CleanupAfterTransactionErrorCallback; }
void SQLTransaction::deliverSuccessCallback() { // Spec 4.3.2.8: Deliver success callback. RefPtr<VoidCallback> successCallback = m_successCallbackWrapper.unwrap(); if (successCallback) successCallback->handleEvent(); clearCallbackWrappers(); // Schedule a "post-success callback" step to return control to the database thread in case there // are further transactions queued up for this Database m_backend->requestTransitToState(SQLTransactionState::CleanupAndTerminate); }
void SQLTransaction::deliverTransactionErrorCallback() { ASSERT(m_transactionError); // Spec 4.3.2.10: If exists, invoke error callback with the last // error to have occurred in this transaction. RefPtr<SQLTransactionErrorCallback> errorCallback = m_errorCallbackWrapper.unwrap(); if (errorCallback) errorCallback->handleEvent(*m_transactionError); clearCallbackWrappers(); // Spec 4.3.2.10: Rollback the transaction. m_backend.requestTransitToState(SQLTransactionState::CleanupAfterTransactionErrorCallback); }
void SQLTransaction::computeNextStateAndCleanupIfNeeded() { // Only honor the requested state transition if we're not supposed to be // cleaning up and shutting down: if (m_database->opened()) { setStateToRequestedState(); ASSERT(m_nextState == SQLTransactionState::End || m_nextState == SQLTransactionState::DeliverTransactionCallback || m_nextState == SQLTransactionState::DeliverTransactionErrorCallback || m_nextState == SQLTransactionState::DeliverStatementCallback || m_nextState == SQLTransactionState::DeliverQuotaIncreaseCallback || m_nextState == SQLTransactionState::DeliverSuccessCallback); LOG(StorageAPI, "Callback %s\n", nameForSQLTransactionState(m_nextState)); return; } clearCallbackWrappers(); m_backend->requestTransitToState(SQLTransactionState::CleanupAndTerminate); }