void DOMFileSystem::reportError(ExecutionContext* executionContext, ErrorCallbackBase* errorCallback, FileError::ErrorCode fileError) { if (errorCallback) scheduleCallback( executionContext, createSameThreadTask(&ErrorCallbackBase::invoke, wrapPersistent(errorCallback), fileError)); }
void SQLTransaction::handleTransactionError() { ASSERT(m_transactionError); if (m_errorCallbackWrapper.hasCallback()) { scheduleCallback(&SQLTransaction::deliverTransactionErrorCallback); return; } // No error callback, so fast-forward to the next state and rollback the // transaction. m_backend.cleanupAfterTransactionErrorCallback(); }
void SQLTransaction::handleCurrentStatementError() { // Spec 4.3.2.6.6: error - Call the statement's error callback, but if there was no error callback, // or the transaction was rolled back, jump to the transaction error callback if (m_currentStatement->hasStatementErrorCallback() && !m_sqliteTransaction->wasRolledBackBySqlite()) { scheduleCallback(&SQLTransaction::deliverStatementCallback); return; } m_transactionError = m_currentStatement->sqlError(); if (!m_transactionError) m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "the statement failed to execute"); handleTransactionError(); }
bool SQLTransaction::runCurrentStatement() { if (!m_currentStatement) { // No more statements to run. So move on to the next state. return false; } m_database->resetAuthorizer(); if (m_hasVersionMismatch) m_currentStatement->setVersionMismatchedError(); if (m_currentStatement->execute(m_database)) { if (m_database->lastActionChangedDatabase()) { // Flag this transaction as having changed the database for later delegate notification m_modifiedDatabase = true; } if (m_currentStatement->hasStatementCallback()) { scheduleCallback(&SQLTransaction::deliverStatementCallback); return false; } // If we get here, then the statement doesn't have a callback to invoke. // We can move on to the next statement. Hence, stay in this state. return true; } if (m_currentStatement->lastExecutionFailedDueToQuota()) { scheduleCallback(&SQLTransaction::deliverQuotaIncreaseCallback); return false; } handleCurrentStatementError(); return false; }
void SQLTransaction::postflightAndCommit() { ASSERT(m_lockAcquired); // Spec 4.3.2.7: Perform 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(SQLError::UNKNOWN_ERR, "unknown error occurred during transaction postflight"); handleTransactionError(); return; } // Spec 4.3.2.7: Commit the transaction, jumping to the error callback if that fails. ASSERT(m_sqliteTransaction); m_database->disableAuthorizer(); m_sqliteTransaction->commit(); m_database->enableAuthorizer(); releaseOriginLockIfNeeded(); // 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_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to commit transaction", m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg()); handleTransactionError(); return; } // 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->didCommitWriteTransaction(); // Spec 4.3.2.8: Deliver success callback, if there is one. scheduleCallback(&SQLTransaction::deliverSuccessCallback); }
void DOMFileSystem::reportError(PassOwnPtr<ErrorCallback> errorCallback, PassRefPtrWillBeRawPtr<FileError> fileError) { scheduleCallback(errorCallback, fileError); }
void DOMFileSystem::createFile(const FileEntry* fileEntry, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback>) { String platformPath = m_asyncFileSystem->virtualToPlatformPath(fileEntry->fullPath()); scheduleCallback(successCallback, File::create(platformPath)); }
void SQLTransaction::openTransactionAndPreflight() { ASSERT(!m_database->sqliteDatabase().transactionInProgress()); ASSERT(m_lockAcquired); LOG(StorageAPI, "Opening and preflighting transaction %p", this); // If the database was deleted, jump to the error callback if (m_database->deleted()) { m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "unable to open a transaction, because the user deleted the database"); handleTransactionError(); return; } // Set the maximum usage for this transaction if this transactions is not read-only if (!m_readOnly) { acquireOriginLock(); m_database->sqliteDatabase().setMaximumSize(m_database->maximumSize()); } ASSERT(!m_sqliteTransaction); m_sqliteTransaction = std::make_unique<SQLiteTransaction>(m_database->sqliteDatabase(), m_readOnly); m_database->resetDeletes(); m_database->disableAuthorizer(); m_sqliteTransaction->begin(); m_database->enableAuthorizer(); // Spec 4.3.2.1+2: Open a transaction to the database, jumping to the error callback if that fails if (!m_sqliteTransaction->inProgress()) { ASSERT(!m_database->sqliteDatabase().transactionInProgress()); m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to begin transaction", m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg()); m_sqliteTransaction = nullptr; handleTransactionError(); return; } // Note: We intentionally retrieve the actual version even with an empty expected version. // In multi-process browsers, we take this opportinutiy to update the cached value for // the actual version. In single-process browsers, this is just a map lookup. String actualVersion; if (!m_database->getActualVersionForTransaction(actualVersion)) { m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "unable to read version", m_database->sqliteDatabase().lastError(), m_database->sqliteDatabase().lastErrorMsg()); m_database->disableAuthorizer(); m_sqliteTransaction = nullptr; m_database->enableAuthorizer(); handleTransactionError(); return; } m_hasVersionMismatch = !m_database->expectedVersion().isEmpty() && (m_database->expectedVersion() != actualVersion); // Spec 4.3.2.3: Perform preflight steps, jumping to the error callback if they fail if (m_wrapper && !m_wrapper->performPreflight(*this)) { m_database->disableAuthorizer(); m_sqliteTransaction = nullptr; m_database->enableAuthorizer(); m_transactionError = m_wrapper->sqlError(); if (!m_transactionError) m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "unknown error occurred during transaction preflight"); handleTransactionError(); return; } // Spec 4.3.2.4: Invoke the transaction callback with the new SQLTransaction object if (m_callbackWrapper.hasCallback()) { scheduleCallback(&SQLTransaction::deliverTransactionCallback); return; } // If we have no callback to make, skip pass to the state after: runStatements(); }