IDBTransactionBackendImpl.h [plain text]
#ifndef IDBTransactionBackendImpl_h
#define IDBTransactionBackendImpl_h
#if ENABLE(INDEXED_DATABASE)
#include "DOMStringList.h"
#include "IDBBackingStore.h"
#include "IDBTransactionBackendInterface.h"
#include "IDBTransactionCallbacks.h"
#include "Timer.h"
#include <wtf/Deque.h>
#include <wtf/HashSet.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class IDBDatabaseBackendImpl;
class IDBTransactionBackendImpl : public IDBTransactionBackendInterface {
public:
static PassRefPtr<IDBTransactionBackendImpl> create(DOMStringList* objectStores, unsigned short mode, IDBDatabaseBackendImpl*);
virtual ~IDBTransactionBackendImpl();
virtual PassRefPtr<IDBObjectStoreBackendInterface> objectStore(const String& name, ExceptionCode&);
virtual unsigned short mode() const { return m_mode; }
virtual bool scheduleTask(PassOwnPtr<ScriptExecutionContext::Task> task, PassOwnPtr<ScriptExecutionContext::Task> abortTask);
virtual void didCompleteTaskEvents();
virtual void abort();
virtual void setCallbacks(IDBTransactionCallbacks* callbacks) { m_callbacks = callbacks; }
virtual void registerOpenCursor(IDBCursorBackendImpl*);
virtual void unregisterOpenCursor(IDBCursorBackendImpl*);
void run();
private:
IDBTransactionBackendImpl(DOMStringList* objectStores, unsigned short mode, IDBDatabaseBackendImpl*);
enum State {
Unused, StartPending, Running, Finished, };
void start();
void commit();
void taskTimerFired(Timer<IDBTransactionBackendImpl>*);
void taskEventTimerFired(Timer<IDBTransactionBackendImpl>*);
void closeOpenCursors();
RefPtr<DOMStringList> m_objectStoreNames;
unsigned short m_mode;
State m_state;
RefPtr<IDBTransactionCallbacks> m_callbacks;
RefPtr<IDBDatabaseBackendImpl> m_database;
typedef Deque<OwnPtr<ScriptExecutionContext::Task> > TaskQueue;
TaskQueue m_taskQueue;
TaskQueue m_abortTaskQueue;
RefPtr<IDBBackingStore::Transaction> m_transaction;
Timer<IDBTransactionBackendImpl> m_taskTimer;
Timer<IDBTransactionBackendImpl> m_taskEventTimer;
int m_pendingEvents;
HashSet<IDBCursorBackendImpl*> m_openCursors;
};
}
#endif // ENABLE(INDEXED_DATABASE)
#endif // IDBTransactionBackendImpl_h