Commit 17efa884 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Fix uses of deprecated V8 functions

Pass Isolate* through to StringObject::New, String::Concat,
Value::ToString and StackTrace::GetFrame as the non-Isolate forms are
deprecated.

Change-Id: Ib064eb3beba9493ba67e679118a6369c22cb92cb
Reviewed-on: https://chromium-review.googlesource.com/1150030Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577964}
parent 3de1818c
...@@ -24,19 +24,23 @@ std::unique_ptr<base::Value> SummarizeV8Value(v8::Isolate* isolate, ...@@ -24,19 +24,23 @@ std::unique_ptr<base::Value> SummarizeV8Value(v8::Isolate* isolate,
isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE); isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE);
v8::Local<v8::String> name = v8::String::NewFromUtf8(isolate, "["); v8::Local<v8::String> name = v8::String::NewFromUtf8(isolate, "[");
if (object->IsFunction()) { if (object->IsFunction()) {
name = name = v8::String::Concat(isolate, name,
v8::String::Concat(name, v8::String::NewFromUtf8(isolate, "Function")); v8::String::NewFromUtf8(isolate, "Function"));
v8::Local<v8::Value> fname = v8::Local<v8::Value> fname =
v8::Local<v8::Function>::Cast(object)->GetName(); v8::Local<v8::Function>::Cast(object)->GetName();
if (fname->IsString() && v8::Local<v8::String>::Cast(fname)->Length()) { if (fname->IsString() && v8::Local<v8::String>::Cast(fname)->Length()) {
name = v8::String::Concat(name, v8::String::NewFromUtf8(isolate, " ")); name = v8::String::Concat(isolate, name,
name = v8::String::Concat(name, v8::Local<v8::String>::Cast(fname)); v8::String::NewFromUtf8(isolate, " "));
name = v8::String::Concat(name, v8::String::NewFromUtf8(isolate, "()")); name =
v8::String::Concat(isolate, name, v8::Local<v8::String>::Cast(fname));
name = v8::String::Concat(isolate, name,
v8::String::NewFromUtf8(isolate, "()"));
} }
} else { } else {
name = v8::String::Concat(name, object->GetConstructorName()); name = v8::String::Concat(isolate, name, object->GetConstructorName());
} }
name = v8::String::Concat(name, v8::String::NewFromUtf8(isolate, "]")); name =
v8::String::Concat(isolate, name, v8::String::NewFromUtf8(isolate, "]"));
if (try_catch.HasCaught()) { if (try_catch.HasCaught()) {
return std::unique_ptr<base::Value>( return std::unique_ptr<base::Value>(
......
...@@ -109,9 +109,9 @@ void SetExportsProperty( ...@@ -109,9 +109,9 @@ void SetExportsProperty(
v8::Local<v8::Object> obj = args.This(); v8::Local<v8::Object> obj = args.This();
CHECK_EQ(2, args.Length()); CHECK_EQ(2, args.Length());
CHECK(args[0]->IsString()); CHECK(args[0]->IsString());
v8::Maybe<bool> result = v8::Maybe<bool> result = obj->DefineOwnProperty(
obj->DefineOwnProperty(args.GetIsolate()->GetCurrentContext(), args.GetIsolate()->GetCurrentContext(),
args[0]->ToString(), args[1], v8::ReadOnly); args[0]->ToString(args.GetIsolate()), args[1], v8::ReadOnly);
if (!result.FromMaybe(false)) if (!result.FromMaybe(false))
LOG(ERROR) << "Failed to set private property on the export."; LOG(ERROR) << "Failed to set private property on the export.";
} }
...@@ -656,8 +656,8 @@ v8::Local<v8::String> ModuleSystem::WrapSource(v8::Local<v8::String> source) { ...@@ -656,8 +656,8 @@ v8::Local<v8::String> ModuleSystem::WrapSource(v8::Local<v8::String> source) {
"$JSON, $Object, $RegExp, $String, $Error) {" "$JSON, $Object, $RegExp, $String, $Error) {"
"'use strict';"); "'use strict';");
v8::Local<v8::String> right = ToV8StringUnsafe(GetIsolate(), "\n})"); v8::Local<v8::String> right = ToV8StringUnsafe(GetIsolate(), "\n})");
return handle_scope.Escape(v8::Local<v8::String>( return handle_scope.Escape(v8::Local<v8::String>(v8::String::Concat(
v8::String::Concat(left, v8::String::Concat(source, right)))); GetIsolate(), left, v8::String::Concat(GetIsolate(), source, right))));
} }
void ModuleSystem::Private(const v8::FunctionCallbackInfo<v8::Value>& args) { void ModuleSystem::Private(const v8::FunctionCallbackInfo<v8::Value>& args) {
......
...@@ -182,7 +182,8 @@ class ExtensionImpl : public v8::Extension { ...@@ -182,7 +182,8 @@ class ExtensionImpl : public v8::Extension {
if (info[1]->IsObject()) { if (info[1]->IsObject()) {
recv = v8::Local<v8::Object>::Cast(info[1]); recv = v8::Local<v8::Object>::Cast(info[1]);
} else if (info[1]->IsString()) { } else if (info[1]->IsString()) {
recv = v8::StringObject::New(v8::Local<v8::String>::Cast(info[1])) recv = v8::StringObject::New(info.GetIsolate(),
v8::Local<v8::String>::Cast(info[1]))
.As<v8::Object>(); .As<v8::Object>();
} else { } else {
info.GetIsolate()->ThrowException( info.GetIsolate()->ThrowException(
......
...@@ -428,7 +428,7 @@ std::string ScriptContext::GetStackTraceAsString() const { ...@@ -428,7 +428,7 @@ std::string ScriptContext::GetStackTraceAsString() const {
} }
std::string result; std::string result;
for (int i = 0; i < stack_trace->GetFrameCount(); ++i) { for (int i = 0; i < stack_trace->GetFrameCount(); ++i) {
v8::Local<v8::StackFrame> frame = stack_trace->GetFrame(i); v8::Local<v8::StackFrame> frame = stack_trace->GetFrame(isolate(), i);
CHECK(!frame.IsEmpty()); CHECK(!frame.IsEmpty());
result += base::StringPrintf( result += base::StringPrintf(
"\n at %s (%s:%d:%d)", "\n at %s (%s:%d:%d)",
......
...@@ -131,7 +131,7 @@ class CaptureExportedStringFunction final : public ScriptFunction { ...@@ -131,7 +131,7 @@ class CaptureExportedStringFunction final : public ScriptFunction {
v8::Local<v8::Value> exported_value = v8::Local<v8::Value> exported_value =
module_namespace->Get(context, V8String(isolate, export_name_)) module_namespace->Get(context, V8String(isolate, export_name_))
.ToLocalChecked(); .ToLocalChecked();
captured_value_ = ToCoreString(exported_value->ToString()); captured_value_ = ToCoreString(exported_value->ToString(isolate));
return ScriptValue(); return ScriptValue();
} }
...@@ -165,11 +165,11 @@ class CaptureErrorFunction final : public ScriptFunction { ...@@ -165,11 +165,11 @@ class CaptureErrorFunction final : public ScriptFunction {
v8::Local<v8::Value> name = v8::Local<v8::Value> name =
error_object->Get(context, V8String(isolate, "name")).ToLocalChecked(); error_object->Get(context, V8String(isolate, "name")).ToLocalChecked();
name_ = ToCoreString(name->ToString()); name_ = ToCoreString(name->ToString(isolate));
v8::Local<v8::Value> message = v8::Local<v8::Value> message =
error_object->Get(context, V8String(isolate, "message")) error_object->Get(context, V8String(isolate, "message"))
.ToLocalChecked(); .ToLocalChecked();
message_ = ToCoreString(message->ToString()); message_ = ToCoreString(message->ToString(isolate));
return ScriptValue(); return ScriptValue();
} }
......
...@@ -62,7 +62,7 @@ class Iteration final : public GarbageCollectedFinalized<Iteration> { ...@@ -62,7 +62,7 @@ class Iteration final : public GarbageCollectedFinalized<Iteration> {
is_valid_ = false; is_valid_ = false;
return; return;
} }
value_ = ToCoreString(value->ToString()); value_ = ToCoreString(value->ToString(v.GetScriptState()->GetIsolate()));
} }
bool IsSet() const { return is_set_; } bool IsSet() const { return is_set_; }
......
...@@ -221,7 +221,7 @@ String DictionaryTest::stringFromIterable( ...@@ -221,7 +221,7 @@ String DictionaryTest::stringFromIterable(
v8::Local<v8::Value> value; v8::Local<v8::Value> value;
if (iterator.GetValue().ToLocal(&value)) if (iterator.GetValue().ToLocal(&value))
result.Append(ToCoreString(value->ToString())); result.Append(ToCoreString(value->ToString(script_state->GetIsolate())));
} }
return result.ToString(); return result.ToString();
......
...@@ -12,9 +12,10 @@ void TraceWrapperV8String::Concat(v8::Isolate* isolate, const String& string) { ...@@ -12,9 +12,10 @@ void TraceWrapperV8String::Concat(v8::Isolate* isolate, const String& string) {
DCHECK(isolate); DCHECK(isolate);
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
v8::Local<v8::String> target_string = v8::Local<v8::String> target_string =
(string_.IsEmpty()) ? V8String(isolate, string) (string_.IsEmpty())
: v8::String::Concat(string_.NewLocal(isolate), ? V8String(isolate, string)
V8String(isolate, string)); : v8::String::Concat(isolate, string_.NewLocal(isolate),
V8String(isolate, string));
string_.Set(isolate, target_string); string_.Set(isolate, target_string);
} }
......
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