void SQLTransaction::postflightAndCommit() { ASSERT(m_lockAcquired); // Transaction Step 7 - Peform postflight steps, jumping to the error callback if they fail if (m_wrapper && !m_wrapper->performPostflight(this)) { m_transactionError = m_wrapper->sqlError(); if (!m_transactionError) { m_database->reportCommitTransactionResult(3, SQLError::UNKNOWN_ERR, 0); m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "unknown error occurred during transaction postflight"); } handleTransactionError(false); return; } // Transacton Step 8+9 - Commit the transaction, jumping to the error callback if that fails ASSERT(m_sqliteTransaction); m_database->disableAuthorizer(); m_sqliteTransaction->commit(); m_database->enableAuthorizer(); // If the commit failed, the transaction will still be marked as "in progress" if (m_sqliteTransaction->inProgress()) { if (m_wrapper) m_wrapper->handleCommitFailedAfterPostflight(this); m_successCallbackWrapper.clear(); m_database->reportCommitTransactionResult(4, SQLError::DATABASE_ERR, m_database->sqliteDatabase().lastError()); m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to commit transaction", m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg()); handleTransactionError(false); return; } m_database->reportCommitTransactionResult(0, -1, 0); // OK // Vacuum the database if anything was deleted. if (m_database->hadDeletes()) m_database->incrementalVacuumIfNeeded(); // The commit was successful. If the transaction modified this database, notify the delegates. if (m_modifiedDatabase) m_database->transactionClient()->didCommitWriteTransaction(database()); // Now release our unneeded callbacks, to break reference cycles. m_errorCallbackWrapper.clear(); // Transaction Step 10 - Deliver success callback, if there is one if (m_successCallbackWrapper.hasCallback()) { m_nextStep = &SQLTransaction::deliverSuccessCallback; LOG(StorageAPI, "Scheduling deliverSuccessCallback for transaction %p\n", this); m_database->scheduleTransactionCallback(this); } else cleanupAfterSuccessCallback(); }
void SQLTransaction::postflightAndCommit() { ASSERT(m_lockAcquired); // Transaction Step 7 - Peform postflight steps, jumping to the error callback if they fail if (m_wrapper && !m_wrapper->performPostflight(this)) { m_transactionError = m_wrapper->sqlError(); if (!m_transactionError) m_transactionError = SQLError::create(0, "unknown error occured setting up transaction"); handleTransactionError(false); return; } // Transacton Step 8+9 - Commit the transaction, jumping to the error callback if that fails ASSERT(m_sqliteTransaction); m_database->m_databaseAuthorizer->disable(); m_sqliteTransaction->commit(); m_database->m_databaseAuthorizer->enable(); // If the commit failed, the transaction will still be marked as "in progress" if (m_sqliteTransaction->inProgress()) { m_transactionError = SQLError::create(0, "failed to commit the transaction"); handleTransactionError(false); return; } // The commit was successful. If the transaction modified this database, // vacuum the database if needed and notify the delegates. if (m_modifiedDatabase) { m_database->incrementalVacuumIfNeeded(); m_database->transactionClient()->didCommitTransaction(this); } // Now release our unneeded callbacks, to break reference cycles. m_callback = 0; m_errorCallback = 0; // Transaction Step 10 - Deliver success callback, if there is one if (m_successCallback) { m_nextStep = &SQLTransaction::deliverSuccessCallback; LOG(StorageAPI, "Scheduling deliverSuccessCallback for transaction %p\n", this); m_database->scheduleTransactionCallback(this); } else cleanupAfterSuccessCallback(); }