summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/bindings/modules/v8/serialization/v8_script_value_serializer_for_modules.h
blob: 3ea3283c636f6450bf88dcff0f79d50742993c52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// 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 THIRD_PARTY_BLINK_RENDERER_BINDINGS_MODULES_V8_SERIALIZATION_V8_SCRIPT_VALUE_SERIALIZER_FOR_MODULES_H_
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_MODULES_V8_SERIALIZATION_V8_SCRIPT_VALUE_SERIALIZER_FOR_MODULES_H_

#include "base/memory/scoped_refptr.h"
#include "third_party/blink/public/platform/web_crypto_algorithm.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/v8_script_value_serializer.h"
#include "third_party/blink/renderer/modules/modules_export.h"

namespace blink {

class FileSystemHandle;
class RTCEncodedAudioFrame;
class RTCEncodedVideoFrame;
class VideoFrameHandle;
class WebCryptoKey;

// Extends V8ScriptValueSerializer with support for modules/ types.
class MODULES_EXPORT V8ScriptValueSerializerForModules final
    : public V8ScriptValueSerializer {
 public:
  explicit V8ScriptValueSerializerForModules(
      ScriptState* script_state,
      const SerializedScriptValue::SerializeOptions& options)
      : V8ScriptValueSerializer(script_state, options) {}

 protected:
  bool WriteDOMObject(ScriptWrappable*, ExceptionState&) override;

 private:
  void WriteOneByte(uint8_t byte) { WriteRawBytes(&byte, 1); }
  bool WriteCryptoKey(const WebCryptoKey&, ExceptionState&);
  bool WriteFileSystemHandle(SerializationTag tag,
                             FileSystemHandle* file_system_handle);
  bool WriteRTCEncodedAudioFrame(RTCEncodedAudioFrame*);
  bool WriteRTCEncodedVideoFrame(RTCEncodedVideoFrame*);
  bool WriteVideoFrameHandle(scoped_refptr<VideoFrameHandle>);
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_BINDINGS_MODULES_V8_SERIALIZATION_V8_SCRIPT_VALUE_SERIALIZER_FOR_MODULES_H_