Index: Source/modules/indexeddb/IDBRequest.cpp |
diff --git a/Source/modules/indexeddb/IDBRequest.cpp b/Source/modules/indexeddb/IDBRequest.cpp |
index 8bab481acd04588ae746702afc9acc8d6e0995c7..f369a589e9e4af5c76fa96372f709957e81315d0 100644 |
--- a/Source/modules/indexeddb/IDBRequest.cpp |
+++ b/Source/modules/indexeddb/IDBRequest.cpp |
@@ -39,6 +39,7 @@ |
#include "modules/indexeddb/IDBEventDispatcher.h" |
#include "modules/indexeddb/IDBTracing.h" |
#include "platform/SharedBuffer.h" |
+#include "public/platform/WebBlobInfo.h" |
using blink::WebIDBCursor; |
@@ -76,6 +77,7 @@ IDBRequest::IDBRequest(ExecutionContext* context, PassRefPtr<IDBAny> source, IDB |
IDBRequest::~IDBRequest() |
{ |
ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !executionContext()); |
+ handleBlobAcks(); |
} |
ScriptValue IDBRequest::result(ExceptionState& exceptionState) |
@@ -87,7 +89,9 @@ ScriptValue IDBRequest::result(ExceptionState& exceptionState) |
if (m_contextStopped || !executionContext()) |
return ScriptValue(); |
m_resultDirty = false; |
- return idbAnyToScriptValue(m_scriptState.get(), m_result); |
+ ScriptValue value = idbAnyToScriptValue(m_scriptState.get(), m_result); |
+ handleBlobAcks(); |
+ return value; |
} |
PassRefPtrWillBeRawPtr<DOMError> IDBRequest::error(ExceptionState& exceptionState) const |
@@ -179,12 +183,27 @@ IDBCursor* IDBRequest::getResultCursor() const |
return 0; |
} |
-void IDBRequest::setResultCursor(PassRefPtr<IDBCursor> cursor, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value) |
+void IDBRequest::ackReceivedBlobs(const Vector<blink::WebBlobInfo>* blobInfo) |
+{ |
+ ASSERT(blobInfo); |
+ if (!blobInfo->size()) |
+ return; |
+ Vector<blink::WebBlobInfo>::const_iterator iter; |
+ Vector<String> uuids; |
+ uuids.reserveCapacity(blobInfo->size()); |
+ for (iter = blobInfo->begin(); iter != blobInfo->end(); ++iter) |
+ uuids.append(iter->uuid()); |
+ m_transaction->db()->backend()->ackReceivedBlobs(uuids); |
jsbell
2014/04/15 18:29:07
Could just be m_transaction->backendDB()
That sai
ericu
2014/04/16 23:04:14
Done.
|
+} |
+ |
+void IDBRequest::setResultCursor(PassRefPtr<IDBCursor> cursor, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value, PassOwnPtr<Vector<blink::WebBlobInfo> > blobInfo) |
{ |
ASSERT(m_readyState == PENDING); |
m_cursorKey = key; |
m_cursorPrimaryKey = primaryKey; |
m_cursorValue = value; |
+ ASSERT(!m_blobInfo.get()); |
+ m_blobInfo = blobInfo; |
onSuccessInternal(IDBAny::create(cursor)); |
} |
@@ -203,6 +222,14 @@ void IDBRequest::checkForReferenceCycle() |
m_result.clear(); |
} |
+void IDBRequest::handleBlobAcks() |
cmumford
2014/04/15 16:05:02
Why do we check for non-zero size in IDBCursor::ha
ericu
2014/04/16 23:04:14
It seems a reasonable optimization to check that t
|
+{ |
+ if (m_blobInfo.get()) { |
+ ackReceivedBlobs(m_blobInfo.get()); |
+ m_blobInfo.clear(); |
+ } |
+} |
+ |
bool IDBRequest::shouldEnqueueEvent() const |
{ |
if (m_contextStopped || !executionContext()) |
@@ -238,7 +265,7 @@ void IDBRequest::onSuccess(const Vector<String>& stringList) |
onSuccessInternal(IDBAny::create(domStringList.release())); |
} |
-void IDBRequest::onSuccess(PassOwnPtr<blink::WebIDBCursor> backend, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value) |
+void IDBRequest::onSuccess(PassOwnPtr<blink::WebIDBCursor> backend, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value, PassOwnPtr<Vector<blink::WebBlobInfo> > blobInfo) |
{ |
IDB_TRACE("IDBRequest::onSuccess(IDBCursor)"); |
if (!shouldEnqueueEvent()) |
@@ -256,7 +283,7 @@ void IDBRequest::onSuccess(PassOwnPtr<blink::WebIDBCursor> backend, PassRefPtr<I |
default: |
ASSERT_NOT_REACHED(); |
} |
- setResultCursor(cursor, key, primaryKey, value); |
+ setResultCursor(cursor, key, primaryKey, value, blobInfo); |
} |
void IDBRequest::onSuccess(PassRefPtr<IDBKey> idbKey) |
@@ -271,7 +298,7 @@ void IDBRequest::onSuccess(PassRefPtr<IDBKey> idbKey) |
onSuccessInternal(IDBAny::createUndefined()); |
} |
-void IDBRequest::onSuccess(PassRefPtr<SharedBuffer> valueBuffer) |
+void IDBRequest::onSuccess(PassRefPtr<SharedBuffer> valueBuffer, PassOwnPtr<Vector<blink::WebBlobInfo> > blobInfo) |
{ |
IDB_TRACE("IDBRequest::onSuccess(SharedBuffer)"); |
if (!shouldEnqueueEvent()) |
@@ -280,11 +307,14 @@ void IDBRequest::onSuccess(PassRefPtr<SharedBuffer> valueBuffer) |
if (m_pendingCursor) { |
// Value should be null, signifying the end of the cursor's range. |
ASSERT(!valueBuffer.get()); |
+ ASSERT(!blobInfo->size()); |
m_pendingCursor->close(); |
m_pendingCursor.clear(); |
} |
- onSuccessInternal(IDBAny::create(valueBuffer)); |
+ ASSERT(!m_blobInfo.get()); |
+ m_blobInfo = blobInfo; |
+ onSuccessInternal(IDBAny::create(valueBuffer, m_blobInfo.get())); |
} |
#ifndef NDEBUG |
@@ -300,7 +330,7 @@ static PassRefPtr<IDBObjectStore> effectiveObjectStore(PassRefPtr<IDBAny> source |
} |
#endif |
-void IDBRequest::onSuccess(PassRefPtr<SharedBuffer> prpValueBuffer, PassRefPtr<IDBKey> prpPrimaryKey, const IDBKeyPath& keyPath) |
+void IDBRequest::onSuccess(PassRefPtr<SharedBuffer> prpValueBuffer, PassOwnPtr<Vector<blink::WebBlobInfo> > blobInfo, PassRefPtr<IDBKey> prpPrimaryKey, const IDBKeyPath& keyPath) |
{ |
IDB_TRACE("IDBRequest::onSuccess(SharedBuffer, IDBKey, IDBKeyPath)"); |
if (!shouldEnqueueEvent()) |
@@ -312,12 +342,14 @@ void IDBRequest::onSuccess(PassRefPtr<SharedBuffer> prpValueBuffer, PassRefPtr<I |
RefPtr<SharedBuffer> valueBuffer = prpValueBuffer; |
RefPtr<IDBKey> primaryKey = prpPrimaryKey; |
+ ASSERT(!m_blobInfo.get()); |
+ m_blobInfo = blobInfo; |
#ifndef NDEBUG |
- assertPrimaryKeyValidOrInjectable(m_scriptState.get(), valueBuffer, primaryKey, keyPath); |
+ assertPrimaryKeyValidOrInjectable(m_scriptState.get(), valueBuffer, m_blobInfo.get(), primaryKey, keyPath); |
#endif |
- onSuccessInternal(IDBAny::create(valueBuffer, primaryKey, keyPath)); |
+ onSuccessInternal(IDBAny::create(valueBuffer, m_blobInfo.get(), primaryKey, keyPath)); |
} |
void IDBRequest::onSuccess(int64_t value) |
@@ -350,14 +382,14 @@ void IDBRequest::setResult(PassRefPtr<IDBAny> result) |
m_resultDirty = true; |
} |
-void IDBRequest::onSuccess(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value) |
+void IDBRequest::onSuccess(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value, PassOwnPtr<Vector<blink::WebBlobInfo> > blobInfo) |
{ |
IDB_TRACE("IDBRequest::onSuccess(key, primaryKey, value)"); |
if (!shouldEnqueueEvent()) |
return; |
ASSERT(m_pendingCursor); |
- setResultCursor(m_pendingCursor.release(), key, primaryKey, value); |
+ setResultCursor(m_pendingCursor.release(), key, primaryKey, value, blobInfo); |
} |
bool IDBRequest::hasPendingActivity() const |
@@ -430,7 +462,7 @@ bool IDBRequest::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event) |
if (event->type() == EventTypeNames::success) { |
cursorToNotify = getResultCursor(); |
if (cursorToNotify) |
- cursorToNotify->setValueReady(m_cursorKey.release(), m_cursorPrimaryKey.release(), m_cursorValue.release()); |
+ cursorToNotify->setValueReady(m_cursorKey.release(), m_cursorPrimaryKey.release(), m_cursorValue.release(), m_blobInfo.release()); |
} |
if (event->type() == EventTypeNames::upgradeneeded) { |