Index: Source/bindings/v8/ScriptValue.h |
diff --git a/Source/bindings/v8/ScriptValue.h b/Source/bindings/v8/ScriptValue.h |
index dc12b8b94cd865179b11fb149472084e9609f6ba..b2a25d9e5fcb51ea6dcc13f742ca824a2748e640 100644 |
--- a/Source/bindings/v8/ScriptValue.h |
+++ b/Source/bindings/v8/ScriptValue.h |
@@ -57,17 +57,29 @@ typedef Vector<RefPtr<WTF::ArrayBuffer>, 1> ArrayBufferArray; |
class ScriptValue { |
public: |
- ScriptValue() { } |
+ ScriptValue() |
+ : m_isolate(0) |
+ { } |
+ |
virtual ~ScriptValue(); |
ScriptValue(v8::Handle<v8::Value> value, v8::Isolate* isolate) |
- : m_value(value.IsEmpty() ? 0 : SharedPersistent<v8::Value>::create(value, isolate)) |
+ : m_isolate(isolate) |
+ , m_value(value.IsEmpty() ? 0 : SharedPersistent<v8::Value>::create(value, isolate)) |
{ |
} |
ScriptValue(const ScriptValue& value) |
- : m_value(value.m_value) |
+ : m_isolate(value.m_isolate) |
+ , m_value(value.m_value) |
+ { |
+ } |
+ |
+ v8::Isolate* isolate() const |
{ |
+ if (!m_isolate) |
+ m_isolate = v8::Isolate::GetCurrent(); |
+ return m_isolate; |
} |
static ScriptValue createNull() |
@@ -83,8 +95,10 @@ public: |
ScriptValue& operator=(const ScriptValue& value) |
{ |
- if (this != &value) |
+ if (this != &value) { |
m_value = value.m_value; |
+ m_isolate = value.m_isolate; |
+ } |
return *this; |
} |
@@ -159,17 +173,16 @@ public: |
v8::Handle<v8::Value> v8Value() const |
{ |
- return m_value.get() ? m_value->newLocal(v8::Isolate::GetCurrent()) : v8::Handle<v8::Value>(); |
+ return m_value.get() ? m_value->newLocal(m_isolate) : v8::Handle<v8::Value>(); |
} |
- bool getString(ScriptState* scriptState, String& result) const { return getString(result, scriptState->isolate()); } |
- bool getString(String& result) const { return getString(result, v8::Isolate::GetCurrent()); } |
- bool getString(String& result, v8::Isolate*) const; |
- String toString(ScriptState*) const; |
+ bool getString(String& result) const; |
+ String toString() const; |
PassRefPtr<JSONValue> toJSONValue(ScriptState*) const; |
private: |
+ mutable v8::Isolate* m_isolate; |
RefPtr<SharedPersistent<v8::Value> > m_value; |
}; |