chore: remove native_mate (Part 2) (#20106)
* add notice to files being removed * add gin version of function_template.h * rename callback.h to avoid confliction * add gin version of callback_converter * add gin converter for OnceCallback * remove callback_converter_gin_adapter.h * remove gin_util.h and gin_utils.h * fix lint warning * add helper for setting methods
This commit is contained in:
parent
504cdb13f0
commit
81ae154714
42 changed files with 866 additions and 202 deletions
36
shell/common/gin_helper/function_template.cc
Normal file
36
shell/common/gin_helper/function_template.cc
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2019 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE.chromium file.
|
||||
|
||||
#include "shell/common/gin_helper/function_template.h"
|
||||
|
||||
namespace gin_helper {
|
||||
|
||||
CallbackHolderBase::CallbackHolderBase(v8::Isolate* isolate)
|
||||
: v8_ref_(isolate, v8::External::New(isolate, this)) {
|
||||
v8_ref_.SetWeak(this, &CallbackHolderBase::FirstWeakCallback,
|
||||
v8::WeakCallbackType::kParameter);
|
||||
}
|
||||
|
||||
CallbackHolderBase::~CallbackHolderBase() {
|
||||
DCHECK(v8_ref_.IsEmpty());
|
||||
}
|
||||
|
||||
v8::Local<v8::External> CallbackHolderBase::GetHandle(v8::Isolate* isolate) {
|
||||
return v8::Local<v8::External>::New(isolate, v8_ref_);
|
||||
}
|
||||
|
||||
// static
|
||||
void CallbackHolderBase::FirstWeakCallback(
|
||||
const v8::WeakCallbackInfo<CallbackHolderBase>& data) {
|
||||
data.GetParameter()->v8_ref_.Reset();
|
||||
data.SetSecondPassCallback(SecondWeakCallback);
|
||||
}
|
||||
|
||||
// static
|
||||
void CallbackHolderBase::SecondWeakCallback(
|
||||
const v8::WeakCallbackInfo<CallbackHolderBase>& data) {
|
||||
delete data.GetParameter();
|
||||
}
|
||||
|
||||
} // namespace gin_helper
|
Loading…
Add table
Add a link
Reference in a new issue