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 "public/platform/WebCrypto.h" |
| 10 #include "public/platform/WebCryptoKey.h" |
| 11 #include "public/platform/WebCryptoKeyAlgorithm.h" |
| 12 #include <v8.h> |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class SerializedScriptValueWriterForModules final : public SerializedScriptValue
Writer { |
| 17 STACK_ALLOCATED(); |
| 18 WTF_MAKE_NONCOPYABLE(SerializedScriptValueWriterForModules); |
| 19 public: |
| 20 SerializedScriptValueWriterForModules() |
| 21 : SerializedScriptValueWriter() |
| 22 { |
| 23 } |
| 24 |
| 25 void writeDOMFileSystem(int type, const String& name, const String& url); |
| 26 bool writeCryptoKey(const WebCryptoKey&); |
| 27 |
| 28 private: |
| 29 void doWriteHmacKey(const WebCryptoKey&); |
| 30 void doWriteAesKey(const WebCryptoKey&); |
| 31 void doWriteRsaHashedKey(const WebCryptoKey&); |
| 32 void doWriteEcKey(const WebCryptoKey&); |
| 33 void doWriteAlgorithmId(WebCryptoAlgorithmId); |
| 34 void doWriteAsymmetricKeyType(WebCryptoKeyType); |
| 35 void doWriteNamedCurve(WebCryptoNamedCurve); |
| 36 void doWriteKeyUsages(const WebCryptoKeyUsageMask usages, bool extractable); |
| 37 }; |
| 38 |
| 39 DEFINE_TYPE_CASTS(SerializedScriptValueWriterForModules, SerializedScriptValueWr
iter, writer, true, true); |
| 40 |
| 41 class SerializedScriptValueReaderForModules final : public SerializedScriptValue
Reader { |
| 42 STACK_ALLOCATED(); |
| 43 WTF_MAKE_NONCOPYABLE(SerializedScriptValueReaderForModules); |
| 44 public: |
| 45 SerializedScriptValueReaderForModules(const uint8_t* buffer, int length, con
st WebBlobInfoArray* blobInfo, BlobDataHandleMap& blobDataHandles, ScriptState*
scriptState) |
| 46 : SerializedScriptValueReader(buffer, length, blobInfo, blobDataHandles,
scriptState) |
| 47 { |
| 48 } |
| 49 |
| 50 virtual bool read(v8::Handle<v8::Value>*, ScriptValueCompositeCreator&) over
ride; |
| 51 |
| 52 private: |
| 53 bool readDOMFileSystem(v8::Handle<v8::Value>*); |
| 54 bool readCryptoKey(v8::Handle<v8::Value>*); |
| 55 bool doReadHmacKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); |
| 56 bool doReadAesKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); |
| 57 bool doReadRsaHashedKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); |
| 58 bool doReadEcKey(WebCryptoKeyAlgorithm&, WebCryptoKeyType&); |
| 59 bool doReadAlgorithmId(WebCryptoAlgorithmId&); |
| 60 bool doReadAsymmetricKeyType(WebCryptoKeyType&); |
| 61 bool doReadNamedCurve(WebCryptoNamedCurve&); |
| 62 bool doReadKeyUsages(WebCryptoKeyUsageMask& usages, bool& extractable); |
| 63 }; |
| 64 |
| 65 DEFINE_TYPE_CASTS(SerializedScriptValueReaderForModules, SerializedScriptValueRe
ader, reader, true, true); |
| 66 |
| 67 class ScriptValueSerializerForModules final : public ScriptValueSerializer { |
| 68 STACK_ALLOCATED(); |
| 69 WTF_MAKE_NONCOPYABLE(ScriptValueSerializerForModules); |
| 70 public: |
| 71 ScriptValueSerializerForModules(SerializedScriptValueWriter&, MessagePortArr
ay* messagePorts, ArrayBufferArray* arrayBuffers, WebBlobInfoArray*, BlobDataHan
dleMap& blobDataHandles, v8::TryCatch&, ScriptState*); |
| 72 |
| 73 private: |
| 74 virtual ScriptValueSerializer::StateBase* doSerializeValue(v8::Handle<v8::Va
lue>, ScriptValueSerializer::StateBase* next) override; |
| 75 |
| 76 ScriptValueSerializer::StateBase* writeDOMFileSystem(v8::Handle<v8::Value>,
ScriptValueSerializer::StateBase* next); |
| 77 bool writeCryptoKey(v8::Handle<v8::Value>); |
| 78 }; |
| 79 |
| 80 class ScriptValueDeserializerForModules final : public ScriptValueDeserializer { |
| 81 STACK_ALLOCATED(); |
| 82 WTF_MAKE_NONCOPYABLE(ScriptValueDeserializerForModules); |
| 83 public: |
| 84 ScriptValueDeserializerForModules(SerializedScriptValueReaderForModules&, Me
ssagePortArray* messagePorts, ArrayBufferContentsArray*); |
| 85 |
| 86 private: |
| 87 virtual bool read(v8::Local<v8::Value>*) override; |
| 88 }; |
| 89 |
| 90 } // namespace blink |
| 91 |
| 92 #endif // ScriptValueSerializerForModules_h |
OLD | NEW |