Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Unified Diff: Source/bindings/v8/ScriptValue.h

Issue 23513066: Pass isolate to ScriptPromise and ScriptString constructors (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nits Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/ScriptString.cpp ('k') | Source/bindings/v8/ScriptValue.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
};
« no previous file with comments | « Source/bindings/v8/ScriptString.cpp ('k') | Source/bindings/v8/ScriptValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698