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

Unified Diff: third_party/WebKit/Source/bindings/modules/v8/TransferableOffscreenCanvasExtractor.h

Issue 1862033002: Make OffscreenCanvas Transferable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, compiles but crashes some layout tests 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/TransferableOffscreenCanvasExtractor.h
diff --git a/third_party/WebKit/Source/bindings/modules/v8/TransferableOffscreenCanvasExtractor.h b/third_party/WebKit/Source/bindings/modules/v8/TransferableOffscreenCanvasExtractor.h
new file mode 100644
index 0000000000000000000000000000000000000000..9afd6e5a3366112d7c209c16ffa33e6e0d62b981
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/modules/v8/TransferableOffscreenCanvasExtractor.h
@@ -0,0 +1,37 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TransferableOffscreenCanvasExtractor_h
+#define TransferableOffscreenCanvasExtractor_h
+
+#include "bindings/core/v8/TransferableExtractor.h"
+#include "bindings/modules/v8/TransferableOffscreenCanvas.h"
+#include "bindings/modules/v8/V8OffscreenCanvas.h"
+#include "modules/ModulesExport.h"
+#include "modules/offscreencanvas/OffscreenCanvas.h"
+
+namespace blink {
+
+class MODULES_EXPORT TransferableOffscreenCanvasExtractor : public TransferableExtractor {
+public:
+ ~TransferableOffscreenCanvasExtractor() override { }
+ bool extract(v8::Local<v8::Value> transferableObject, v8::Isolate* isolate, Transferables& transferables, ExceptionState& exceptionState, const unsigned i) override
+ {
+ if (V8OffscreenCanvas::hasInstance(transferableObject, isolate)) {
+ OffscreenCanvas* offscreenCanvas = V8OffscreenCanvas::toImpl(v8::Local<v8::Object>::Cast(transferableObject));
+ auto& offscreenCanvases = static_cast<TransferableOffscreenCanvas*>(&transferables)->offscreenCanvases;
+ if (offscreenCanvases.contains(offscreenCanvas)) {
+ exceptionState.throwDOMException(DataCloneError, "OffscreenCanvas at index " + String::number(i) + " is a duplicate of an earlier OffscreenCanvas.");
+ return false;
+ }
+ offscreenCanvases.append(offscreenCanvas);
+ return true;
+ }
+ return false;
+ }
+};
+
+} // namespace blink
+
+#endif // TransferableOffscreenCanvasExtractor_h

Powered by Google App Engine
This is Rietveld 408576698