| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 V8ScriptValueSerializer_h | 5 #ifndef V8ScriptValueSerializer_h |
| 6 #define V8ScriptValueSerializer_h | 6 #define V8ScriptValueSerializer_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "bindings/core/v8/SerializationTag.h" | 10 #include "bindings/core/v8/SerializationTag.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // Supports only basic JavaScript objects and core DOM types. Support for | 25 // Supports only basic JavaScript objects and core DOM types. Support for |
| 26 // modules types is implemented in a subclass. | 26 // modules types is implemented in a subclass. |
| 27 // | 27 // |
| 28 // A serializer cannot be used multiple times; it is expected that its serialize | 28 // A serializer cannot be used multiple times; it is expected that its serialize |
| 29 // method will be invoked exactly once. | 29 // method will be invoked exactly once. |
| 30 class GC_PLUGIN_IGNORE("https://crbug.com/644725") CORE_EXPORT V8ScriptValueSeri
alizer : public v8::ValueSerializer::Delegate { | 30 class GC_PLUGIN_IGNORE("https://crbug.com/644725") CORE_EXPORT V8ScriptValueSeri
alizer : public v8::ValueSerializer::Delegate { |
| 31 STACK_ALLOCATED(); | 31 STACK_ALLOCATED(); |
| 32 WTF_MAKE_NONCOPYABLE(V8ScriptValueSerializer); | 32 WTF_MAKE_NONCOPYABLE(V8ScriptValueSerializer); |
| 33 public: | 33 public: |
| 34 explicit V8ScriptValueSerializer(RefPtr<ScriptState>); | 34 explicit V8ScriptValueSerializer(RefPtr<ScriptState>); |
| 35 |
| 36 // If not null, blobs will have info written into this array and be |
| 37 // serialized by index. |
| 38 void setBlobInfoArray(WebBlobInfoArray* blobInfoArray) { m_blobInfoArray = b
lobInfoArray; } |
| 39 |
| 35 RefPtr<SerializedScriptValue> serialize(v8::Local<v8::Value>, Transferables*
, ExceptionState&); | 40 RefPtr<SerializedScriptValue> serialize(v8::Local<v8::Value>, Transferables*
, ExceptionState&); |
| 36 | 41 |
| 37 protected: | 42 protected: |
| 38 // Returns true if the DOM object was successfully written. | 43 // Returns true if the DOM object was successfully written. |
| 39 // If false is returned and no more specific exception is thrown, a generic | 44 // If false is returned and no more specific exception is thrown, a generic |
| 40 // DataCloneError message will be used. | 45 // DataCloneError message will be used. |
| 41 virtual bool writeDOMObject(ScriptWrappable*, ExceptionState&); | 46 virtual bool writeDOMObject(ScriptWrappable*, ExceptionState&); |
| 42 | 47 |
| 43 void writeTag(SerializationTag tag) | 48 void writeTag(SerializationTag tag) |
| 44 { | 49 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 61 | 66 |
| 62 // v8::ValueSerializer::Delegate | 67 // v8::ValueSerializer::Delegate |
| 63 void ThrowDataCloneError(v8::Local<v8::String> message) override; | 68 void ThrowDataCloneError(v8::Local<v8::String> message) override; |
| 64 v8::Maybe<bool> WriteHostObject(v8::Isolate*, v8::Local<v8::Object> message)
override; | 69 v8::Maybe<bool> WriteHostObject(v8::Isolate*, v8::Local<v8::Object> message)
override; |
| 65 | 70 |
| 66 RefPtr<ScriptState> m_scriptState; | 71 RefPtr<ScriptState> m_scriptState; |
| 67 RefPtr<SerializedScriptValue> m_serializedScriptValue; | 72 RefPtr<SerializedScriptValue> m_serializedScriptValue; |
| 68 v8::ValueSerializer m_serializer; | 73 v8::ValueSerializer m_serializer; |
| 69 const Transferables* m_transferables = nullptr; | 74 const Transferables* m_transferables = nullptr; |
| 70 const ExceptionState* m_exceptionState = nullptr; | 75 const ExceptionState* m_exceptionState = nullptr; |
| 76 WebBlobInfoArray* m_blobInfoArray = nullptr; |
| 77 |
| 71 #if DCHECK_IS_ON() | 78 #if DCHECK_IS_ON() |
| 72 bool m_serializeInvoked = false; | 79 bool m_serializeInvoked = false; |
| 73 #endif | 80 #endif |
| 74 }; | 81 }; |
| 75 | 82 |
| 76 } // namespace blink | 83 } // namespace blink |
| 77 | 84 |
| 78 #endif // V8ScriptValueSerializer_h | 85 #endif // V8ScriptValueSerializer_h |
| OLD | NEW |