This source file includes following definitions.
- GetHandle
- WeakCallback
#include "gin/function_template.h"
namespace gin {
namespace internal {
CallbackHolderBase::CallbackHolderBase(v8::Isolate* isolate)
: v8_ref_(isolate, v8::External::New(isolate, this)) {
v8_ref_.SetWeak(this, &CallbackHolderBase::WeakCallback);
}
CallbackHolderBase::~CallbackHolderBase() {
DCHECK(v8_ref_.IsEmpty());
}
v8::Handle<v8::External> CallbackHolderBase::GetHandle(v8::Isolate* isolate) {
return v8::Local<v8::External>::New(isolate, v8_ref_);
}
void CallbackHolderBase::WeakCallback(
const v8::WeakCallbackData<v8::External, CallbackHolderBase>& data) {
data.GetParameter()->v8_ref_.Reset();
delete data.GetParameter();
}
}
}