Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Unified Diff: Source/modules/indexeddb/IDBCursor.cpp

Issue 235933013: Add the backchannel for Blobs to be received into Blink from the database backend. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rolled in feedback Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/indexeddb/IDBCursor.h ('k') | Source/modules/indexeddb/IDBDatabase.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/indexeddb/IDBCursor.cpp
diff --git a/Source/modules/indexeddb/IDBCursor.cpp b/Source/modules/indexeddb/IDBCursor.cpp
index 0bad4b057c3ccf7b02a3ec547345e69260da7b7e..9fb73bd4be36ed3fe1fb9f04f721d2be48586522 100644
--- a/Source/modules/indexeddb/IDBCursor.cpp
+++ b/Source/modules/indexeddb/IDBCursor.cpp
@@ -38,6 +38,7 @@
#include "modules/indexeddb/IDBTracing.h"
#include "modules/indexeddb/IDBTransaction.h"
#include "modules/indexeddb/WebIDBCallbacksImpl.h"
+#include "public/platform/WebBlobInfo.h"
#include "public/platform/WebIDBDatabase.h"
#include "public/platform/WebIDBKeyRange.h"
#include <limits>
@@ -96,6 +97,7 @@ IDBCursor::IDBCursor(PassOwnPtr<blink::WebIDBCursor> backend, WebIDBCursor::Dire
IDBCursor::~IDBCursor()
{
+ handleBlobAcks();
}
PassRefPtr<IDBRequest> IDBCursor::update(ExecutionContext* executionContext, ScriptValue& value, ExceptionState& exceptionState)
@@ -291,6 +293,7 @@ void IDBCursor::close()
{
// The notifier may be the last reference to this cursor.
RefPtr<IDBCursor> protect(this);
+ handleBlobAcks();
m_request.clear();
m_backend.clear();
}
@@ -305,6 +308,7 @@ void IDBCursor::checkForReferenceCycle()
if (!hasOneRef() || !m_request->hasOneRef())
return;
+ handleBlobAcks();
m_request.clear();
}
@@ -328,16 +332,18 @@ ScriptValue IDBCursor::value(NewScriptState* scriptState)
const IDBObjectStoreMetadata& metadata = objectStore->metadata();
RefPtr<IDBAny> value;
if (metadata.autoIncrement && !metadata.keyPath.isNull()) {
- value = IDBAny::create(m_value, m_primaryKey, metadata.keyPath);
+ value = IDBAny::create(m_value, m_blobInfo.get(), m_primaryKey, metadata.keyPath);
#ifndef NDEBUG
- assertPrimaryKeyValidOrInjectable(scriptState, m_value, m_primaryKey, metadata.keyPath);
+ assertPrimaryKeyValidOrInjectable(scriptState, m_value, m_blobInfo.get(), m_primaryKey, metadata.keyPath);
#endif
} else {
- value = IDBAny::create(m_value);
+ value = IDBAny::create(m_value, m_blobInfo.get());
}
m_valueDirty = false;
- return idbAnyToScriptValue(scriptState, value);
+ ScriptValue scriptValue = idbAnyToScriptValue(scriptState, value);
+ handleBlobAcks();
+ return scriptValue;
}
ScriptValue IDBCursor::source(NewScriptState* scriptState) const
@@ -345,7 +351,7 @@ ScriptValue IDBCursor::source(NewScriptState* scriptState) const
return idbAnyToScriptValue(scriptState, m_source);
}
-void IDBCursor::setValueReady(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value)
+void IDBCursor::setValueReady(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey, PassRefPtr<SharedBuffer> value, PassOwnPtr<Vector<blink::WebBlobInfo> > blobInfo)
{
m_key = key;
m_keyDirty = true;
@@ -355,6 +361,7 @@ void IDBCursor::setValueReady(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primary
if (isCursorWithValue()) {
m_value = value;
+ m_blobInfo = blobInfo;
jsbell 2014/04/17 19:00:33 If `value` is never accessed, the blobs remain una
ericu 2014/04/17 19:30:14 Right, thanks; I've added a handleBlobAcks() call
jsbell 2014/04/17 20:19:28 Yeah. See comment on another review about propagat
m_valueDirty = true;
}
@@ -376,6 +383,15 @@ bool IDBCursor::isDeleted() const
return m_source->idbIndex()->isDeleted();
}
+void IDBCursor::handleBlobAcks()
+{
+ if (m_blobInfo.get() && m_blobInfo->size()) {
+ ASSERT(m_request);
jsbell 2014/04/17 19:00:33 Can we add a complementary ASSERT (outside the if)
ericu 2014/04/17 19:30:14 Done.
+ m_request->transaction()->db()->ackReceivedBlobs(m_blobInfo.get());
jsbell 2014/04/17 19:00:33 Can use m_transaction
ericu 2014/04/17 19:30:14 Done.
+ m_blobInfo.clear();
+ }
+}
+
WebIDBCursor::Direction IDBCursor::stringToDirection(const String& directionString, ExceptionState& exceptionState)
{
if (directionString.isNull() || directionString == IDBCursor::directionNext())
« no previous file with comments | « Source/modules/indexeddb/IDBCursor.h ('k') | Source/modules/indexeddb/IDBDatabase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698