From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- .../Modules/webdatabase/SQLTransactionBackend.h | 115 +++++---------------- 1 file changed, 24 insertions(+), 91 deletions(-) (limited to 'Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h') diff --git a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h b/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h index 17a4c65f2..29e603c95 100644 --- a/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h +++ b/Source/WebCore/Modules/webdatabase/SQLTransactionBackend.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2013 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2013, 2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,7 +10,7 @@ * 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 + * 3. Neither the name of Apple 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. * @@ -25,122 +25,55 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SQLTransactionBackend_h -#define SQLTransactionBackend_h -#if ENABLE(SQL_DATABASE) +#pragma once -#include "AbstractSQLStatement.h" -#include "AbstractSQLTransactionBackend.h" -#include "DatabaseBasicTypes.h" #include "SQLTransactionStateMachine.h" +#include #include #include +#include #include namespace WebCore { -class AbstractSQLTransaction; -class DatabaseBackend; +class Database; class OriginLock; class SQLError; class SQLiteTransaction; -class SQLStatementBackend; -class SQLTransactionBackend; -class SQLValue; +class SQLStatement; +class SQLTransaction; +class SQLTransactionWrapper; -class SQLTransactionWrapper : public ThreadSafeRefCounted { +class SQLTransactionBackend : public SQLTransactionStateMachine { public: - virtual ~SQLTransactionWrapper() { } - virtual bool performPreflight(SQLTransactionBackend*) = 0; - virtual bool performPostflight(SQLTransactionBackend*) = 0; - virtual SQLError* sqlError() const = 0; - virtual void handleCommitFailedAfterPostflight(SQLTransactionBackend*) = 0; -}; - -class SQLTransactionBackend : public SQLTransactionStateMachine, public AbstractSQLTransactionBackend { -public: - static PassRefPtr create(DatabaseBackend*, - PassRefPtr, PassRefPtr, bool readOnly); - - virtual ~SQLTransactionBackend(); - - void lockAcquired(); - void performNextStep(); + explicit SQLTransactionBackend(SQLTransaction&); + ~SQLTransactionBackend(); -#if PLATFORM(IOS) - bool shouldPerformWhilePaused() const; -#endif - - DatabaseBackend* database() { return m_database.get(); } - bool isReadOnly() { return m_readOnly; } void notifyDatabaseThreadIsShuttingDown(); -private: - SQLTransactionBackend(DatabaseBackend*, PassRefPtr, - PassRefPtr, bool readOnly); + // API called from the frontend published via SQLTransactionBackend: + void requestTransitToState(SQLTransactionState); - // APIs called from the frontend published via AbstractSQLTransactionBackend: - virtual void requestTransitToState(SQLTransactionState) override; - virtual PassRefPtr transactionError() override; - virtual AbstractSQLStatement* currentStatement() override; - virtual void setShouldRetryCurrentStatement(bool) override; - virtual void executeSQL(PassOwnPtr, const String& statement, - const Vector& arguments, int permissions) override; +private: + friend class SQLTransaction; void doCleanup(); - void enqueueStatementBackend(PassRefPtr); - // State Machine functions: - virtual StateFunction stateFunctionFor(SQLTransactionState) override; + StateFunction stateFunctionFor(SQLTransactionState) override; void computeNextStateAndCleanupIfNeeded(); // State functions: - SQLTransactionState acquireLock(); - SQLTransactionState openTransactionAndPreflight(); - SQLTransactionState runStatements(); - SQLTransactionState postflightAndCommit(); - SQLTransactionState cleanupAndTerminate(); - SQLTransactionState cleanupAfterTransactionErrorCallback(); + void acquireLock(); + void openTransactionAndPreflight(); + void runStatements(); + void cleanupAndTerminate(); + void cleanupAfterTransactionErrorCallback(); - SQLTransactionState unreachableState(); - SQLTransactionState sendToFrontendState(); + NO_RETURN_DUE_TO_ASSERT void unreachableState(); - SQLTransactionState nextStateForCurrentStatementError(); - SQLTransactionState nextStateForTransactionError(); - SQLTransactionState runCurrentStatementAndGetNextState(); - - void getNextStatement(); - - void acquireOriginLock(); - void releaseOriginLockIfNeeded(); - - RefPtr m_frontend; // Has a reference cycle, and will break in doCleanup(). - RefPtr m_currentStatementBackend; - - RefPtr m_database; - RefPtr m_wrapper; - RefPtr m_transactionError; - - bool m_hasCallback; - bool m_hasSuccessCallback; - bool m_hasErrorCallback; - bool m_shouldRetryCurrentStatement; - bool m_modifiedDatabase; - bool m_lockAcquired; - bool m_readOnly; - bool m_hasVersionMismatch; - - Mutex m_statementMutex; - Deque> m_statementQueue; - - OwnPtr m_sqliteTransaction; - RefPtr m_originLock; + SQLTransaction& m_frontend; }; } // namespace WebCore - -#endif - -#endif // SQLTransactionBackend_h -- cgit v1.2.1