/* * Copyright (C) 2007, 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "third_party/blink/renderer/modules/webdatabase/sql_statement_backend.h" #include "third_party/blink/renderer/modules/webdatabase/database.h" #include "third_party/blink/renderer/modules/webdatabase/sql_error.h" #include "third_party/blink/renderer/modules/webdatabase/sql_statement.h" #include "third_party/blink/renderer/modules/webdatabase/sqlite/sqlite_database.h" #include "third_party/blink/renderer/modules/webdatabase/sqlite/sqlite_statement.h" #include "third_party/blink/renderer/modules/webdatabase/storage_log.h" // The Life-Cycle of a SQLStatement i.e. Who's keeping the SQLStatement alive? // ========================================================================== // The RefPtr chain goes something like this: // // At birth (in SQLTransactionBackend::executeSQL()): // ================================================= // SQLTransactionBackend // // HeapDeque<Member<SQLStatementBackend>> m_statementQueue // // points to ... // --> SQLStatementBackend // // Member<SQLStatement> m_frontend points to ... // --> SQLStatement // // After grabbing the statement for execution (in // SQLTransactionBackend::getNextStatement()): // ====================================================================== // SQLTransactionBackend // // Member<SQLStatementBackend> m_currentStatementBackend // // points to ... // --> SQLStatementBackend // // Member<SQLStatement> m_frontend points to ... // --> SQLStatement // // Then we execute the statement in // SQLTransactionBackend::runCurrentStatementAndGetNextState(). // And we callback to the script in // SQLTransaction::deliverStatementCallback() if necessary. // - Inside SQLTransaction::deliverStatementCallback(), we operate on a raw // SQLStatement*. This pointer is valid because it is owned by // SQLTransactionBackend's // SQLTransactionBackend::m_currentStatementBackend. // // After we're done executing the statement (in // SQLTransactionBackend::getNextStatement()): // ====================================================================== // When we're done executing, we'll grab the next statement. But before we // do that, getNextStatement() nullify // SQLTransactionBackend::m_currentStatementBackend. // This will trigger the deletion of the SQLStatementBackend and // SQLStatement. // // Note: unlike with SQLTransaction, there is no JS representation of // SQLStatement. Hence, there is no GC dependency at play here. namespace blink { SQLStatementBackend::SQLStatementBackend(SQLStatement* frontend, const String& statement, const Vector<SQLValue>& arguments, int permissions) : … { … } void SQLStatementBackend::Trace(Visitor* visitor) const { … } SQLStatement* SQLStatementBackend::GetFrontend() { … } SQLErrorData* SQLStatementBackend::SqlError() const { … } SQLResultSet* SQLStatementBackend::SqlResultSet() const { … } bool SQLStatementBackend::Execute(Database* db) { … } void SQLStatementBackend::SetVersionMismatchedError(Database* database) { … } void SQLStatementBackend::SetFailureDueToQuota(Database* database) { … } void SQLStatementBackend::ClearFailureDueToQuota() { … } bool SQLStatementBackend::LastExecutionFailedDueToQuota() const { … } } // namespace blink