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 SerializedScriptValueFactory_h |
| 6 #define SerializedScriptValueFactory_h |
| 7 |
| 8 #include "bindings/core/v8/SerializedScriptValue.h" |
| 9 #include "wtf/Noncopyable.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 class SerializedScriptValueFactory { |
| 14 WTF_MAKE_NONCOPYABLE(SerializedScriptValueFactory); |
| 15 public: |
| 16 SerializedScriptValueFactory() { } |
| 17 |
| 18 // If a serialization error occurs (e.g., cyclic input value) this |
| 19 // function returns an empty representation, schedules a V8 exception to |
| 20 // be thrown using v8::ThrowException(), and sets |didThrow|. In this case |
| 21 // the caller must not invoke any V8 operations until control returns to |
| 22 // V8. When serialization is successful, |didThrow| is false. |
| 23 virtual PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, Mess
agePortArray*, ArrayBufferArray*, ExceptionState&, v8::Isolate*); |
| 24 virtual PassRefPtr<SerializedScriptValue> createFromWire(const String&); |
| 25 PassRefPtr<SerializedScriptValue> createFromWireBytes(const Vector<uint8_t>&
); |
| 26 PassRefPtr<SerializedScriptValue> create(const String&); |
| 27 virtual PassRefPtr<SerializedScriptValue> create(const String&, v8::Isolate*
); |
| 28 virtual PassRefPtr<SerializedScriptValue> create(); |
| 29 virtual PassRefPtr<SerializedScriptValue> create(const ScriptValue&, WebBlob
InfoArray*, ExceptionState&, v8::Isolate*); |
| 30 |
| 31 // Never throws exceptions. |
| 32 PassRefPtr<SerializedScriptValue> createAndSwallowExceptions(v8::Isolate*, v
8::Handle<v8::Value>); |
| 33 |
| 34 static SerializedScriptValueFactory& instance() |
| 35 { |
| 36 if (!m_instance) { |
| 37 ASSERT_NOT_REACHED(); |
| 38 m_instance = new SerializedScriptValueFactory(); |
| 39 } |
| 40 return *m_instance; |
| 41 } |
| 42 |
| 43 // SerializedScriptValueFactory::initialize() should be invoked when Blink i
s initialized, |
| 44 // i.e. initializeWithoutV8() in WebKit.cpp. |
| 45 static void initialize(SerializedScriptValueFactory* newFactory) |
| 46 { |
| 47 ASSERT(!m_instance); |
| 48 m_instance = newFactory; |
| 49 } |
| 50 |
| 51 private: |
| 52 static SerializedScriptValueFactory* m_instance; |
| 53 }; |
| 54 |
| 55 } // namespace blink |
| 56 |
| 57 #endif // SerializedScriptValueFactory_h |
| 58 |
OLD | NEW |