| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 ScriptValueSerializerForModules_h | |
| 6 #define ScriptValueSerializerForModules_h | |
| 7 | |
| 8 #include "bindings/core/v8/ScriptValueSerializer.h" | |
| 9 #include "modules/peerconnection/RTCCertificate.h" | |
| 10 #include "public/platform/WebCrypto.h" | |
| 11 #include "public/platform/WebCryptoKey.h" | |
| 12 #include "public/platform/WebCryptoKeyAlgorithm.h" | |
| 13 #include <v8.h> | |
| 14 | |
| 15 namespace blink { | |
| 16 | |
| 17 class SerializedScriptValueWriterForModules final | |
| 18 : public SerializedScriptValueWriter { | |
| 19 STACK_ALLOCATED(); | |
| 20 WTF_MAKE_NONCOPYABLE(SerializedScriptValueWriterForModules); | |
| 21 | |
| 22 public: | |
| 23 SerializedScriptValueWriterForModules() : SerializedScriptValueWriter() {} | |
| 24 | |
| 25 void writeDOMFileSystem(int type, const String& name, const String& url); | |
| 26 bool writeCryptoKey(const WebCryptoKey&); | |
| 27 void writeRTCCertificate(const RTCCertificate&); | |
| 28 | |
| 29 private: | |
| 30 void doWriteHmacKey(const WebCryptoKey&); | |
| 31 void doWriteAesKey(const WebCryptoKey&); | |
| 32 void doWriteRsaHashedKey(const WebCryptoKey&); | |
| 33 void doWriteEcKey(const WebCryptoKey&); | |
| 34 void doWriteKeyWithoutParams(const WebCryptoKey&); | |
| 35 void doWriteAlgorithmId(WebCryptoAlgorithmId); | |
| 36 void doWriteAsymmetricKeyType(WebCryptoKeyType); | |
| 37 void doWriteNamedCurve(WebCryptoNamedCurve); | |
| 38 void doWriteKeyUsages(const WebCryptoKeyUsageMask usages, bool extractable); | |
| 39 }; | |
| 40 | |
| 41 DEFINE_TYPE_CASTS(SerializedScriptValueWriterForModules, | |
| 42 SerializedScriptValueWriter, | |
| 43 writer, | |
| 44 true, | |
| 45 true); | |
| 46 | |
| 47 class SerializedScriptValueReaderForModules final | |
| 48 : public SerializedScriptValueReader { | |
| 49 STACK_ALLOCATED(); | |
| 50 WTF_MAKE_NONCOPYABLE(SerializedScriptValueReaderForModules); | |
| 51 | |
| 52 public: | |
| 53 SerializedScriptValueReaderForModules(const uint8_t* buffer, | |
| 54 int length, | |
| 55 const WebBlobInfoArray* blobInfo, | |
| 56 BlobDataHandleMap& blobDataHandles, | |
| 57 ScriptState* scriptState) | |
| 58 : SerializedScriptValueReader(buffer, | |
| 59 length, | |
| 60 blobInfo, | |
| 61 blobDataHandles, | |
| 62 scriptState) {} | |
| 63 | |
| 64 bool read(v8::Local<v8::Value>*, ScriptValueDeserializer&) override; | |
| 65 | |
| 66 private: | |
| 67 bool readDOMFileSystem(v8::Local<v8::Value>*); | |
| 68 bool readCryptoKey(v8::Local<v8::Value>*); | |
| 69 bool readRTCCertificate(v8::Local<v8::Value>*); | |
| 70 bool doReadHmacKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); | |
| 71 bool doReadAesKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); | |
| 72 bool doReadRsaHashedKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); | |
| 73 bool doReadEcKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); | |
| 74 bool doReadKeyWithoutParams(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); | |
| 75 bool doReadAlgorithmId(WebCryptoAlgorithmId&); | |
| 76 bool doReadAsymmetricKeyType(WebCryptoKeyType&); | |
| 77 bool doReadNamedCurve(WebCryptoNamedCurve&); | |
| 78 bool doReadKeyUsages(WebCryptoKeyUsageMask& usages, bool& extractable); | |
| 79 }; | |
| 80 | |
| 81 DEFINE_TYPE_CASTS(SerializedScriptValueReaderForModules, | |
| 82 SerializedScriptValueReader, | |
| 83 reader, | |
| 84 true, | |
| 85 true); | |
| 86 | |
| 87 class ScriptValueSerializerForModules final : public ScriptValueSerializer { | |
| 88 STACK_ALLOCATED(); | |
| 89 WTF_MAKE_NONCOPYABLE(ScriptValueSerializerForModules); | |
| 90 | |
| 91 public: | |
| 92 ScriptValueSerializerForModules(SerializedScriptValueWriter&, | |
| 93 WebBlobInfoArray*, | |
| 94 ScriptState*); | |
| 95 | |
| 96 private: | |
| 97 StateBase* doSerializeObject(v8::Local<v8::Object>, StateBase* next) override; | |
| 98 | |
| 99 StateBase* writeDOMFileSystem(v8::Local<v8::Value>, StateBase* next); | |
| 100 bool writeCryptoKey(v8::Local<v8::Value>); | |
| 101 StateBase* writeRTCCertificate(v8::Local<v8::Value>, StateBase* next); | |
| 102 }; | |
| 103 | |
| 104 class ScriptValueDeserializerForModules final : public ScriptValueDeserializer { | |
| 105 STACK_ALLOCATED(); | |
| 106 WTF_MAKE_NONCOPYABLE(ScriptValueDeserializerForModules); | |
| 107 | |
| 108 public: | |
| 109 ScriptValueDeserializerForModules(SerializedScriptValueReaderForModules&, | |
| 110 MessagePortArray* messagePorts, | |
| 111 ArrayBufferContentsArray*, | |
| 112 ImageBitmapContentsArray*); | |
| 113 | |
| 114 private: | |
| 115 bool read(v8::Local<v8::Value>*) override; | |
| 116 }; | |
| 117 | |
| 118 } // namespace blink | |
| 119 | |
| 120 #endif // ScriptValueSerializerForModules_h | |
| OLD | NEW |