#ifndef DatabaseSync_h
#define DatabaseSync_h
#include "bindings/v8/ScriptWrappable.h"
#include "heap/Handle.h"
#include "modules/webdatabase/DatabaseBackendSync.h"
#include "modules/webdatabase/DatabaseBase.h"
#include "modules/webdatabase/DatabaseBasicTypes.h"
#include "wtf/Forward.h"
#include "wtf/text/WTFString.h"
#ifndef NDEBUG
#include "platform/weborigin/SecurityOrigin.h"
#endif
namespace WebCore {
class DatabaseCallback;
class ExceptionState;
class SQLTransactionSync;
class SQLTransactionSyncCallback;
class SecurityOrigin;
class DatabaseSync FINAL : public DatabaseBackendSync, public DatabaseBase, public ScriptWrappable {
public:
virtual ~DatabaseSync();
virtual void trace(Visitor*) OVERRIDE;
void changeVersion(const String& oldVersion, const String& newVersion, PassOwnPtr<SQLTransactionSyncCallback>, ExceptionState&);
void transaction(PassOwnPtr<SQLTransactionSyncCallback>, ExceptionState&);
void readTransaction(PassOwnPtr<SQLTransactionSyncCallback>, ExceptionState&);
virtual void closeImmediately() OVERRIDE;
void observeTransaction(SQLTransactionSync&);
const String& lastErrorMessage() const { return m_lastErrorMessage; }
void setLastErrorMessage(const String& message) { m_lastErrorMessage = message; }
void setLastErrorMessage(const char* message, int sqliteCode, const char* sqliteMessage)
{
setLastErrorMessage(String::format("%s (%d, %s)", message, sqliteCode, sqliteMessage));
}
private:
DatabaseSync(DatabaseContext*, const String& name,
const String& expectedVersion, const String& displayName, unsigned long estimatedSize);
static PassRefPtrWillBeRawPtr<DatabaseSync> create(ExecutionContext*, PassRefPtrWillBeRawPtr<DatabaseBackendBase>);
void runTransaction(PassOwnPtr<SQLTransactionSyncCallback>, bool readOnly, ExceptionState&);
void rollbackTransaction(SQLTransactionSync&);
#if ENABLE(OILPAN)
class TransactionObserver {
public:
explicit TransactionObserver(SQLTransactionSync& transaction) : m_transaction(transaction) { }
~TransactionObserver();
private:
SQLTransactionSync& m_transaction;
};
GC_PLUGIN_IGNORE("http://crbug.com/353083")
PersistentHeapHashMap<WeakMember<SQLTransactionSync>, OwnPtr<TransactionObserver> > m_observers;
#endif
String m_lastErrorMessage;
friend class DatabaseManager;
friend class DatabaseServer;
};
}
#endif