summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/SerializedScriptValue.h
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8/SerializedScriptValue.h')
-rw-r--r--WebCore/bindings/v8/SerializedScriptValue.h36
1 files changed, 31 insertions, 5 deletions
diff --git a/WebCore/bindings/v8/SerializedScriptValue.h b/WebCore/bindings/v8/SerializedScriptValue.h
index 7eb8935..8205a42 100644
--- a/WebCore/bindings/v8/SerializedScriptValue.h
+++ b/WebCore/bindings/v8/SerializedScriptValue.h
@@ -40,10 +40,36 @@ namespace WebCore {
class SerializedScriptValue : public RefCounted<SerializedScriptValue> {
public:
+ // Deserializes the given value and sets it as a property on the
+ // object.
+ static void deserializeAndSetProperty(v8::Handle<v8::Object> object,
+ const char* propertyName,
+ v8::PropertyAttribute attribute,
+ SerializedScriptValue* value)
+ {
+ if (!value)
+ return;
+ v8::Handle<v8::Value> deserialized = value->deserialize();
+ object->ForceSet(v8::String::NewSymbol(propertyName), deserialized, attribute);
+ }
+
// Creates a serialized representation of the given V8 value.
static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value> value)
{
- return adoptRef(new SerializedScriptValue(value));
+ bool didThrow;
+ return adoptRef(new SerializedScriptValue(value, didThrow));
+ }
+
+ // Creates a serialized representation of the given V8 value.
+ //
+ // If a serialization error occurs (e.g., cyclic input value) this
+ // function returns an empty representation, schedules a V8 exception to
+ // be thrown using v8::ThrowException(), and sets |didThrow|. In this case
+ // the caller must not invoke any V8 operations until control returns to
+ // V8. When serialization is successful, |didThrow| is false.
+ static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value> value, bool& didThrow)
+ {
+ return adoptRef(new SerializedScriptValue(value, didThrow));
}
// Creates a serialized value with the given data obtained from a
@@ -74,9 +100,9 @@ public:
String toWireString() const { return m_data; }
- // Deserializes the value (in the current context). Returns an
- // empty handle in case of failure.
- v8::Local<v8::Value> deserialize();
+ // Deserializes the value (in the current context). Returns a null value in
+ // case of failure.
+ v8::Handle<v8::Value> deserialize();
private:
enum StringDataMode {
@@ -86,7 +112,7 @@ private:
SerializedScriptValue() { }
- explicit SerializedScriptValue(v8::Handle<v8::Value>);
+ SerializedScriptValue(v8::Handle<v8::Value>, bool& didThrow);
SerializedScriptValue(String data, StringDataMode mode);