]> khamidou — GitHub mirrors - electron.git/commitdiff
Remove unneeded HandleScopes.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 27 Jan 2014 06:26:28 +0000 (14:26 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 27 Jan 2014 07:01:06 +0000 (15:01 +0800)
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.

14 files changed:
browser/api/atom_api_app.cc
browser/api/atom_api_auto_updater.cc
browser/api/atom_api_dialog.cc
browser/api/atom_api_menu.cc
browser/api/atom_api_menu_mac.mm
browser/api/atom_api_menu_win.cc
browser/api/atom_api_power_monitor.cc
browser/api/atom_api_window.cc
common/api/atom_api_clipboard.cc
common/api/atom_api_id_weak_map.cc
common/api/atom_api_screen.cc
common/api/atom_api_shell.cc
common/api/atom_api_v8_util.cc
common/api/atom_bindings.cc

index 51661bb80778ed5d82a5665a69b9a1f505e7d393..f2b021c0d68532f235667d78bf38e5e795231da6 100644 (file)
@@ -174,8 +174,6 @@ void App::DockGetBadgeText(const v8::FunctionCallbackInfo<v8::Value>& args) {
 
 // static
 void App::Initialize(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
   v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
   t->InstanceTemplate()->SetInternalFieldCount(1);
   t->SetClassName(v8::String::NewSymbol("Application"));
index 9525cecd65ba1ab5a010c4d3ed00e73966683ec7..94618bd5f8f832674336cb0d036decf47f08ee46 100644 (file)
@@ -47,8 +47,6 @@ void AutoUpdater::ReadyForUpdateOnQuit(const std::string& version,
 
 // static
 void AutoUpdater::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
-  v8::HandleScope handle_scope(args.GetIsolate());
-
   if (!args.IsConstructCall())
     return node::ThrowError("Require constructor call");
 
@@ -102,8 +100,6 @@ void AutoUpdater::QuitAndInstall(
 
 // static
 void AutoUpdater::Initialize(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
   v8::Local<v8::FunctionTemplate> t(
       v8::FunctionTemplate::New(AutoUpdater::New));
   t->InstanceTemplate()->SetInternalFieldCount(1);
index f42eb1b6eefa277d3ab527e03f0f5fac0245fef6..b35f67af7682d96c2344515af5be8b791b8c0933 100644 (file)
@@ -34,8 +34,6 @@ void CallV8Function2(const RefCountedV8Function& callback, bool result, T arg) {
 }
 
 void Initialize(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
   NODE_SET_METHOD(target, "showMessageBox", ShowMessageBox);
   NODE_SET_METHOD(target, "showOpenDialog", ShowOpenDialog);
   NODE_SET_METHOD(target, "showSaveDialog", ShowSaveDialog);
index ffc9c5a26965ab2822fcc8529f87c5108dbae81f..c86a1ce727cafe60b36baf48a0c5c62cfcee0fe5 100644 (file)
@@ -121,8 +121,6 @@ void Menu::ExecuteCommand(int command_id, int event_flags) {
 
 // static
 void Menu::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
-  v8::HandleScope handle_scope(args.GetIsolate());
-
   if (!args.IsConstructCall())
     return node::ThrowError("Require constructor call");
 
@@ -307,8 +305,6 @@ void Menu::Popup(const v8::FunctionCallbackInfo<v8::Value>& args) {
 
 // static
 void Menu::Initialize(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
   v8::Local<v8::FunctionTemplate> t(v8::FunctionTemplate::New(Menu::New));
   t->InstanceTemplate()->SetInternalFieldCount(1);
   t->SetClassName(v8::String::NewSymbol("Menu"));
index 432ddb52e19f2158ad5bb0c56e23cd133619ce1e..12e2710604b58e6baf6df9e36ec1f8ef4d7d0025 100644 (file)
@@ -74,8 +74,6 @@ void MenuMac::SendActionToFirstResponder(const std::string& action) {
 
 // static
 void Menu::SetApplicationMenu(const v8::FunctionCallbackInfo<v8::Value>& args) {
-  v8::HandleScope handle_scope(args.GetIsolate());
-
   if (!args[0]->IsObject())
     return node::ThrowTypeError("Bad argument");
 
@@ -94,8 +92,6 @@ void Menu::SetApplicationMenu(const v8::FunctionCallbackInfo<v8::Value>& args) {
 // static
 void Menu::SendActionToFirstResponder(
     const v8::FunctionCallbackInfo<v8::Value>& args) {
-  v8::HandleScope handle_scope(args.GetIsolate());
-
   std::string action;
   if (!FromV8Arguments(args, &action))
     return node::ThrowTypeError("Bad argument");
index c5f5522367b9bb4c15a20c37e75bce42adc7e571..e645478ac2fc6f27e6eedc0c64e941952c797cfd 100644 (file)
@@ -31,8 +31,6 @@ void MenuWin::Popup(NativeWindow* native_window) {
 
 // static
 void Menu::AttachToWindow(const v8::FunctionCallbackInfo<v8::Value>& args) {
-  v8::HandleScope handle_scope(args.GetIsolate());
-
   Menu* self = ObjectWrap::Unwrap<Menu>(args.This());
   if (self == NULL)
     return node::ThrowError("Menu is already destroyed");
index df1ac1f27e230d3abc921a8a64fe5c918b07a3a9..1dd362bc6b26b8ff0a9dad768f7c90ef4c510cb9 100644 (file)
@@ -39,8 +39,6 @@ void PowerMonitor::OnResume() {
 
 // static
 void PowerMonitor::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
-  v8::HandleScope handle_scope(args.GetIsolate());
-
   if (!args.IsConstructCall())
     return node::ThrowError("Require constructor call");
 
@@ -49,8 +47,6 @@ void PowerMonitor::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
 
 // static
 void PowerMonitor::Initialize(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
 #if defined(OS_MACOSX)
   base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
 #endif
index 9718629dbef6b755d035dd7464696e955fbe653e..0052a28c6c7cb5c0bfb7b74bb83a965d2886e4e8 100644 (file)
@@ -103,8 +103,6 @@ void Window::OnCapturePageDone(const RefCountedV8Function& callback,
 
 // static
 void Window::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
-  v8::HandleScope handle_scope(args.GetIsolate());
-
   if (!args.IsConstructCall())
     return node::ThrowError("Require constructor call");
 
@@ -625,8 +623,6 @@ void Window::ReloadIgnoringCache(
 
 // static
 void Window::Initialize(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
   v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(Window::New);
   t->InstanceTemplate()->SetInternalFieldCount(1);
   t->SetClassName(v8::String::NewSymbol("BrowserWindow"));
index e83b1eb5494c60962eaccd8f20d384f9244c38d0..d0c97d350fc9359af3e383b1e7f46618b1dc08f8 100644 (file)
@@ -74,8 +74,6 @@ void Clipboard::Clear(const v8::FunctionCallbackInfo<v8::Value>& args) {
 
 // static
 void Clipboard::Initialize(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
   NODE_SET_METHOD(target, "has", Has);
   NODE_SET_METHOD(target, "read", Read);
   NODE_SET_METHOD(target, "readText", ReadText);
index 2ee2cf32913cf13a1930dd94f591a5adacf82969..09abbe9017b2866977e166f341d01329b3a0bcf0 100644 (file)
@@ -122,8 +122,6 @@ void IDWeakMap::Remove(const v8::FunctionCallbackInfo<v8::Value>& args) {
 
 // static
 void IDWeakMap::Initialize(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
   v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
   t->InstanceTemplate()->SetInternalFieldCount(1);
   t->SetClassName(v8::String::NewSymbol("IDWeakMap"));
index 574d70718a8f00cef0b34a5f27170d125c6cbaf6..85e1ff2a95f86a62759249d56e7b3471e79174f4 100644 (file)
@@ -67,8 +67,6 @@ void Screen::GetPrimaryDisplay(
 
 // static
 void Screen::Initialize(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
   v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
   t->InstanceTemplate()->SetInternalFieldCount(1);
   t->SetClassName(v8::String::NewSymbol("Screen"));
index 5f7f2d80c8432255e5f27bc57199374a6c03e38a..63a114b87f80a9b2e45edac9e342d59470bbc82b 100644 (file)
@@ -60,8 +60,6 @@ void Shell::Beep(const v8::FunctionCallbackInfo<v8::Value>& args) {
 
 // static
 void Shell::Initialize(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
   NODE_SET_METHOD(target, "showItemInFolder", ShowItemInFolder);
   NODE_SET_METHOD(target, "openItem", OpenItem);
   NODE_SET_METHOD(target, "openExternal", OpenExternal);
index 01d779c3b9843f7bf6dd97ffc78f53a971d05daa..1f3d250af6e21d3c3adea4d63cd338b1f7c63e7e 100644 (file)
@@ -46,8 +46,6 @@ void TakeHeapSnapshot(const v8::FunctionCallbackInfo<v8::Value>& args) {
 }  // namespace
 
 void InitializeV8Util(v8::Handle<v8::Object> target) {
-  v8::HandleScope handle_scope(node_isolate);
-
   NODE_SET_METHOD(target, "createObjectWithName", CreateObjectWithName);
   NODE_SET_METHOD(target, "getHiddenValue", GetHiddenValue);
   NODE_SET_METHOD(target, "setHiddenValue", SetHiddenValue);
index 3e58d8fe72facfc1e99654e6017454345a7340a1..faa139a6c6109c29fe0f72b99ba24b1247677469 100644 (file)
@@ -90,8 +90,6 @@ AtomBindings::~AtomBindings() {
 }
 
 void AtomBindings::BindTo(v8::Handle<v8::Object> process) {
-  v8::HandleScope handle_scope(node_isolate);
-
   NODE_SET_METHOD(process, "atomBinding", Binding);
   NODE_SET_METHOD(process, "crash", Crash);
   NODE_SET_METHOD(process, "activateUvLoop", ActivateUVLoop);
@@ -170,8 +168,6 @@ void AtomBindings::Log(const v8::FunctionCallbackInfo<v8::Value>& args) {
 // static
 void AtomBindings::GetCurrentStackTrace(
     const v8::FunctionCallbackInfo<v8::Value>& args) {
-  v8::HandleScope handle_scope(args.GetIsolate());
-
   int stack_limit = kMaxCallStackSize;
   FromV8Arguments(args, &stack_limit);