| Index: third_party/WebKit/Source/bindings/modules/v8/SerializedScriptValueForModulesFactory.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/modules/v8/SerializedScriptValueForModulesFactory.cpp b/third_party/WebKit/Source/bindings/modules/v8/SerializedScriptValueForModulesFactory.cpp
|
| index a127ba5450a904ed05713f7536019d6590663267..6a0412d35f18782b5ee46c7c2d570c9f7880e173 100644
|
| --- a/third_party/WebKit/Source/bindings/modules/v8/SerializedScriptValueForModulesFactory.cpp
|
| +++ b/third_party/WebKit/Source/bindings/modules/v8/SerializedScriptValueForModulesFactory.cpp
|
| @@ -7,6 +7,7 @@
|
| #include "bindings/core/v8/ExceptionState.h"
|
| #include "bindings/core/v8/SerializedScriptValue.h"
|
| #include "bindings/modules/v8/ScriptValueSerializerForModules.h"
|
| +#include "bindings/modules/v8/TransferableOffscreenCanvas.h"
|
| #include "core/dom/ExceptionCode.h"
|
|
|
| namespace blink {
|
| @@ -50,6 +51,37 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValueForModulesFactory::create
|
| return createFromWire(wireData);
|
| }
|
|
|
| +void SerializedScriptValueForModulesFactory::transferData(SerializedScriptValue* serializedValue, SerializedScriptValueWriter& writer, TransferableArray* transferables, ExceptionState& exceptionState, v8::Isolate* isolate)
|
| +{
|
| + serializedValue->setData(writer.takeWireString());
|
| + ASSERT(serializedValue->data().impl()->hasOneRef());
|
| + if (!transferables)
|
| + return;
|
| + if (auto* transferableOffscreenCanvases = TransferableOffscreenCanvas::get(*transferables)) {
|
| + HeapVector<Member<OffscreenCanvas>, 1> offscreenCanvases = transferableOffscreenCanvases->getArray();
|
| + if (offscreenCanvases.size()) {
|
| + for (size_t i = 0; i < offscreenCanvases.size(); i++) {
|
| + if (offscreenCanvases[i]->isNeutered()) {
|
| + exceptionState.throwDOMException(DataCloneError, "OffscreenCanvas at index " + String::number(i) + " is already neutered.");
|
| + return;
|
| + }
|
| + if (offscreenCanvases[i]->renderingContext()) {
|
| + exceptionState.throwDOMException(DataCloneError, "OffscreenCanvas at index " + String::number(i) + " has an associated context.");
|
| + return;
|
| + }
|
| + }
|
| + HeapHashSet<Member<OffscreenCanvas>> visited;
|
| + for (size_t i = 0; i < offscreenCanvases.size(); i++) {
|
| + if (visited.contains(offscreenCanvases[i].get()))
|
| + continue;
|
| + visited.add(offscreenCanvases[i].get());
|
| + offscreenCanvases[i].get()->setNeutered();
|
| + }
|
| + }
|
| + }
|
| + SerializedScriptValueFactory::transferData(serializedValue, writer, transferables, exceptionState, isolate);
|
| +}
|
| +
|
| ScriptValueSerializer::Status SerializedScriptValueForModulesFactory::doSerialize(v8::Local<v8::Value> value, SerializedScriptValueWriter& writer, MessagePortArray* messagePorts, TransferableArray* transferables, WebBlobInfoArray* blobInfo, BlobDataHandleMap& blobDataHandles, v8::TryCatch& tryCatch, String& errorMessage, v8::Isolate* isolate)
|
| {
|
| ScriptValueSerializerForModules serializer(writer, messagePorts, transferables, blobInfo, blobDataHandles, tryCatch, ScriptState::current(isolate));
|
|
|