This source file includes following definitions.
- create
- m_statementErrorCallbackWrapper
- setBackend
- hasCallback
- hasErrorCallback
- performCallback
#include "config.h"
#include "modules/webdatabase/SQLStatement.h"
#include "platform/Logging.h"
#include "modules/webdatabase/sqlite/SQLiteDatabase.h"
#include "modules/webdatabase/sqlite/SQLiteStatement.h"
#include "modules/webdatabase/AbstractDatabaseServer.h"
#include "modules/webdatabase/AbstractSQLStatementBackend.h"
#include "modules/webdatabase/Database.h"
#include "modules/webdatabase/DatabaseManager.h"
#include "modules/webdatabase/SQLStatementCallback.h"
#include "modules/webdatabase/SQLStatementErrorCallback.h"
#include "modules/webdatabase/SQLTransaction.h"
#include "wtf/text/CString.h"
namespace WebCore {
PassOwnPtr<SQLStatement> SQLStatement::create(Database* database,
PassOwnPtr<SQLStatementCallback> callback, PassOwnPtr<SQLStatementErrorCallback> errorCallback)
{
return adoptPtr(new SQLStatement(database, callback, errorCallback));
}
SQLStatement::SQLStatement(Database* database, PassOwnPtr<SQLStatementCallback> callback,
PassOwnPtr<SQLStatementErrorCallback> errorCallback)
: m_statementCallbackWrapper(callback, database->executionContext())
, m_statementErrorCallbackWrapper(errorCallback, database->executionContext())
{
}
void SQLStatement::setBackend(AbstractSQLStatementBackend* backend)
{
m_backend = backend;
}
bool SQLStatement::hasCallback()
{
return m_statementCallbackWrapper.hasCallback();
}
bool SQLStatement::hasErrorCallback()
{
return m_statementErrorCallbackWrapper.hasCallback();
}
bool SQLStatement::performCallback(SQLTransaction* transaction)
{
ASSERT(transaction);
ASSERT(m_backend);
bool callbackError = false;
OwnPtr<SQLStatementCallback> callback = m_statementCallbackWrapper.unwrap();
OwnPtr<SQLStatementErrorCallback> errorCallback = m_statementErrorCallbackWrapper.unwrap();
SQLErrorData* error = m_backend->sqlError();
if (error) {
if (errorCallback) {
RefPtrWillBeRawPtr<SQLError> sqlError = SQLError::create(*error);
callbackError = errorCallback->handleEvent(transaction, sqlError.get());
}
} else if (callback) {
RefPtrWillBeRawPtr<SQLResultSet> resultSet = m_backend->sqlResultSet();
callbackError = !callback->handleEvent(transaction, resultSet.get());
}
return callbackError;
}
}