#ifndef Database_h
#define Database_h
#include "bindings/v8/ScriptWrappable.h"
#include "modules/webdatabase/DatabaseBackend.h"
#include "modules/webdatabase/DatabaseBase.h"
#include "modules/webdatabase/DatabaseBasicTypes.h"
#include "modules/webdatabase/DatabaseError.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class ChangeVersionData;
class DatabaseCallback;
class DatabaseContext;
class SecurityOrigin;
class SQLTransaction;
class SQLTransactionBackend;
class SQLTransactionCallback;
class SQLTransactionErrorCallback;
class VoidCallback;
class Database FINAL : public DatabaseBackend, public DatabaseBase, public ScriptWrappable {
public:
virtual ~Database();
virtual void trace(Visitor*) OVERRIDE;
virtual String version() const OVERRIDE;
void changeVersion(const String& oldVersion, const String& newVersion, PassOwnPtr<SQLTransactionCallback>, PassOwnPtr<SQLTransactionErrorCallback>, PassOwnPtr<VoidCallback> successCallback);
void transaction(PassOwnPtr<SQLTransactionCallback>, PassOwnPtr<SQLTransactionErrorCallback>, PassOwnPtr<VoidCallback> successCallback);
void readTransaction(PassOwnPtr<SQLTransactionCallback>, PassOwnPtr<SQLTransactionErrorCallback>, PassOwnPtr<VoidCallback> successCallback);
static Database* from(DatabaseBackend*);
DatabaseContext* databaseContext() const { return m_databaseContext.get(); }
Vector<String> tableNames();
virtual SecurityOrigin* securityOrigin() const OVERRIDE;
virtual void closeImmediately() OVERRIDE;
void scheduleTransactionCallback(SQLTransaction*);
private:
Database(DatabaseContext*, const String& name,
const String& expectedVersion, const String& displayName, unsigned long estimatedSize);
PassRefPtrWillBeRawPtr<DatabaseBackend> backend();
static PassRefPtrWillBeRawPtr<Database> create(ExecutionContext*, PassRefPtrWillBeRawPtr<DatabaseBackendBase>);
void runTransaction(PassOwnPtr<SQLTransactionCallback>, PassOwnPtr<SQLTransactionErrorCallback>,
PassOwnPtr<VoidCallback> successCallback, bool readOnly, const ChangeVersionData* = 0);
Vector<String> performGetTableNames();
void reportStartTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
RefPtr<SecurityOrigin> m_databaseThreadSecurityOrigin;
RefPtrWillBeMember<DatabaseContext> m_databaseContext;
friend class DatabaseManager;
friend class DatabaseServer;
friend class DatabaseBackend;
friend class SQLStatement;
friend class SQLTransaction;
};
}
#endif