#ifndef SQLTransaction_h
#define SQLTransaction_h
#include "bindings/v8/ScriptWrappable.h"
#include "heap/Handle.h"
#include "modules/webdatabase/AbstractSQLTransaction.h"
#include "modules/webdatabase/SQLCallbackWrapper.h"
#include "modules/webdatabase/SQLStatement.h"
#include "modules/webdatabase/SQLTransactionStateMachine.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefPtr.h"
namespace WebCore {
class AbstractSQLTransactionBackend;
class Database;
class ExceptionState;
class SQLErrorData;
class SQLStatementCallback;
class SQLStatementErrorCallback;
class SQLTransactionCallback;
class SQLTransactionErrorCallback;
class SQLValue;
class VoidCallback;
class SQLTransaction FINAL : public AbstractSQLTransaction, public SQLTransactionStateMachine<SQLTransaction>, public ScriptWrappable {
public:
static PassRefPtrWillBeRawPtr<SQLTransaction> create(Database*, PassOwnPtr<SQLTransactionCallback>,
PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<SQLTransactionErrorCallback>,
bool readOnly);
virtual void trace(Visitor*) OVERRIDE;
void performPendingCallback();
void executeSQL(const String& sqlStatement, const Vector<SQLValue>& arguments,
PassOwnPtr<SQLStatementCallback>, PassOwnPtr<SQLStatementErrorCallback>, ExceptionState&);
Database* database() { return m_database.get(); }
PassOwnPtr<SQLTransactionErrorCallback> releaseErrorCallback();
private:
SQLTransaction(Database*, PassOwnPtr<SQLTransactionCallback>,
PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<SQLTransactionErrorCallback>,
bool readOnly);
void clearCallbackWrappers();
virtual void requestTransitToState(SQLTransactionState) OVERRIDE;
virtual bool hasCallback() const OVERRIDE;
virtual bool hasSuccessCallback() const OVERRIDE;
virtual bool hasErrorCallback() const OVERRIDE;
virtual void setBackend(AbstractSQLTransactionBackend*) OVERRIDE;
virtual StateFunction stateFunctionFor(SQLTransactionState) OVERRIDE;
bool computeNextStateAndCleanupIfNeeded();
SQLTransactionState deliverTransactionCallback();
SQLTransactionState deliverTransactionErrorCallback();
SQLTransactionState deliverStatementCallback();
SQLTransactionState deliverQuotaIncreaseCallback();
SQLTransactionState deliverSuccessCallback();
SQLTransactionState unreachableState();
SQLTransactionState sendToBackendState();
SQLTransactionState nextStateForTransactionError();
RefPtrWillBeMember<Database> m_database;
RefPtrWillBeMember<AbstractSQLTransactionBackend> m_backend;
SQLCallbackWrapper<SQLTransactionCallback> m_callbackWrapper;
SQLCallbackWrapper<VoidCallback> m_successCallbackWrapper;
SQLCallbackWrapper<SQLTransactionErrorCallback> m_errorCallbackWrapper;
bool m_executeSqlAllowed;
OwnPtr<SQLErrorData> m_transactionError;
bool m_readOnly;
};
}
#endif