Commit 6c14c914 authored by Mythri Alle's avatar Mythri Alle Committed by Commit Bot

Change deprecated V8 API calls to use non-deprecated versions

Change the soon to be deprecated API calls to use the alternate
non-deprecated versions

Bug: v8:8238
Change-Id: I9a6fff7c23cef953d8cf941e5cc32c7da451195e
Reviewed-on: https://chromium-review.googlesource.com/c/1349692Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610823}
parent f790abc9
......@@ -372,7 +372,7 @@ std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8ValueImpl(
}
if (val->IsInt32())
return std::make_unique<base::Value>(val->ToInt32(isolate)->Value());
return std::make_unique<base::Value>(val.As<v8::Int32>()->Value());
if (val->IsNumber()) {
double val_as_double = val.As<v8::Number>()->Value();
......@@ -405,7 +405,7 @@ std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8ValueImpl(
if (!date_allowed_)
// JSON.stringify would convert this to a string, but an object is more
// consistent within this class.
return FromV8Object(val->ToObject(isolate), state, isolate);
return FromV8Object(val.As<v8::Object>(), state, isolate);
v8::Date* date = v8::Date::Cast(*val);
return std::make_unique<base::Value>(date->ValueOf() / 1000.0);
}
......@@ -471,12 +471,15 @@ std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8Array(
for (uint32_t i = 0; i < val->Length(); ++i) {
v8::TryCatch try_catch(isolate);
v8::Local<v8::Value> child_v8 = val->Get(i);
if (try_catch.HasCaught()) {
v8::MaybeLocal<v8::Value> maybe_child =
val->Get(isolate->GetCurrentContext(), i);
if (try_catch.HasCaught() || !maybe_child.ToLocal(&child_v8)) {
LOG(ERROR) << "Getter for index " << i << " threw an exception.";
child_v8 = v8::Null(isolate);
}
if (!val->HasRealIndexedProperty(i)) {
if (!val->HasRealIndexedProperty(isolate->GetCurrentContext(), i)
.FromMaybe(false)) {
result->Append(std::make_unique<base::Value>());
continue;
}
......@@ -562,10 +565,15 @@ std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8Object(
return std::make_unique<base::DictionaryValue>();
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
v8::Local<v8::Array> property_names(val->GetOwnPropertyNames());
v8::Local<v8::Array> property_names;
if (!val->GetOwnPropertyNames(isolate->GetCurrentContext())
.ToLocal(&property_names)) {
return std::move(result);
}
for (uint32_t i = 0; i < property_names->Length(); ++i) {
v8::Local<v8::Value> key(property_names->Get(i));
v8::Local<v8::Value> key =
property_names->Get(isolate->GetCurrentContext(), i).ToLocalChecked();
// Extend this test to cover more types as necessary and if sensible.
if (!key->IsString() &&
......@@ -579,9 +587,10 @@ std::unique_ptr<base::Value> V8ValueConverterImpl::FromV8Object(
v8::String::Utf8Value name_utf8(isolate, key);
v8::TryCatch try_catch(isolate);
v8::Local<v8::Value> child_v8 = val->Get(key);
if (try_catch.HasCaught()) {
v8::Local<v8::Value> child_v8;
v8::MaybeLocal<v8::Value> maybe_child =
val->Get(isolate->GetCurrentContext(), key);
if (try_catch.HasCaught() || !maybe_child.ToLocal(&child_v8)) {
LOG(WARNING) << "Getter for property " << *name_utf8
<< " threw an exception.";
child_v8 = v8::Null(isolate);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment