Commit 52f0d911 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Fix deprecated V8 function usage in zircon.cc

Fixes uses of deprecated Object::Set and FunctionTemplate::GetFunction
to use Context version that return Maybe values.

Bug: v8:7283, v8:7295, v8:8238, chromium:883496
Change-Id: Ia400ec8b36d138b9f6b87c4a91f7ccb12c2eeefa
Reviewed-on: https://chromium-review.googlesource.com/c/1352314
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: default avatarScott Graham <scottmg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611276}
parent 99312768
......@@ -361,31 +361,48 @@ ZxBindings::ZxBindings(v8::Isolate* isolate, v8::Local<v8::Object> global)
SET_CONSTANT(ZX_ERR_CONNECTION_RESET);
SET_CONSTANT(ZX_ERR_CONNECTION_ABORTED);
v8::Local<v8::Context> context = isolate->GetCurrentContext();
// Handle APIs.
global->Set(
gin::StringToSymbol(isolate, "$ZxObjectWaitOne"),
gin::CreateFunctionTemplate(isolate, base::BindRepeating(ZxObjectWaitOne))
->GetFunction());
global->Set(
gin::StringToSymbol(isolate, "$zx_handle_close"),
gin::CreateFunctionTemplate(isolate, base::BindRepeating(zx_handle_close))
->GetFunction());
global
->Set(context, gin::StringToSymbol(isolate, "$ZxObjectWaitOne"),
gin::CreateFunctionTemplate(isolate,
base::BindRepeating(ZxObjectWaitOne))
->GetFunction(context)
.ToLocalChecked())
.ToChecked();
global
->Set(context, gin::StringToSymbol(isolate, "$zx_handle_close"),
gin::CreateFunctionTemplate(isolate,
base::BindRepeating(zx_handle_close))
->GetFunction(context)
.ToLocalChecked())
.ToChecked();
SET_CONSTANT(ZX_HANDLE_INVALID);
SET_CONSTANT(ZX_TIME_INFINITE);
// Channel APIs.
global->Set(gin::StringToSymbol(isolate, "$ZxChannelCreate"),
global
->Set(context, gin::StringToSymbol(isolate, "$ZxChannelCreate"),
gin::CreateFunctionTemplate(isolate,
base::BindRepeating(&ZxChannelCreate))
->GetFunction());
global->Set(
gin::StringToSymbol(isolate, "$ZxChannelWrite"),
gin::CreateFunctionTemplate(isolate, base::BindRepeating(&ZxChannelWrite))
->GetFunction());
global->Set(
gin::StringToSymbol(isolate, "$ZxChannelRead"),
gin::CreateFunctionTemplate(isolate, base::BindRepeating(&ZxChannelRead))
->GetFunction());
->GetFunction(context)
.ToLocalChecked())
.ToChecked();
global
->Set(context, gin::StringToSymbol(isolate, "$ZxChannelWrite"),
gin::CreateFunctionTemplate(isolate,
base::BindRepeating(&ZxChannelWrite))
->GetFunction(context)
.ToLocalChecked())
.ToChecked();
global
->Set(context, gin::StringToSymbol(isolate, "$ZxChannelRead"),
gin::CreateFunctionTemplate(isolate,
base::BindRepeating(&ZxChannelRead))
->GetFunction(context)
.ToLocalChecked())
.ToChecked();
SET_CONSTANT(ZX_CHANNEL_READABLE);
SET_CONSTANT(ZX_CHANNEL_WRITABLE);
SET_CONSTANT(ZX_CHANNEL_PEER_CLOSED);
......@@ -395,14 +412,20 @@ ZxBindings::ZxBindings(v8::Isolate* isolate, v8::Local<v8::Object> global)
// Utilities to make string handling easier to convert to/from UCS-2 (JS) <->
// UTF-8 (FIDL).
global->Set(
gin::StringToSymbol(isolate, "$FidlJsStrToUtf8Array"),
gin::CreateFunctionTemplate(isolate, base::BindRepeating(&StrToUtf8Array))
->GetFunction());
global->Set(
gin::StringToSymbol(isolate, "$FidlJsUtf8ArrayToStr"),
gin::CreateFunctionTemplate(isolate, base::BindRepeating(&Utf8ArrayToStr))
->GetFunction());
global
->Set(context, gin::StringToSymbol(isolate, "$FidlJsStrToUtf8Array"),
gin::CreateFunctionTemplate(isolate,
base::BindRepeating(&StrToUtf8Array))
->GetFunction(context)
.ToLocalChecked())
.ToChecked();
global
->Set(context, gin::StringToSymbol(isolate, "$FidlJsUtf8ArrayToStr"),
gin::CreateFunctionTemplate(isolate,
base::BindRepeating(&Utf8ArrayToStr))
->GetFunction(context)
.ToLocalChecked())
.ToChecked();
#undef SET_CONSTANT
}
......
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