| Index: Source/modules/indexeddb/IDBRequest.cpp
|
| diff --git a/Source/modules/indexeddb/IDBRequest.cpp b/Source/modules/indexeddb/IDBRequest.cpp
|
| index 3268a098bd74474215a7df68e7608d6fbf1fba25..3803f4ad3a36af4071ed5dff55a462c2b28cd771 100644
|
| --- a/Source/modules/indexeddb/IDBRequest.cpp
|
| +++ b/Source/modules/indexeddb/IDBRequest.cpp
|
| @@ -40,6 +40,7 @@
|
| #include "modules/indexeddb/IDBTracing.h"
|
| #include "modules/indexeddb/IDBTransaction.h"
|
| #include "platform/SharedBuffer.h"
|
| +#include "platform/blob/BlobInfo.h"
|
| #include "public/platform/WebIDBCursor.h"
|
|
|
| namespace WebCore {
|
| @@ -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)
|
| @@ -85,7 +87,9 @@ ScriptValue IDBRequest::result(ExceptionState& exceptionState)
|
| return ScriptValue();
|
| }
|
| m_resultDirty = false;
|
| - return idbAnyToScriptValue(&m_requestState, m_result);
|
| + ScriptValue value = idbAnyToScriptValue(&m_requestState, m_result);
|
| + handleBlobAcks();
|
| + return value;
|
| }
|
|
|
| PassRefPtr<DOMError> IDBRequest::error(ExceptionState& exceptionState) const
|
| @@ -189,12 +193,28 @@ IDBCursor* IDBRequest::getResultCursor()
|
| return 0;
|
| }
|
|
|
| -void IDBRequest::setResultCursor(PassRefPtr<IDBCursor> cursor, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value)
|
| +void IDBRequest::ackReceivedBlobs(const Vector<BlobInfo>* blobInfo)
|
| +{
|
| + ASSERT(blobInfo);
|
| + if (!blobInfo->size())
|
| + return;
|
| + Vector<BlobInfo>::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);
|
| +}
|
| +
|
| +void IDBRequest::setResultCursor(PassRefPtr<IDBCursor> cursor, PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value, PassOwnPtr<Vector<BlobInfo> > 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));
|
| }
|
| @@ -213,6 +233,14 @@ void IDBRequest::checkForReferenceCycle()
|
| m_result.clear();
|
| }
|
|
|
| +void IDBRequest::handleBlobAcks()
|
| +{
|
| + if (m_blobInfo.get()) {
|
| + ackReceivedBlobs(m_blobInfo.get());
|
| + m_blobInfo.clear();
|
| + }
|
| +}
|
| +
|
| bool IDBRequest::shouldEnqueueEvent() const
|
| {
|
| if (m_contextStopped || !executionContext())
|
| @@ -248,7 +276,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<BlobInfo> > blobInfo)
|
| {
|
| IDB_TRACE("IDBRequest::onSuccess(IDBCursor)");
|
| if (!shouldEnqueueEvent())
|
| @@ -266,7 +294,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)
|
| @@ -281,7 +309,7 @@ void IDBRequest::onSuccess(PassRefPtr<IDBKey> idbKey)
|
| onSuccessInternal(IDBAny::createUndefined());
|
| }
|
|
|
| -void IDBRequest::onSuccess(PassRefPtr<SharedBuffer> valueBuffer)
|
| +void IDBRequest::onSuccess(PassRefPtr<SharedBuffer> valueBuffer, PassOwnPtr<Vector<BlobInfo> > blobInfo)
|
| {
|
| IDB_TRACE("IDBRequest::onSuccess(SharedBuffer)");
|
| if (!shouldEnqueueEvent())
|
| @@ -294,7 +322,9 @@ void IDBRequest::onSuccess(PassRefPtr<SharedBuffer> valueBuffer)
|
| m_pendingCursor.clear();
|
| }
|
|
|
| - onSuccessInternal(IDBAny::create(valueBuffer));
|
| + ASSERT(!m_blobInfo.get());
|
| + m_blobInfo = blobInfo;
|
| + onSuccessInternal(IDBAny::create(valueBuffer, m_blobInfo.get()));
|
| }
|
|
|
| #ifndef NDEBUG
|
| @@ -310,7 +340,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<BlobInfo> > blobInfo, PassRefPtr<IDBKey> prpPrimaryKey, const IDBKeyPath& keyPath)
|
| {
|
| IDB_TRACE("IDBRequest::onSuccess(SharedBuffer, IDBKey, IDBKeyPath)");
|
| if (!shouldEnqueueEvent())
|
| @@ -322,12 +352,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_requestState, valueBuffer, primaryKey, keyPath);
|
| + assertPrimaryKeyValidOrInjectable(&m_requestState, 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)
|
| @@ -360,14 +392,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<BlobInfo> > 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
|
| @@ -436,7 +468,7 @@ bool IDBRequest::dispatchEvent(PassRefPtr<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) {
|
|
|