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 |