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

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

Issue 18590006: Blob support for IDB [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merge fixes [builds, untested] Created 7 years, 3 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
Index: Source/modules/indexeddb/IDBObjectStore.cpp
diff --git a/Source/modules/indexeddb/IDBObjectStore.cpp b/Source/modules/indexeddb/IDBObjectStore.cpp
index 8f6b4ae18ea3e23b55196b426ef67cfdd821d4a1..2ac8e0fc6409dc5b298bdd4cf7dc3cde7242f714 100644
--- a/Source/modules/indexeddb/IDBObjectStore.cpp
+++ b/Source/modules/indexeddb/IDBObjectStore.cpp
@@ -163,16 +163,12 @@ PassRefPtr<IDBRequest> IDBObjectStore::put(IDBDatabaseBackendInterface::PutMode
// FIXME: Make serialize etc take an ExceptionState or use ScriptState::setDOMException.
bool didThrow = false;
- RefPtr<SerializedScriptValue> serializedValue = value.serialize(state, 0, 0, didThrow);
+ Vector<BlobInfo> blobInfo;
+ RefPtr<SerializedScriptValue> serializedValue = value.serialize(state, &blobInfo, didThrow);
+ ASSERT(serializedValue->blobInfo() == &blobInfo);
if (didThrow)
return 0;
- if (serializedValue->blobURLs().size() > 0) {
- // FIXME: Add Blob/File/FileList support
- es.throwDOMException(DataCloneError);
- return 0;
- }
-
const IDBKeyPath& keyPath = m_metadata.keyPath;
const bool usesInLineKeys = !keyPath.isNull();
const bool hasKeyGenerator = autoIncrement();
@@ -225,7 +221,15 @@ PassRefPtr<IDBRequest> IDBObjectStore::put(IDBDatabaseBackendInterface::PutMode
Vector<char> wireBytes;
serializedValue->toWireBytes(wireBytes);
RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes);
- backendDB()->put(m_transaction->id(), id(), valueBuffer, key.release(), static_cast<IDBDatabaseBackendInterface::PutMode>(putMode), request, indexIds, indexKeys);
+ backendDB()->put(m_transaction->id(), id(), valueBuffer, serializedValue->blobInfo(), key.release(), static_cast<IDBDatabaseBackendInterface::PutMode>(putMode), request, indexIds, indexKeys);
jsbell 2013/09/12 22:52:17 If we remove m_blobInfo from SSV, this can just th
ericu 2013/11/20 23:06:08 Done.
+ // TODO(ericu): Hold a reference to each blob in serializedValue->blobInfo()
jsbell 2013/09/12 22:52:17 Adding a vector of blob refs to IDBTransaction sou
ericu 2013/11/20 23:06:08 Updated TODO.
+ // until the transaction's committed or this value is overwritten or
+ // otherwise removed. We have to grab it here, rather than the backend, to
+ // avoid a race. Blobs live on the IO thread in the backend, and IDB
+ // requests are handled on the IDB task runner; if we grabbed the blob
+ // references on the IO thread before switching to the IDB task runner, that
+ // would work too, but it's probably safer to have the refs held in the
+ // renderer, in case of crashes, request failures, etc.
return request.release();
}

Powered by Google App Engine
This is Rietveld 408576698