diff options
Diffstat (limited to 'webkit/port/bindings/v8')
-rw-r--r-- | webkit/port/bindings/v8/ScriptValue.h | 43 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_proxy.h | 3 |
2 files changed, 38 insertions, 8 deletions
diff --git a/webkit/port/bindings/v8/ScriptValue.h b/webkit/port/bindings/v8/ScriptValue.h index 664858f..4695d0e 100644 --- a/webkit/port/bindings/v8/ScriptValue.h +++ b/webkit/port/bindings/v8/ScriptValue.h @@ -34,6 +34,10 @@ #include "v8.h" +#ifndef NDEBUG +#include "v8_proxy.h" // for register and unregister global handles. +#endif + namespace WebCore { class String; @@ -44,12 +48,22 @@ public: ScriptValue(v8::Handle<v8::Value> value) { - m_value = v8::Persistent<v8::Value>::New(value); + if (!value.IsEmpty()) { + m_value = v8::Persistent<v8::Value>::New(value); +#ifndef NDEBUG + V8Proxy::RegisterGlobalHandle(SCRIPTVALUE, this, m_value); +#endif + } } ScriptValue(const ScriptValue& value) { - m_value = v8::Persistent<v8::Value>::New(value.m_value); + if (!value.m_value.IsEmpty()) { + m_value = v8::Persistent<v8::Value>::New(value.m_value); +#ifndef NDEBUG + V8Proxy::RegisterGlobalHandle(SCRIPTVALUE, this, m_value); +#endif + } } ScriptValue& operator=(const ScriptValue& value) @@ -57,15 +71,30 @@ public: if (this == &value) return *this; - m_value.Dispose(); - m_value = v8::Persistent<v8::Value>::New(value.m_value); + clear(); + if (!value.m_value.IsEmpty()) { + m_value = v8::Persistent<v8::Value>::New(value.m_value); +#ifndef NDEBUG + V8Proxy::RegisterGlobalHandle(SCRIPTVALUE, this, m_value); +#endif + } + return *this; } + void clear() { + if (!m_value.IsEmpty()) { +#ifndef NDEBUG + V8Proxy::UnregisterGlobalHandle(this, m_value); +#endif + m_value.Dispose(); + m_value.Clear(); + } + } + ~ScriptValue() - { - m_value.Dispose(); - m_value.Clear(); + { + clear(); } bool getString(String& result) const; diff --git a/webkit/port/bindings/v8/v8_proxy.h b/webkit/port/bindings/v8/v8_proxy.h index eef19c0..724222f 100644 --- a/webkit/port/bindings/v8/v8_proxy.h +++ b/webkit/port/bindings/v8/v8_proxy.h @@ -86,7 +86,8 @@ void log_info(Frame* frame, const String& msg, const String& url); V(SCHEDULED_ACTION) \ V(EVENT_LISTENER) \ V(NODE_FILTER) \ - V(JSINSTANCE) \ + V(SCRIPTVALUE) \ + V(JSINSTANCE) // Host information of persistent handles. |