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); }
void SQLTransactionBackend::computeNextStateAndCleanupIfNeeded() { // Only honor the requested state transition if we're not supposed to be // cleaning up and shutting down: if (m_database->opened() && !m_database->isInterrupted()) { setStateToRequestedState(); ASSERT(m_nextState == SQLTransactionState::AcquireLock || m_nextState == SQLTransactionState::OpenTransactionAndPreflight || m_nextState == SQLTransactionState::RunStatements || m_nextState == SQLTransactionState::PostflightAndCommit || m_nextState == SQLTransactionState::CleanupAndTerminate || m_nextState == SQLTransactionState::CleanupAfterTransactionErrorCallback); WTF_LOG(StorageAPI, "State %s\n", nameForSQLTransactionState(m_nextState)); return; } // If we get here, then we should be shutting down. Do clean up if needed: if (m_nextState == SQLTransactionState::End) return; m_nextState = SQLTransactionState::End; // If the database was stopped, don't do anything and cancel queued work WTF_LOG(StorageAPI, "Database was stopped or interrupted - cancelling work for this transaction"); // The current SQLite transaction should be stopped, as well if (m_sqliteTransaction) { m_sqliteTransaction->stop(); m_sqliteTransaction.clear(); } // Terminate the frontend state machine. This also gets the frontend to // call computeNextStateAndCleanupIfNeeded() and clear its wrappers // if needed. m_frontend->requestTransitToState(SQLTransactionState::End); // Redirect to the end state to abort, clean up, and end the transaction. doCleanup(); }