summaryrefslogtreecommitdiffstats
path: root/gin
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-28 09:31:58 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-28 09:31:58 +0000
commit91cd4febe4c959d8256341e25a59a4d9dca9ca69 (patch)
treefd209b95a98db73a7f6e3b7edfc7cee40de6eb62 /gin
parent8070b950de0375a10e5e79439bfea7dca26d51b1 (diff)
downloadchromium_src-91cd4febe4c959d8256341e25a59a4d9dca9ca69.zip
chromium_src-91cd4febe4c959d8256341e25a59a4d9dca9ca69.tar.gz
chromium_src-91cd4febe4c959d8256341e25a59a4d9dca9ca69.tar.bz2
Remove usage of deprecagted V8 API from gin/
R=mkwst@chromium.org TBR=abarth@chromium.org BUG=324225 Review URL: https://codereview.chromium.org/94413002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237750 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gin')
-rw-r--r--gin/converter.cc6
-rw-r--r--gin/converter.h3
-rw-r--r--gin/converter_unittest.cc56
-rw-r--r--gin/dictionary.cc2
-rw-r--r--gin/function_template.cc3
-rw-r--r--gin/function_template.h.pump1
-rw-r--r--gin/isolate_holder.cc3
-rw-r--r--gin/per_isolate_data.h2
-rw-r--r--gin/wrappable_unittest.cc6
9 files changed, 44 insertions, 38 deletions
diff --git a/gin/converter.cc b/gin/converter.cc
index 04fe7ea..c7a572a 100644
--- a/gin/converter.cc
+++ b/gin/converter.cc
@@ -21,7 +21,7 @@ using v8::Value;
namespace gin {
Handle<Value> Converter<bool>::ToV8(Isolate* isolate, bool val) {
- return Boolean::New(val).As<Value>();
+ return Boolean::New(isolate, val).As<Value>();
}
bool Converter<bool>::FromV8(Isolate* isolate, Handle<Value> val, bool* out) {
@@ -30,7 +30,7 @@ bool Converter<bool>::FromV8(Isolate* isolate, Handle<Value> val, bool* out) {
}
Handle<Value> Converter<int32_t>::ToV8(Isolate* isolate, int32_t val) {
- return Integer::New(val, isolate).As<Value>();
+ return Integer::New(isolate, val).As<Value>();
}
bool Converter<int32_t>::FromV8(Isolate* isolate, Handle<Value> val,
@@ -42,7 +42,7 @@ bool Converter<int32_t>::FromV8(Isolate* isolate, Handle<Value> val,
}
Handle<Value> Converter<uint32_t>::ToV8(Isolate* isolate, uint32_t val) {
- return Integer::NewFromUnsigned(val, isolate).As<Value>();
+ return Integer::NewFromUnsigned(isolate, val).As<Value>();
}
bool Converter<uint32_t>::FromV8(Isolate* isolate, Handle<Value> val,
diff --git a/gin/converter.h b/gin/converter.h
index e36977f..4ff7043 100644
--- a/gin/converter.h
+++ b/gin/converter.h
@@ -127,7 +127,8 @@ template<typename T>
struct Converter<std::vector<T> > {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
const std::vector<T>& val) {
- v8::Handle<v8::Array> result(v8::Array::New(static_cast<int>(val.size())));
+ v8::Handle<v8::Array> result(
+ v8::Array::New(isolate, static_cast<int>(val.size())));
for (size_t i = 0; i < val.size(); ++i) {
result->Set(static_cast<int>(i), Converter<T>::ToV8(isolate, val[i]));
}
diff --git a/gin/converter_unittest.cc b/gin/converter_unittest.cc
index 58ae625..9b831b9 100644
--- a/gin/converter_unittest.cc
+++ b/gin/converter_unittest.cc
@@ -34,25 +34,25 @@ TEST_F(ConverterTest, Bool) {
HandleScope handle_scope(instance_->isolate());
EXPECT_TRUE(Converter<bool>::ToV8(instance_->isolate(), true)->StrictEquals(
- Boolean::New(true)));
+ Boolean::New(instance_->isolate(), true)));
EXPECT_TRUE(Converter<bool>::ToV8(instance_->isolate(), false)->StrictEquals(
- Boolean::New(false)));
+ Boolean::New(instance_->isolate(), false)));
struct {
Handle<Value> input;
bool expected;
} test_data[] = {
- { Boolean::New(false).As<Value>(), false },
- { Boolean::New(true).As<Value>(), true },
- { Number::New(0).As<Value>(), false },
- { Number::New(1).As<Value>(), true },
- { Number::New(-1).As<Value>(), true },
- { Number::New(0.1).As<Value>(), true },
- { String::New("").As<Value>(), false },
- { String::New("foo").As<Value>(), true },
- { Object::New().As<Value>(), true },
- { Null().As<Value>(), false },
- { Undefined().As<Value>(), false },
+ { Boolean::New(instance_->isolate(), false).As<Value>(), false },
+ { Boolean::New(instance_->isolate(), true).As<Value>(), true },
+ { Number::New(instance_->isolate(), 0).As<Value>(), false },
+ { Number::New(instance_->isolate(), 1).As<Value>(), true },
+ { Number::New(instance_->isolate(), -1).As<Value>(), true },
+ { Number::New(instance_->isolate(), 0.1).As<Value>(), true },
+ { String::NewFromUtf8(instance_->isolate(), "").As<Value>(), false },
+ { String::NewFromUtf8(instance_->isolate(), "foo").As<Value>(), true },
+ { Object::New(instance_->isolate()).As<Value>(), true },
+ { Null(instance_->isolate()).As<Value>(), false },
+ { Undefined(instance_->isolate()).As<Value>(), false },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) {
@@ -82,19 +82,19 @@ TEST_F(ConverterTest, Int32) {
bool expect_sucess;
int expected_result;
} test_data_from[] = {
- { Boolean::New(false).As<Value>(), false, 0 },
- { Boolean::New(true).As<Value>(), false, 0 },
- { Integer::New(-1).As<Value>(), true, -1 },
- { Integer::New(0).As<Value>(), true, 0 },
- { Integer::New(1).As<Value>(), true, 1 },
- { Number::New(-1).As<Value>(), true, -1 },
- { Number::New(1.1).As<Value>(), false, 0 },
- { String::New("42").As<Value>(), false, 0 },
- { String::New("foo").As<Value>(), false, 0 },
- { Object::New().As<Value>(), false, 0 },
- { Array::New().As<Value>(), false, 0 },
- { v8::Null().As<Value>(), false, 0 },
- { v8::Undefined().As<Value>(), false, 0 },
+ { Boolean::New(instance_->isolate(), false).As<Value>(), false, 0 },
+ { Boolean::New(instance_->isolate(), true).As<Value>(), false, 0 },
+ { Integer::New(instance_->isolate(), -1).As<Value>(), true, -1 },
+ { Integer::New(instance_->isolate(), 0).As<Value>(), true, 0 },
+ { Integer::New(instance_->isolate(), 1).As<Value>(), true, 1 },
+ { Number::New(instance_->isolate(), -1).As<Value>(), true, -1 },
+ { Number::New(instance_->isolate(), 1.1).As<Value>(), false, 0 },
+ { String::NewFromUtf8(instance_->isolate(), "42").As<Value>(), false, 0 },
+ { String::NewFromUtf8(instance_->isolate(), "foo").As<Value>(), false, 0 },
+ { Object::New(instance_->isolate()).As<Value>(), false, 0 },
+ { Array::New(instance_->isolate()).As<Value>(), false, 0 },
+ { v8::Null(instance_->isolate()).As<Value>(), false, 0 },
+ { v8::Undefined(instance_->isolate()).As<Value>(), false, 0 },
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data_from); ++i) {
@@ -120,8 +120,8 @@ TEST_F(ConverterTest, Vector) {
ASSERT_FALSE(js_array.IsEmpty());
EXPECT_EQ(3u, js_array->Length());
for (size_t i = 0; i < expected.size(); ++i) {
- EXPECT_TRUE(Integer::New(expected[i])->StrictEquals(
- js_array->Get(static_cast<int>(i))));
+ EXPECT_TRUE(Integer::New(instance_->isolate(), expected[i])
+ ->StrictEquals(js_array->Get(static_cast<int>(i))));
}
std::vector<int> actual;
diff --git a/gin/dictionary.cc b/gin/dictionary.cc
index e8b2ac3..d336122 100644
--- a/gin/dictionary.cc
+++ b/gin/dictionary.cc
@@ -21,7 +21,7 @@ Dictionary::~Dictionary() {
Dictionary Dictionary::CreateEmpty(v8::Isolate* isolate) {
Dictionary dictionary(isolate);
- dictionary.object_ = v8::Object::New();
+ dictionary.object_ = v8::Object::New(isolate);
return dictionary;
}
diff --git a/gin/function_template.cc b/gin/function_template.cc
index e8878e0..07882e8 100644
--- a/gin/function_template.cc
+++ b/gin/function_template.cc
@@ -20,7 +20,8 @@ void InitFunctionTemplates(PerIsolateData* isolate_data) {
return;
}
- v8::Handle<v8::ObjectTemplate> templ(v8::ObjectTemplate::New());
+ v8::Handle<v8::ObjectTemplate> templ(
+ v8::ObjectTemplate::New(isolate_data->isolate()));
templ->SetInternalFieldCount(kNumberOfInternalFields);
isolate_data->SetObjectTemplate(&internal::CallbackHolderBase::kWrapperInfo,
templ);
diff --git a/gin/function_template.h.pump b/gin/function_template.h.pump
index 5812c80..1f308ce 100644
--- a/gin/function_template.h.pump
+++ b/gin/function_template.h.pump
@@ -173,6 +173,7 @@ v8::Local<v8::FunctionTemplate> CreateFunctionTemplate(
typedef internal::CallbackHolder<R($for ARG , [[P$(ARG)]])> HolderT;
scoped_refptr<HolderT> holder(new HolderT(callback));
return v8::FunctionTemplate::New(
+ isolate,
&internal::DispatchToCallback<R$for ARG [[, P$(ARG)]]>,
ConvertToV8<internal::CallbackHolderBase*>(isolate, holder.get()));
}
diff --git a/gin/isolate_holder.cc b/gin/isolate_holder.cc
index b5501b6..c9f435c 100644
--- a/gin/isolate_holder.cc
+++ b/gin/isolate_holder.cc
@@ -48,7 +48,8 @@ IsolateHolder::IsolateHolder()
EnsureV8Initialized(true);
isolate_ = v8::Isolate::New();
v8::ResourceConstraints constraints;
- constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory());
+ constraints.ConfigureDefaults(base::SysInfo::AmountOfPhysicalMemory(),
+ base::SysInfo::NumberOfProcessors());
v8::SetResourceConstraints(isolate_, &constraints);
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);
diff --git a/gin/per_isolate_data.h b/gin/per_isolate_data.h
index 4801125..11bbc03 100644
--- a/gin/per_isolate_data.h
+++ b/gin/per_isolate_data.h
@@ -37,6 +37,8 @@ class PerIsolateData {
v8::Local<v8::ObjectTemplate> GetObjectTemplate(WrapperInfo* info);
v8::Local<v8::FunctionTemplate> GetFunctionTemplate(WrapperInfo* info);
+ v8::Isolate* isolate() { return isolate_; }
+
private:
typedef std::map<
WrapperInfo*, v8::Eternal<v8::ObjectTemplate> > ObjectTemplateMap;
diff --git a/gin/wrappable_unittest.cc b/gin/wrappable_unittest.cc
index da57cc3..c653866 100644
--- a/gin/wrappable_unittest.cc
+++ b/gin/wrappable_unittest.cc
@@ -75,12 +75,12 @@ void RegisterTemplate(v8::Isolate* isolate) {
PerIsolateData* data = PerIsolateData::From(isolate);
DCHECK(data->GetObjectTemplate(&MyObject::kWrapperInfo).IsEmpty());
- v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New();
+ v8::Handle<v8::ObjectTemplate> templ = v8::ObjectTemplate::New(isolate);
templ->SetInternalFieldCount(kNumberOfInternalFields);
templ->SetAccessorProperty(
StringToSymbol(isolate, "value"),
- v8::FunctionTemplate::New(MyObjectGetValue),
- v8::FunctionTemplate::New(MyObjectSetValue));
+ v8::FunctionTemplate::New(isolate, MyObjectGetValue),
+ v8::FunctionTemplate::New(isolate, MyObjectSetValue));
data->SetObjectTemplate(&MyObject::kWrapperInfo, templ);
}