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.h45
1 files changed, 33 insertions, 12 deletions
diff --git a/WebCore/bindings/v8/SerializedScriptValue.h b/WebCore/bindings/v8/SerializedScriptValue.h
index 26a4199..7eb8935 100644
--- a/WebCore/bindings/v8/SerializedScriptValue.h
+++ b/WebCore/bindings/v8/SerializedScriptValue.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -40,11 +40,26 @@ namespace WebCore {
class SerializedScriptValue : public RefCounted<SerializedScriptValue> {
public:
- static PassRefPtr<SerializedScriptValue> create(String string)
+ // Creates a serialized representation of the given V8 value.
+ static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value> value)
{
- return adoptRef(new SerializedScriptValue(string));
+ return adoptRef(new SerializedScriptValue(value));
}
+ // Creates a serialized value with the given data obtained from a
+ // prior call to toWireString().
+ static PassRefPtr<SerializedScriptValue> createFromWire(String data)
+ {
+ return adoptRef(new SerializedScriptValue(data, WireData));
+ }
+
+ // Creates a serialized representation of WebCore string.
+ static PassRefPtr<SerializedScriptValue> create(String data)
+ {
+ return adoptRef(new SerializedScriptValue(data, StringValue));
+ }
+
+ // Creates an empty serialized value.
static PassRefPtr<SerializedScriptValue> create()
{
return adoptRef(new SerializedScriptValue());
@@ -52,23 +67,29 @@ public:
PassRefPtr<SerializedScriptValue> release()
{
- RefPtr<SerializedScriptValue> result = adoptRef(new SerializedScriptValue(m_data));
+ RefPtr<SerializedScriptValue> result = adoptRef(new SerializedScriptValue(m_data, WireData));
m_data = String();
return result.release();
}
- String toString()
- {
- return m_data;
- }
+ 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();
private:
- SerializedScriptValue(String string)
- : m_data(string)
- {
- }
+ enum StringDataMode {
+ StringValue,
+ WireData
+ };
SerializedScriptValue() { }
+
+ explicit SerializedScriptValue(v8::Handle<v8::Value>);
+
+ SerializedScriptValue(String data, StringDataMode mode);
+
String m_data;
};