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

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: small cleanup Created 7 years 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 6b5e375a910bd72b73a673edbdb4fa33a03487c0..e7cb34750329d20b1780bb53bbcd61a4933d9f6e 100644
--- a/Source/modules/indexeddb/IDBObjectStore.cpp
+++ b/Source/modules/indexeddb/IDBObjectStore.cpp
@@ -41,12 +41,17 @@
#include "modules/indexeddb/IDBTransaction.h"
#include "modules/indexeddb/WebIDBCallbacksImpl.h"
#include "platform/SharedBuffer.h"
+#include "platform/blob/BlobInfo.h"
+#include "public/platform/WebBlobInfo.h"
#include "public/platform/WebData.h"
#include "public/platform/WebIDBKey.h"
#include "public/platform/WebIDBKeyRange.h"
+#include "public/platform/WebVector.h"
+using blink::WebBlobInfo;
using blink::WebIDBDatabase;
using blink::WebIDBCallbacks;
+using blink::WebVector;
namespace WebCore {
@@ -164,16 +169,11 @@ PassRefPtr<IDBRequest> IDBObjectStore::put(WebIDBDatabase::PutMode putMode, Pass
// FIXME: Make SerializedScriptValue::create etc take an ExceptionState or use ScriptState::setDOMException.
bool didThrow = false;
- RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(value, didThrow, state);
+ Vector<BlobInfo> blobInfo;
+ RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValue::create(value, &blobInfo, didThrow, state);
if (didThrow)
return 0;
- if (serializedValue->containsBlobs()) {
- // FIXME: Add Blob/File/FileList support
- exceptionState.throwUninformativeAndGenericDOMException(DataCloneError);
- return 0;
- }
-
const IDBKeyPath& keyPath = m_metadata.keyPath;
const bool usesInLineKeys = !keyPath.isNull();
const bool hasKeyGenerator = autoIncrement();
@@ -226,7 +226,17 @@ PassRefPtr<IDBRequest> IDBObjectStore::put(WebIDBDatabase::PutMode putMode, Pass
Vector<char> wireBytes;
serializedValue->toWireBytes(wireBytes);
RefPtr<SharedBuffer> valueBuffer = SharedBuffer::adoptVector(wireBytes);
- backendDB()->put(m_transaction->id(), id(), blink::WebData(valueBuffer), key.release(), static_cast<WebIDBDatabase::PutMode>(putMode), WebIDBCallbacksImpl::create(request).leakPtr(), indexIds, indexKeys);
+
+ WebVector<WebBlobInfo> webBlobInfo(blobInfo.size());
+ for (size_t i = 0; i < blobInfo.size(); ++i) {
+ const WebCore::BlobInfo& info = blobInfo[i];
+ if (info.isFile())
+ webBlobInfo[i] = WebBlobInfo(info.uuid(), info.filePath(), info.fileName(), info.type());
+ else
+ webBlobInfo[i] = WebBlobInfo(info.uuid(), info.type(), info.size());
+ }
+
+ backendDB()->put(m_transaction->id(), id(), blink::WebData(valueBuffer), webBlobInfo, key.release(), static_cast<WebIDBDatabase::PutMode>(putMode), WebIDBCallbacksImpl::create(request).leakPtr(), indexIds, indexKeys);
return request.release();
}

Powered by Google App Engine
This is Rietveld 408576698