refactor: replace base::Bind() with base::BindOnce() / base::BindRepeating() (#27447)
This commit is contained in:
parent
b11c5533e8
commit
949fd0728f
10 changed files with 24 additions and 22 deletions
|
@ -185,7 +185,7 @@ gfx::Image Clipboard::ReadImage(gin_helper::Arguments* args) {
|
|||
clipboard->ReadImage(
|
||||
GetClipboardBuffer(args),
|
||||
/* data_dst = */ nullptr,
|
||||
base::Bind(
|
||||
base::BindOnce(
|
||||
[](base::Optional<gfx::Image>* image, const SkBitmap& result) {
|
||||
image->emplace(gfx::Image::CreateFrom1xBitmap(result));
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ struct Converter<base::RepeatingCallback<Sig>> {
|
|||
// We don't use CreateFunctionTemplate here because it creates a new
|
||||
// FunctionTemplate everytime, which is cached by V8 and causes leaks.
|
||||
auto translater =
|
||||
base::Bind(&gin_helper::NativeFunctionInvoker<Sig>::Go, val);
|
||||
base::BindRepeating(&gin_helper::NativeFunctionInvoker<Sig>::Go, val);
|
||||
// To avoid memory leak, we ensure that the callback can only be called
|
||||
// for once.
|
||||
return gin_helper::CreateFunctionFromTranslater(isolate, translater, true);
|
||||
|
|
|
@ -142,7 +142,8 @@ template <typename Sig>
|
|||
v8::Local<v8::Value> CallbackToV8Leaked(
|
||||
v8::Isolate* isolate,
|
||||
const base::RepeatingCallback<Sig>& val) {
|
||||
Translater translater = base::Bind(&NativeFunctionInvoker<Sig>::Go, val);
|
||||
Translater translater =
|
||||
base::BindRepeating(&NativeFunctionInvoker<Sig>::Go, val);
|
||||
return CreateFunctionFromTranslater(isolate, translater, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class Wrappable : public WrappableBase {
|
|||
static void SetConstructor(v8::Isolate* isolate,
|
||||
const base::Callback<Sig>& constructor) {
|
||||
v8::Local<v8::FunctionTemplate> templ = gin_helper::CreateFunctionTemplate(
|
||||
isolate, base::Bind(&internal::InvokeNew<Sig>, constructor));
|
||||
isolate, base::BindRepeating(&internal::InvokeNew<Sig>, constructor));
|
||||
templ->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
T::BuildPrototype(isolate, templ);
|
||||
gin::PerIsolateData::From(isolate)->SetFunctionTemplate(&kWrapperInfo,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue