summaryrefslogtreecommitdiffstats
path: root/webkit/glue/devtools/bound_object.cc
diff options
context:
space:
mode:
authoryurys@chromium.org <yurys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 14:02:15 +0000
committeryurys@chromium.org <yurys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-10 14:02:15 +0000
commita636b2bc80b36e1a3da8d6013926fa758b861e6b (patch)
tree7d30f6e9ed07f16d88f4793d3046d1355a687e48 /webkit/glue/devtools/bound_object.cc
parent2669ef2b4b212b4b08f8b3848efeebadb25ca4f9 (diff)
downloadchromium_src-a636b2bc80b36e1a3da8d6013926fa758b861e6b.zip
chromium_src-a636b2bc80b36e1a3da8d6013926fa758b861e6b.tar.gz
chromium_src-a636b2bc80b36e1a3da8d6013926fa758b861e6b.tar.bz2
DevTools: destroy BoundObject once JS object has been built. There is no need to keep references to instances of the objects after that.
Review URL: http://codereview.chromium.org/491002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34249 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/devtools/bound_object.cc')
-rw-r--r--webkit/glue/devtools/bound_object.cc23
1 files changed, 9 insertions, 14 deletions
diff --git a/webkit/glue/devtools/bound_object.cc b/webkit/glue/devtools/bound_object.cc
index 051d116..7c08f7a 100644
--- a/webkit/glue/devtools/bound_object.cc
+++ b/webkit/glue/devtools/bound_object.cc
@@ -12,11 +12,9 @@ BoundObject::BoundObject(
void* v8_this,
const char* object_name)
: object_name_(object_name),
- context_(context) {
- v8::HandleScope scope;
+ context_(context),
+ v8_this_(v8_this) {
v8::Context::Scope context_scope(context);
- v8_this_ = v8::Persistent<v8::External>::New(v8::External::New(v8_this));
-
v8::Local<v8::FunctionTemplate> local_template =
v8::FunctionTemplate::New(WebCore::V8Proxy::checkNewLegal);
host_template_ = v8::Persistent<v8::FunctionTemplate>::New(local_template);
@@ -24,34 +22,31 @@ BoundObject::BoundObject(
}
BoundObject::~BoundObject() {
- bound_object_.Dispose();
host_template_.Dispose();
- v8_this_.Dispose();
}
void BoundObject::AddProtoFunction(
const char* name,
v8::InvocationCallback callback) {
- v8::HandleScope scope;
+ v8::Context::Scope context_scope(context_);
v8::Local<v8::Signature> signature = v8::Signature::New(host_template_);
v8::Local<v8::ObjectTemplate> proto = host_template_->PrototypeTemplate();
+ v8::Local<v8::External> v8_this = v8::External::New(v8_this_);
proto->Set(
v8::String::New(name),
v8::FunctionTemplate::New(
callback,
- v8_this_,
+ v8_this,
signature),
static_cast<v8::PropertyAttribute>(v8::DontDelete));
}
void BoundObject::Build() {
- v8::HandleScope scope;
- v8::Context::Scope frame_scope(context_);
-
+ v8::Context::Scope context_scope(context_);
v8::Local<v8::Function> constructor = host_template_->GetFunction();
- bound_object_ = v8::Persistent<v8::Object>::New(
- WebCore::SafeAllocation::newInstance(constructor));
+ v8::Local<v8::Object> bound_object =
+ WebCore::SafeAllocation::newInstance(constructor);
v8::Handle<v8::Object> global = context_->Global();
- global->Set(v8::String::New(object_name_), bound_object_);
+ global->Set(v8::String::New(object_name_), bound_object);
}