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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp

Issue 2359363005: Support Blob on the V8-based structured clone path. (Closed)
Patch Set: Created 4 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: third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
index 69c43d317d23032577e30afc5c4b68578450c20c..940bdd55bedcb1605fca8d114386c8c33c0e5262 100644
--- a/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/serialization/V8ScriptValueSerializer.cpp
@@ -5,6 +5,7 @@
#include "bindings/core/v8/serialization/V8ScriptValueSerializer.h"
#include "bindings/core/v8/ToV8.h"
+#include "bindings/core/v8/V8Blob.h"
#include "bindings/core/v8/V8ImageBitmap.h"
#include "bindings/core/v8/V8ImageData.h"
#include "bindings/core/v8/V8MessagePort.h"
@@ -12,6 +13,7 @@
#include "core/dom/DOMArrayBufferBase.h"
#include "core/html/ImageData.h"
#include "platform/RuntimeEnabledFeatures.h"
+#include "public/platform/WebBlobInfo.h"
#include "wtf/AutoReset.h"
#include "wtf/text/StringUTF8Adaptor.h"
@@ -123,6 +125,28 @@ void V8ScriptValueSerializer::writeUTF8String(const String& string)
bool V8ScriptValueSerializer::writeDOMObject(ScriptWrappable* wrappable, ExceptionState& exceptionState)
{
const WrapperTypeInfo* wrapperTypeInfo = wrappable->wrapperTypeInfo();
+ if (wrapperTypeInfo == &V8Blob::wrapperTypeInfo) {
+ Blob* blob = wrappable->toImpl<Blob>();
+ if (blob->isClosed()) {
+ exceptionState.throwDOMException(DataCloneError,
+ "A Blob object has been closed, and could therefore not be cloned.");
+ return false;
+ }
+ m_serializedScriptValue->blobDataHandles().set(blob->uuid(), blob->blobDataHandle());
+ if (m_blobInfoArray) {
+ size_t index = m_blobInfoArray->size();
+ DCHECK_LE(index, std::numeric_limits<uint32_t>::max());
+ m_blobInfoArray->emplaceAppend(blob->uuid(), blob->type(), blob->size());
+ writeTag(BlobIndexTag);
+ writeUint32(static_cast<uint32_t>(index));
+ } else {
+ writeTag(BlobTag);
+ writeUTF8String(blob->uuid());
+ writeUTF8String(blob->type());
+ writeUint64(blob->size());
+ }
+ return true;
+ }
if (wrapperTypeInfo == &V8ImageBitmap::wrapperTypeInfo) {
ImageBitmap* imageBitmap = wrappable->toImpl<ImageBitmap>();
if (imageBitmap->isNeutered()) {

Powered by Google App Engine
This is Rietveld 408576698