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

Unified Diff: third_party/WebKit/Source/bindings/modules/v8/SerializedScriptValueForModulesFactory.cpp

Issue 1862033002: Make OffscreenCanvas Transferable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update layout test results Created 4 years, 8 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/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));

Powered by Google App Engine
This is Rietveld 408576698