Remove unneeded HandleScopes.
It's not necessary to create HandleScope in v8 native binding functions, because it's guarrenteed that the there is a upper HandleScope when the native function is called. So unless we are urgent to free the handles, not using HandleScope in native binding functions is a cleaner and safer choice.
This commit is contained in:
parent
426bc97194
commit
5250871e69
14 changed files with 0 additions and 40 deletions
|
@ -174,8 +174,6 @@ void App::DockGetBadgeText(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void App::Initialize(v8::Handle<v8::Object> target) {
|
void App::Initialize(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
|
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(v8::String::NewSymbol("Application"));
|
t->SetClassName(v8::String::NewSymbol("Application"));
|
||||||
|
|
|
@ -47,8 +47,6 @@ void AutoUpdater::ReadyForUpdateOnQuit(const std::string& version,
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void AutoUpdater::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
void AutoUpdater::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope handle_scope(args.GetIsolate());
|
|
||||||
|
|
||||||
if (!args.IsConstructCall())
|
if (!args.IsConstructCall())
|
||||||
return node::ThrowError("Require constructor call");
|
return node::ThrowError("Require constructor call");
|
||||||
|
|
||||||
|
@ -102,8 +100,6 @@ void AutoUpdater::QuitAndInstall(
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void AutoUpdater::Initialize(v8::Handle<v8::Object> target) {
|
void AutoUpdater::Initialize(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
v8::Local<v8::FunctionTemplate> t(
|
v8::Local<v8::FunctionTemplate> t(
|
||||||
v8::FunctionTemplate::New(AutoUpdater::New));
|
v8::FunctionTemplate::New(AutoUpdater::New));
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
|
|
|
@ -34,8 +34,6 @@ void CallV8Function2(const RefCountedV8Function& callback, bool result, T arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> target) {
|
void Initialize(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
NODE_SET_METHOD(target, "showMessageBox", ShowMessageBox);
|
NODE_SET_METHOD(target, "showMessageBox", ShowMessageBox);
|
||||||
NODE_SET_METHOD(target, "showOpenDialog", ShowOpenDialog);
|
NODE_SET_METHOD(target, "showOpenDialog", ShowOpenDialog);
|
||||||
NODE_SET_METHOD(target, "showSaveDialog", ShowSaveDialog);
|
NODE_SET_METHOD(target, "showSaveDialog", ShowSaveDialog);
|
||||||
|
|
|
@ -121,8 +121,6 @@ void Menu::ExecuteCommand(int command_id, int event_flags) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Menu::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
void Menu::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope handle_scope(args.GetIsolate());
|
|
||||||
|
|
||||||
if (!args.IsConstructCall())
|
if (!args.IsConstructCall())
|
||||||
return node::ThrowError("Require constructor call");
|
return node::ThrowError("Require constructor call");
|
||||||
|
|
||||||
|
@ -307,8 +305,6 @@ void Menu::Popup(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Menu::Initialize(v8::Handle<v8::Object> target) {
|
void Menu::Initialize(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
v8::Local<v8::FunctionTemplate> t(v8::FunctionTemplate::New(Menu::New));
|
v8::Local<v8::FunctionTemplate> t(v8::FunctionTemplate::New(Menu::New));
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(v8::String::NewSymbol("Menu"));
|
t->SetClassName(v8::String::NewSymbol("Menu"));
|
||||||
|
|
|
@ -74,8 +74,6 @@ void MenuMac::SendActionToFirstResponder(const std::string& action) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Menu::SetApplicationMenu(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
void Menu::SetApplicationMenu(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope handle_scope(args.GetIsolate());
|
|
||||||
|
|
||||||
if (!args[0]->IsObject())
|
if (!args[0]->IsObject())
|
||||||
return node::ThrowTypeError("Bad argument");
|
return node::ThrowTypeError("Bad argument");
|
||||||
|
|
||||||
|
@ -94,8 +92,6 @@ void Menu::SetApplicationMenu(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
// static
|
// static
|
||||||
void Menu::SendActionToFirstResponder(
|
void Menu::SendActionToFirstResponder(
|
||||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope handle_scope(args.GetIsolate());
|
|
||||||
|
|
||||||
std::string action;
|
std::string action;
|
||||||
if (!FromV8Arguments(args, &action))
|
if (!FromV8Arguments(args, &action))
|
||||||
return node::ThrowTypeError("Bad argument");
|
return node::ThrowTypeError("Bad argument");
|
||||||
|
|
|
@ -31,8 +31,6 @@ void MenuWin::Popup(NativeWindow* native_window) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Menu::AttachToWindow(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
void Menu::AttachToWindow(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope handle_scope(args.GetIsolate());
|
|
||||||
|
|
||||||
Menu* self = ObjectWrap::Unwrap<Menu>(args.This());
|
Menu* self = ObjectWrap::Unwrap<Menu>(args.This());
|
||||||
if (self == NULL)
|
if (self == NULL)
|
||||||
return node::ThrowError("Menu is already destroyed");
|
return node::ThrowError("Menu is already destroyed");
|
||||||
|
|
|
@ -39,8 +39,6 @@ void PowerMonitor::OnResume() {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void PowerMonitor::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
void PowerMonitor::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope handle_scope(args.GetIsolate());
|
|
||||||
|
|
||||||
if (!args.IsConstructCall())
|
if (!args.IsConstructCall())
|
||||||
return node::ThrowError("Require constructor call");
|
return node::ThrowError("Require constructor call");
|
||||||
|
|
||||||
|
@ -49,8 +47,6 @@ void PowerMonitor::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void PowerMonitor::Initialize(v8::Handle<v8::Object> target) {
|
void PowerMonitor::Initialize(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
|
base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -103,8 +103,6 @@ void Window::OnCapturePageDone(const RefCountedV8Function& callback,
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Window::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
void Window::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope handle_scope(args.GetIsolate());
|
|
||||||
|
|
||||||
if (!args.IsConstructCall())
|
if (!args.IsConstructCall())
|
||||||
return node::ThrowError("Require constructor call");
|
return node::ThrowError("Require constructor call");
|
||||||
|
|
||||||
|
@ -625,8 +623,6 @@ void Window::ReloadIgnoringCache(
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Window::Initialize(v8::Handle<v8::Object> target) {
|
void Window::Initialize(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(Window::New);
|
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(Window::New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(v8::String::NewSymbol("BrowserWindow"));
|
t->SetClassName(v8::String::NewSymbol("BrowserWindow"));
|
||||||
|
|
|
@ -74,8 +74,6 @@ void Clipboard::Clear(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Clipboard::Initialize(v8::Handle<v8::Object> target) {
|
void Clipboard::Initialize(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
NODE_SET_METHOD(target, "has", Has);
|
NODE_SET_METHOD(target, "has", Has);
|
||||||
NODE_SET_METHOD(target, "read", Read);
|
NODE_SET_METHOD(target, "read", Read);
|
||||||
NODE_SET_METHOD(target, "readText", ReadText);
|
NODE_SET_METHOD(target, "readText", ReadText);
|
||||||
|
|
|
@ -122,8 +122,6 @@ void IDWeakMap::Remove(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void IDWeakMap::Initialize(v8::Handle<v8::Object> target) {
|
void IDWeakMap::Initialize(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
|
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(v8::String::NewSymbol("IDWeakMap"));
|
t->SetClassName(v8::String::NewSymbol("IDWeakMap"));
|
||||||
|
|
|
@ -67,8 +67,6 @@ void Screen::GetPrimaryDisplay(
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Screen::Initialize(v8::Handle<v8::Object> target) {
|
void Screen::Initialize(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
|
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(v8::String::NewSymbol("Screen"));
|
t->SetClassName(v8::String::NewSymbol("Screen"));
|
||||||
|
|
|
@ -60,8 +60,6 @@ void Shell::Beep(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Shell::Initialize(v8::Handle<v8::Object> target) {
|
void Shell::Initialize(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
NODE_SET_METHOD(target, "showItemInFolder", ShowItemInFolder);
|
NODE_SET_METHOD(target, "showItemInFolder", ShowItemInFolder);
|
||||||
NODE_SET_METHOD(target, "openItem", OpenItem);
|
NODE_SET_METHOD(target, "openItem", OpenItem);
|
||||||
NODE_SET_METHOD(target, "openExternal", OpenExternal);
|
NODE_SET_METHOD(target, "openExternal", OpenExternal);
|
||||||
|
|
|
@ -46,8 +46,6 @@ void TakeHeapSnapshot(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void InitializeV8Util(v8::Handle<v8::Object> target) {
|
void InitializeV8Util(v8::Handle<v8::Object> target) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
NODE_SET_METHOD(target, "createObjectWithName", CreateObjectWithName);
|
NODE_SET_METHOD(target, "createObjectWithName", CreateObjectWithName);
|
||||||
NODE_SET_METHOD(target, "getHiddenValue", GetHiddenValue);
|
NODE_SET_METHOD(target, "getHiddenValue", GetHiddenValue);
|
||||||
NODE_SET_METHOD(target, "setHiddenValue", SetHiddenValue);
|
NODE_SET_METHOD(target, "setHiddenValue", SetHiddenValue);
|
||||||
|
|
|
@ -90,8 +90,6 @@ AtomBindings::~AtomBindings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBindings::BindTo(v8::Handle<v8::Object> process) {
|
void AtomBindings::BindTo(v8::Handle<v8::Object> process) {
|
||||||
v8::HandleScope handle_scope(node_isolate);
|
|
||||||
|
|
||||||
NODE_SET_METHOD(process, "atomBinding", Binding);
|
NODE_SET_METHOD(process, "atomBinding", Binding);
|
||||||
NODE_SET_METHOD(process, "crash", Crash);
|
NODE_SET_METHOD(process, "crash", Crash);
|
||||||
NODE_SET_METHOD(process, "activateUvLoop", ActivateUVLoop);
|
NODE_SET_METHOD(process, "activateUvLoop", ActivateUVLoop);
|
||||||
|
@ -170,8 +168,6 @@ void AtomBindings::Log(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
// static
|
// static
|
||||||
void AtomBindings::GetCurrentStackTrace(
|
void AtomBindings::GetCurrentStackTrace(
|
||||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope handle_scope(args.GetIsolate());
|
|
||||||
|
|
||||||
int stack_limit = kMaxCallStackSize;
|
int stack_limit = kMaxCallStackSize;
|
||||||
FromV8Arguments(args, &stack_limit);
|
FromV8Arguments(args, &stack_limit);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue