IDBBackingStoreTransactionLevelDB.cpp [plain text]
#include "config.h"
#include "IDBBackingStoreTransactionLevelDB.h"
#if ENABLE(INDEXED_DATABASE) && USE(LEVELDB)
#include "IDBBackingStoreLevelDB.h"
#include "Logging.h"
#include <wtf/text/CString.h>
namespace WebCore {
IDBBackingStoreTransactionLevelDB::IDBBackingStoreTransactionLevelDB(int64_t transactionID, IDBBackingStoreLevelDB* backingStore)
: m_transactionID(transactionID)
, m_backingStore(backingStore)
{
}
IDBBackingStoreTransactionLevelDB::~IDBBackingStoreTransactionLevelDB()
{
if (m_backingStore)
m_backingStore->removeBackingStoreTransaction(this);
}
void IDBBackingStoreTransactionLevelDB::begin()
{
LOG(StorageAPI, "IDBBackingStoreTransactionLevelDB::begin");
ASSERT(!m_transaction);
m_transaction = LevelDBTransaction::create(reinterpret_cast<IDBBackingStoreLevelDB*>(m_backingStore)->levelDBDatabase());
}
bool IDBBackingStoreTransactionLevelDB::commit()
{
LOG(StorageAPI, "IDBBackingStoreTransactionLevelDB::commit");
ASSERT(m_transaction);
bool result = m_transaction->commit();
m_transaction.clear();
if (!result)
LOG_ERROR("IndexedDB TransactionCommit Error");
return result;
}
void IDBBackingStoreTransactionLevelDB::rollback()
{
LOG(StorageAPI, "IDBBackingStoreTransactionLevelDB::rollback");
ASSERT(m_transaction);
m_transaction->rollback();
m_transaction.clear();
}
void IDBBackingStoreTransactionLevelDB::resetTransaction()
{
ASSERT(m_backingStore);
m_backingStore->removeBackingStoreTransaction(this);
m_backingStore = 0;
m_transaction = 0;
}
}
#endif // ENABLE(INDEXED_DATABASE) && USE(LEVELDB)