#include "modules/indexeddb/IDBCursorWithValue.h"
#include "modules/indexeddb/IDBDatabase.h"
#include "modules/indexeddb/IDBEventDispatcher.h"
+#include "modules/indexeddb/IDBPendingTransactionMonitor.h"
#include "modules/indexeddb/IDBTracing.h"
#include "platform/SharedBuffer.h"
#include "public/platform/WebBlobInfo.h"
IDBRequest::~IDBRequest()
{
ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionContext());
+ ASSERT(!m_blobInfo || m_blobInfo->size() == 0);
+}
+
+void IDBRequest::dispose()
+{
handleBlobAcks();
}
m_cursorKey = key;
m_cursorPrimaryKey = primaryKey;
m_cursorValue = value;
- ASSERT(!m_blobInfo.get());
- m_blobInfo = blobInfo;
+ setBlobInfo(blobInfo);
onSuccessInternal(IDBAny::create(cursor));
}
+void IDBRequest::setBlobInfo(PassOwnPtr<Vector<WebBlobInfo>> blobInfo)
+{
+ ASSERT(!m_blobInfo);
+ m_blobInfo = blobInfo;
+ if (m_blobInfo && m_blobInfo->size() > 0)
+ V8PerIsolateData::from(scriptState()->isolate())->ensureIDBPendingTransactionMonitor()->registerRequest(*this);
+}
+
void IDBRequest::handleBlobAcks()
{
if (m_blobInfo.get() && m_blobInfo->size()) {
m_transaction->db()->ackReceivedBlobs(m_blobInfo.get());
m_blobInfo.clear();
+ V8PerIsolateData::from(scriptState()->isolate())->ensureIDBPendingTransactionMonitor()->unregisterRequest(*this);
}
}
m_pendingCursor.clear();
}
- ASSERT(!m_blobInfo.get());
- m_blobInfo = blobInfo;
+ setBlobInfo(blobInfo);
onSuccessInternal(IDBAny::create(valueBuffer, m_blobInfo.get()));
}
RefPtr<SharedBuffer> valueBuffer = prpValueBuffer;
IDBKey* primaryKey = prpPrimaryKey;
- ASSERT(!m_blobInfo.get());
- m_blobInfo = blobInfo;
+ setBlobInfo(blobInfo);
#if ENABLE(ASSERT)
assertPrimaryKeyValidOrInjectable(m_scriptState.get(), valueBuffer, m_blobInfo.get(), primaryKey, keyPath);
IDBCursor* cursorToNotify = 0;
if (event->type() == EventTypeNames::success) {
cursorToNotify = getResultCursor();
- if (cursorToNotify)
+ if (cursorToNotify) {
+ if (m_blobInfo && m_blobInfo->size() > 0)
+ V8PerIsolateData::from(scriptState()->isolate())->ensureIDBPendingTransactionMonitor()->unregisterRequest(*this);
cursorToNotify->setValueReady(m_cursorKey.release(), m_cursorPrimaryKey.release(), m_cursorValue.release(), m_blobInfo.release());
+ }
}
if (event->type() == EventTypeNames::upgradeneeded) {