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

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

Issue 1409243005: Make ImageBitmap Transferable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix blank line Created 5 years, 2 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/SerializedScriptValueFactory.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValueFactory.cpp b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValueFactory.cpp
index c2a3783803affe335b0031070452ba096e1d9ac8..05d496a55805238c692a0933282d44f441092e1e 100644
--- a/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValueFactory.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/SerializedScriptValueFactory.cpp
@@ -14,7 +14,7 @@ namespace blink {
SerializedScriptValueFactory* SerializedScriptValueFactory::m_instance = 0;
-PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(v8::Isolate* isolate, v8::Local<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, WebBlobInfoArray* blobInfo, ExceptionState& exceptionState)
+PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(v8::Isolate* isolate, v8::Local<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ImageBitmapArray* imageBitmaps, WebBlobInfoArray* blobInfo, ExceptionState& exceptionState)
{
RefPtr<SerializedScriptValue> serializedValue = create();
SerializedScriptValueWriter writer;
@@ -22,7 +22,7 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(v8::Isola
String errorMessage;
{
v8::TryCatch tryCatch;
- status = doSerialize(value, writer, messagePorts, arrayBuffers, blobInfo, serializedValue.get(), tryCatch, errorMessage, isolate);
+ status = doSerialize(value, writer, messagePorts, arrayBuffers, imageBitmaps, blobInfo, serializedValue.get(), tryCatch, errorMessage, isolate);
if (status == ScriptValueSerializer::JSException) {
// If there was a JS exception thrown, re-throw it.
exceptionState.rethrowV8Exception(tryCatch.Exception());
@@ -35,7 +35,7 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(v8::Isola
exceptionState.throwDOMException(ScriptValueSerializer::DataCloneError, errorMessage);
return serializedValue.release();
case ScriptValueSerializer::Success:
- transferData(serializedValue.get(), writer, arrayBuffers, exceptionState, isolate);
+ transferData(serializedValue.get(), writer, arrayBuffers, imageBitmaps, exceptionState, isolate);
return serializedValue.release();
case ScriptValueSerializer::JSException:
ASSERT_NOT_REACHED();
@@ -45,21 +45,21 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(v8::Isola
return serializedValue.release();
}
-PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(v8::Isolate* isolate, v8::Local<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ExceptionState& exceptionState)
+PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(v8::Isolate* isolate, v8::Local<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ImageBitmapArray* imageBitmaps, ExceptionState& exceptionState)
{
- return create(isolate, value, messagePorts, arrayBuffers, 0, exceptionState);
+ return create(isolate, value, messagePorts, arrayBuffers, imageBitmaps, 0, exceptionState);
}
PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::createAndSwallowExceptions(v8::Isolate* isolate, v8::Local<v8::Value> value)
{
TrackExceptionState exceptionState;
- return create(isolate, value, 0, 0, exceptionState);
+ return create(isolate, value, 0, 0, 0, exceptionState);
}
PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(v8::Isolate* isolate, const ScriptValue& value, WebBlobInfoArray* blobInfo, ExceptionState& exceptionState)
{
ASSERT(isolate->InContext());
- return create(isolate, value.v8Value(), 0, 0, blobInfo, exceptionState);
+ return create(isolate, value.v8Value(), 0, 0, 0, blobInfo, exceptionState);
}
PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::createFromWire(const String& data)
@@ -100,23 +100,26 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create()
return adoptRef(new SerializedScriptValue());
}
-void SerializedScriptValueFactory::transferData(SerializedScriptValue* serializedValue, SerializedScriptValueWriter& writer, ArrayBufferArray* arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate)
+void SerializedScriptValueFactory::transferData(SerializedScriptValue* serializedValue, SerializedScriptValueWriter& writer, ArrayBufferArray* arrayBuffers, ImageBitmapArray* imageBitmaps, ExceptionState& exceptionState, v8::Isolate* isolate)
{
serializedValue->setData(writer.takeWireString());
ASSERT(serializedValue->data().impl()->hasOneRef());
- if (!arrayBuffers || !arrayBuffers->size())
+ if ((!arrayBuffers || !arrayBuffers->size()) && (!imageBitmaps || !imageBitmaps->size()))
return;
- serializedValue->transferArrayBuffers(isolate, *arrayBuffers, exceptionState);
+ if (!imageBitmaps || !imageBitmaps->size())
+ serializedValue->transferArrayBuffers(isolate, *arrayBuffers, exceptionState);
+ else if (!arrayBuffers || !arrayBuffers->size())
+ serializedValue->transferImageBitmaps(isolate, *imageBitmaps, exceptionState);
}
-ScriptValueSerializer::Status SerializedScriptValueFactory::doSerialize(v8::Local<v8::Value> value, SerializedScriptValueWriter& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, WebBlobInfoArray* blobInfo, SerializedScriptValue* serializedValue, v8::TryCatch& tryCatch, String& errorMessage, v8::Isolate* isolate)
+ScriptValueSerializer::Status SerializedScriptValueFactory::doSerialize(v8::Local<v8::Value> value, SerializedScriptValueWriter& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ImageBitmapArray* imageBitmaps, WebBlobInfoArray* blobInfo, SerializedScriptValue* serializedValue, v8::TryCatch& tryCatch, String& errorMessage, v8::Isolate* isolate)
{
- return doSerialize(value, writer, messagePorts, arrayBuffers, blobInfo, serializedValue->blobDataHandles(), tryCatch, errorMessage, isolate);
+ return doSerialize(value, writer, messagePorts, arrayBuffers, imageBitmaps, blobInfo, serializedValue->blobDataHandles(), tryCatch, errorMessage, isolate);
}
-ScriptValueSerializer::Status SerializedScriptValueFactory::doSerialize(v8::Local<v8::Value> value, SerializedScriptValueWriter& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, WebBlobInfoArray* blobInfo, BlobDataHandleMap& blobDataHandles, v8::TryCatch& tryCatch, String& errorMessage, v8::Isolate* isolate)
+ScriptValueSerializer::Status SerializedScriptValueFactory::doSerialize(v8::Local<v8::Value> value, SerializedScriptValueWriter& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ImageBitmapArray* imageBitmaps, WebBlobInfoArray* blobInfo, BlobDataHandleMap& blobDataHandles, v8::TryCatch& tryCatch, String& errorMessage, v8::Isolate* isolate)
{
- ScriptValueSerializer serializer(writer, messagePorts, arrayBuffers, blobInfo, blobDataHandles, tryCatch, ScriptState::current(isolate));
+ ScriptValueSerializer serializer(writer, messagePorts, arrayBuffers, imageBitmaps, blobInfo, blobDataHandles, tryCatch, ScriptState::current(isolate));
ScriptValueSerializer::Status status = serializer.serialize(value);
errorMessage = serializer.errorMessage();
return status;
@@ -127,10 +130,10 @@ v8::Local<v8::Value> SerializedScriptValueFactory::deserialize(SerializedScriptV
// deserialize() can run arbitrary script (e.g., setters), which could result in |this| being destroyed.
// Holding a RefPtr ensures we are alive (along with our internal data) throughout the operation.
RefPtr<SerializedScriptValue> protect(value);
- return deserialize(value->data(), value->blobDataHandles(), value->arrayBufferContentsArray(), isolate, messagePorts, blobInfo);
+ return deserialize(value->data(), value->blobDataHandles(), value->arrayBufferContentsArray(), value->imageBitmapArray(), isolate, messagePorts, blobInfo);
}
-v8::Local<v8::Value> SerializedScriptValueFactory::deserialize(String& data, BlobDataHandleMap& blobDataHandles, ArrayBufferContentsArray* arrayBufferContentsArray, v8::Isolate* isolate, MessagePortArray* messagePorts, const WebBlobInfoArray* blobInfo)
+v8::Local<v8::Value> SerializedScriptValueFactory::deserialize(String& data, BlobDataHandleMap& blobDataHandles, ArrayBufferContentsArray* arrayBufferContentsArray, ImageBitmapArray* imageBitmaps, v8::Isolate* isolate, MessagePortArray* messagePorts, const WebBlobInfoArray* blobInfo)
{
if (!data.impl())
return v8::Null(isolate);
@@ -141,7 +144,7 @@ v8::Local<v8::Value> SerializedScriptValueFactory::deserialize(String& data, Blo
// information stored in m_data isn't even encoded in UTF-16. Instead,
// unicode characters are encoded as UTF-8 with two code units per UChar.
SerializedScriptValueReader reader(reinterpret_cast<const uint8_t*>(data.impl()->characters16()), 2 * data.length(), blobInfo, blobDataHandles, ScriptState::current(isolate));
- ScriptValueDeserializer deserializer(reader, messagePorts, arrayBufferContentsArray);
+ ScriptValueDeserializer deserializer(reader, messagePorts, arrayBufferContentsArray, imageBitmaps);
// deserialize() can run arbitrary script (e.g., setters), which could result in |this| being destroyed.
// Holding a RefPtr ensures we are alive (along with our internal data) throughout the operation.

Powered by Google App Engine
This is Rietveld 408576698