OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef TransferableOffscreenCanvasExtractor_h |
| 6 #define TransferableOffscreenCanvasExtractor_h |
| 7 |
| 8 #include "bindings/core/v8/TransferableExtractor.h" |
| 9 #include "bindings/modules/v8/TransferableOffscreenCanvas.h" |
| 10 #include "bindings/modules/v8/V8OffscreenCanvas.h" |
| 11 #include "modules/ModulesExport.h" |
| 12 #include "modules/offscreencanvas/OffscreenCanvas.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class MODULES_EXPORT TransferableOffscreenCanvasExtractor : public TransferableE
xtractor { |
| 17 public: |
| 18 ~TransferableOffscreenCanvasExtractor() override { } |
| 19 bool extract(v8::Local<v8::Value> transferableObject, v8::Isolate* isolate,
Transferables& transferables, ExceptionState& exceptionState, const unsigned i)
override |
| 20 { |
| 21 if (V8OffscreenCanvas::hasInstance(transferableObject, isolate)) { |
| 22 OffscreenCanvas* offscreenCanvas = V8OffscreenCanvas::toImpl(v8::Loc
al<v8::Object>::Cast(transferableObject)); |
| 23 auto& offscreenCanvases = static_cast<TransferableOffscreenCanvas*>(
&transferables)->offscreenCanvases; |
| 24 if (offscreenCanvases.contains(offscreenCanvas)) { |
| 25 exceptionState.throwDOMException(DataCloneError, "OffscreenCanva
s at index " + String::number(i) + " is a duplicate of an earlier OffscreenCanva
s."); |
| 26 return false; |
| 27 } |
| 28 offscreenCanvases.append(offscreenCanvas); |
| 29 return true; |
| 30 } |
| 31 return false; |
| 32 } |
| 33 }; |
| 34 |
| 35 } // namespace blink |
| 36 |
| 37 #endif // TransferableOffscreenCanvasExtractor_h |
OLD | NEW |