| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ScriptValueSerializerForModules_h | 5 #ifndef ScriptValueSerializerForModules_h |
| 6 #define ScriptValueSerializerForModules_h | 6 #define ScriptValueSerializerForModules_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptValueSerializer.h" | 8 #include "bindings/core/v8/ScriptValueSerializer.h" |
| 9 #include "modules/mediastream/RTCCertificate.h" |
| 9 #include "public/platform/WebCrypto.h" | 10 #include "public/platform/WebCrypto.h" |
| 10 #include "public/platform/WebCryptoKey.h" | 11 #include "public/platform/WebCryptoKey.h" |
| 11 #include "public/platform/WebCryptoKeyAlgorithm.h" | 12 #include "public/platform/WebCryptoKeyAlgorithm.h" |
| 12 #include <v8.h> | 13 #include <v8.h> |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 class SerializedScriptValueWriterForModules final : public SerializedScriptValue
Writer { | 17 class SerializedScriptValueWriterForModules final : public SerializedScriptValue
Writer { |
| 17 STACK_ALLOCATED(); | 18 STACK_ALLOCATED(); |
| 18 WTF_MAKE_NONCOPYABLE(SerializedScriptValueWriterForModules); | 19 WTF_MAKE_NONCOPYABLE(SerializedScriptValueWriterForModules); |
| 19 public: | 20 public: |
| 20 SerializedScriptValueWriterForModules() | 21 SerializedScriptValueWriterForModules() |
| 21 : SerializedScriptValueWriter() | 22 : SerializedScriptValueWriter() |
| 22 { | 23 { |
| 23 } | 24 } |
| 24 | 25 |
| 25 void writeDOMFileSystem(int type, const String& name, const String& url); | 26 void writeDOMFileSystem(int type, const String& name, const String& url); |
| 26 bool writeCryptoKey(const WebCryptoKey&); | 27 bool writeCryptoKey(const WebCryptoKey&); |
| 28 void writeRTCCertificate(const RTCCertificate&); |
| 27 | 29 |
| 28 private: | 30 private: |
| 29 void doWriteHmacKey(const WebCryptoKey&); | 31 void doWriteHmacKey(const WebCryptoKey&); |
| 30 void doWriteAesKey(const WebCryptoKey&); | 32 void doWriteAesKey(const WebCryptoKey&); |
| 31 void doWriteRsaHashedKey(const WebCryptoKey&); | 33 void doWriteRsaHashedKey(const WebCryptoKey&); |
| 32 void doWriteEcKey(const WebCryptoKey&); | 34 void doWriteEcKey(const WebCryptoKey&); |
| 33 void doWriteKeyWithoutParams(const WebCryptoKey&); | 35 void doWriteKeyWithoutParams(const WebCryptoKey&); |
| 34 void doWriteAlgorithmId(WebCryptoAlgorithmId); | 36 void doWriteAlgorithmId(WebCryptoAlgorithmId); |
| 35 void doWriteAsymmetricKeyType(WebCryptoKeyType); | 37 void doWriteAsymmetricKeyType(WebCryptoKeyType); |
| 36 void doWriteNamedCurve(WebCryptoNamedCurve); | 38 void doWriteNamedCurve(WebCryptoNamedCurve); |
| 37 void doWriteKeyUsages(const WebCryptoKeyUsageMask usages, bool extractable); | 39 void doWriteKeyUsages(const WebCryptoKeyUsageMask usages, bool extractable); |
| 38 }; | 40 }; |
| 39 | 41 |
| 40 DEFINE_TYPE_CASTS(SerializedScriptValueWriterForModules, SerializedScriptValueWr
iter, writer, true, true); | 42 DEFINE_TYPE_CASTS(SerializedScriptValueWriterForModules, SerializedScriptValueWr
iter, writer, true, true); |
| 41 | 43 |
| 42 class SerializedScriptValueReaderForModules final : public SerializedScriptValue
Reader { | 44 class SerializedScriptValueReaderForModules final : public SerializedScriptValue
Reader { |
| 43 STACK_ALLOCATED(); | 45 STACK_ALLOCATED(); |
| 44 WTF_MAKE_NONCOPYABLE(SerializedScriptValueReaderForModules); | 46 WTF_MAKE_NONCOPYABLE(SerializedScriptValueReaderForModules); |
| 45 public: | 47 public: |
| 46 SerializedScriptValueReaderForModules(const uint8_t* buffer, int length, con
st WebBlobInfoArray* blobInfo, BlobDataHandleMap& blobDataHandles, ScriptState*
scriptState) | 48 SerializedScriptValueReaderForModules(const uint8_t* buffer, int length, con
st WebBlobInfoArray* blobInfo, BlobDataHandleMap& blobDataHandles, ScriptState*
scriptState) |
| 47 : SerializedScriptValueReader(buffer, length, blobInfo, blobDataHandles,
scriptState) | 49 : SerializedScriptValueReader(buffer, length, blobInfo, blobDataHandles,
scriptState) |
| 48 { | 50 { |
| 49 } | 51 } |
| 50 | 52 |
| 51 bool read(v8::Local<v8::Value>*, ScriptValueCompositeCreator&) override; | 53 bool read(v8::Local<v8::Value>*, ScriptValueCompositeCreator&) override; |
| 52 | 54 |
| 53 private: | 55 private: |
| 54 bool readDOMFileSystem(v8::Local<v8::Value>*); | 56 bool readDOMFileSystem(v8::Local<v8::Value>*); |
| 55 bool readCryptoKey(v8::Local<v8::Value>*); | 57 bool readCryptoKey(v8::Local<v8::Value>*); |
| 58 bool readRTCCertificate(v8::Local<v8::Value>*); |
| 56 bool doReadHmacKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); | 59 bool doReadHmacKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); |
| 57 bool doReadAesKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); | 60 bool doReadAesKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); |
| 58 bool doReadRsaHashedKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); | 61 bool doReadRsaHashedKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); |
| 59 bool doReadEcKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); | 62 bool doReadEcKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); |
| 60 bool doReadKeyWithoutParams(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); | 63 bool doReadKeyWithoutParams(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); |
| 61 bool doReadAlgorithmId(WebCryptoAlgorithmId&); | 64 bool doReadAlgorithmId(WebCryptoAlgorithmId&); |
| 62 bool doReadAsymmetricKeyType(WebCryptoKeyType&); | 65 bool doReadAsymmetricKeyType(WebCryptoKeyType&); |
| 63 bool doReadNamedCurve(WebCryptoNamedCurve&); | 66 bool doReadNamedCurve(WebCryptoNamedCurve&); |
| 64 bool doReadKeyUsages(WebCryptoKeyUsageMask& usages, bool& extractable); | 67 bool doReadKeyUsages(WebCryptoKeyUsageMask& usages, bool& extractable); |
| 65 }; | 68 }; |
| 66 | 69 |
| 67 DEFINE_TYPE_CASTS(SerializedScriptValueReaderForModules, SerializedScriptValueRe
ader, reader, true, true); | 70 DEFINE_TYPE_CASTS(SerializedScriptValueReaderForModules, SerializedScriptValueRe
ader, reader, true, true); |
| 68 | 71 |
| 69 class ScriptValueSerializerForModules final : public ScriptValueSerializer { | 72 class ScriptValueSerializerForModules final : public ScriptValueSerializer { |
| 70 STACK_ALLOCATED(); | 73 STACK_ALLOCATED(); |
| 71 WTF_MAKE_NONCOPYABLE(ScriptValueSerializerForModules); | 74 WTF_MAKE_NONCOPYABLE(ScriptValueSerializerForModules); |
| 72 public: | 75 public: |
| 73 ScriptValueSerializerForModules(SerializedScriptValueWriter&, const Transfer
ables*, WebBlobInfoArray*, BlobDataHandleMap&, v8::TryCatch&, ScriptState*); | 76 ScriptValueSerializerForModules(SerializedScriptValueWriter&, const Transfer
ables*, WebBlobInfoArray*, BlobDataHandleMap&, v8::TryCatch&, ScriptState*); |
| 74 | 77 |
| 75 private: | 78 private: |
| 76 ScriptValueSerializer::StateBase* doSerializeValue(v8::Local<v8::Value>, Scr
iptValueSerializer::StateBase* next) override; | 79 ScriptValueSerializer::StateBase* doSerializeValue(v8::Local<v8::Value>, Scr
iptValueSerializer::StateBase* next) override; |
| 77 | 80 |
| 78 ScriptValueSerializer::StateBase* writeDOMFileSystem(v8::Local<v8::Value>, S
criptValueSerializer::StateBase* next); | 81 ScriptValueSerializer::StateBase* writeDOMFileSystem(v8::Local<v8::Value>, S
criptValueSerializer::StateBase* next); |
| 79 bool writeCryptoKey(v8::Local<v8::Value>); | 82 bool writeCryptoKey(v8::Local<v8::Value>); |
| 83 ScriptValueSerializer::StateBase* writeRTCCertificate(v8::Local<v8::Value>,
ScriptValueSerializer::StateBase* next); |
| 80 }; | 84 }; |
| 81 | 85 |
| 82 class ScriptValueDeserializerForModules final : public ScriptValueDeserializer { | 86 class ScriptValueDeserializerForModules final : public ScriptValueDeserializer { |
| 83 STACK_ALLOCATED(); | 87 STACK_ALLOCATED(); |
| 84 WTF_MAKE_NONCOPYABLE(ScriptValueDeserializerForModules); | 88 WTF_MAKE_NONCOPYABLE(ScriptValueDeserializerForModules); |
| 85 public: | 89 public: |
| 86 ScriptValueDeserializerForModules(SerializedScriptValueReaderForModules&, Me
ssagePortArray* messagePorts, ArrayBufferContentsArray*, ImageBitmapContentsArra
y*); | 90 ScriptValueDeserializerForModules(SerializedScriptValueReaderForModules&, Me
ssagePortArray* messagePorts, ArrayBufferContentsArray*, ImageBitmapContentsArra
y*); |
| 87 | 91 |
| 88 private: | 92 private: |
| 89 bool read(v8::Local<v8::Value>*) override; | 93 bool read(v8::Local<v8::Value>*) override; |
| 90 }; | 94 }; |
| 91 | 95 |
| 92 } // namespace blink | 96 } // namespace blink |
| 93 | 97 |
| 94 #endif // ScriptValueSerializerForModules_h | 98 #endif // ScriptValueSerializerForModules_h |
| OLD | NEW |