OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "v8_proxy.h" | 9 #include "V8Proxy.h" |
10 #include "webkit/glue/devtools/bound_object.h" | 10 #include "webkit/glue/devtools/bound_object.h" |
11 | 11 |
12 using namespace WebCore; | 12 using namespace WebCore; |
13 | 13 |
14 BoundObject::BoundObject( | 14 BoundObject::BoundObject( |
15 v8::Handle<v8::Context> context, | 15 v8::Handle<v8::Context> context, |
16 void* v8_this, | 16 void* v8_this, |
17 const char* object_name) | 17 const char* object_name) |
18 : context_(context), | 18 : context_(context), |
19 object_name_(object_name) { | 19 object_name_(object_name) { |
20 v8::HandleScope scope; | 20 v8::HandleScope scope; |
21 v8::Context::Scope context_scope(context); | 21 v8::Context::Scope context_scope(context); |
22 v8_this_ = v8::Persistent<v8::External>::New(v8::External::New(v8_this)); | 22 v8_this_ = v8::Persistent<v8::External>::New(v8::External::New(v8_this)); |
23 | 23 |
24 v8::Local<v8::FunctionTemplate> local_template = | 24 v8::Local<v8::FunctionTemplate> local_template = |
25 v8::FunctionTemplate::New(V8Proxy::CheckNewLegal); | 25 v8::FunctionTemplate::New(V8Proxy::checkNewLegal); |
26 host_template_ = v8::Persistent<v8::FunctionTemplate>::New(local_template); | 26 host_template_ = v8::Persistent<v8::FunctionTemplate>::New(local_template); |
27 host_template_->SetClassName(v8::String::New(object_name)); | 27 host_template_->SetClassName(v8::String::New(object_name)); |
28 } | 28 } |
29 | 29 |
30 BoundObject::~BoundObject() { | 30 BoundObject::~BoundObject() { |
31 bound_object_.Dispose(); | 31 bound_object_.Dispose(); |
32 host_template_.Dispose(); | 32 host_template_.Dispose(); |
33 v8_this_.Dispose(); | 33 v8_this_.Dispose(); |
34 } | 34 } |
35 | 35 |
(...skipping 11 matching lines...) Expand all Loading... |
47 signature), | 47 signature), |
48 static_cast<v8::PropertyAttribute>(v8::DontDelete)); | 48 static_cast<v8::PropertyAttribute>(v8::DontDelete)); |
49 } | 49 } |
50 | 50 |
51 void BoundObject::Build() { | 51 void BoundObject::Build() { |
52 v8::HandleScope scope; | 52 v8::HandleScope scope; |
53 v8::Context::Scope frame_scope(context_); | 53 v8::Context::Scope frame_scope(context_); |
54 | 54 |
55 v8::Local<v8::Function> constructor = host_template_->GetFunction(); | 55 v8::Local<v8::Function> constructor = host_template_->GetFunction(); |
56 bound_object_ = v8::Persistent<v8::Object>::New( | 56 bound_object_ = v8::Persistent<v8::Object>::New( |
57 SafeAllocation::NewInstance(constructor)); | 57 SafeAllocation::newInstance(constructor)); |
58 | 58 |
59 v8::Handle<v8::Object> global = context_->Global(); | 59 v8::Handle<v8::Object> global = context_->Global(); |
60 global->Set(v8::String::New(object_name_), bound_object_); | 60 global->Set(v8::String::New(object_name_), bound_object_); |
61 } | 61 } |
OLD | NEW |