]> khamidou — GitHub mirrors - electron.git/commitdiff
Use new context aware module API in builtin modules.
authorCheng Zhao <zcbenz@gmail.com>
Sun, 29 Jun 2014 12:48:44 +0000 (20:48 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 29 Jun 2014 12:48:44 +0000 (20:48 +0800)
16 files changed:
atom/browser/api/atom_api_app.cc
atom/browser/api/atom_api_auto_updater.cc
atom/browser/api/atom_api_dialog.cc
atom/browser/api/atom_api_menu.cc
atom/browser/api/atom_api_power_monitor.cc
atom/browser/api/atom_api_protocol.cc
atom/browser/api/atom_api_tray.cc
atom/browser/api/atom_api_window.cc
atom/common/api/atom_api_clipboard.cc
atom/common/api/atom_api_crash_reporter.cc
atom/common/api/atom_api_id_weak_map.cc
atom/common/api/atom_api_screen.cc
atom/common/api/atom_api_shell.cc
atom/common/api/atom_api_v8_util.cc
atom/renderer/api/atom_api_renderer_ipc.cc
atom/renderer/api/atom_api_web_view.cc

index 0d06b392b859ad72354fcff682f113185a35146d..6ea5464d6f32fe86a72d8d77039df2221c36ad26 100644 (file)
@@ -109,8 +109,9 @@ int DockBounce(const std::string& type) {
 }
 #endif
 
-void Initialize(v8::Handle<v8::Object> exports) {
-  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
+  v8::Isolate* isolate = context->GetIsolate();
   Browser* browser = Browser::Get();
   CommandLine* command_line = CommandLine::ForCurrentProcess();
 
@@ -140,4 +141,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_browser_app, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_app, Initialize)
index 65842b21e986c7e78213a3bcfd8a0fd136ad2774..b76b1ef76290c1cae1abf8a3206ff541f3c6e067 100644 (file)
@@ -85,12 +85,13 @@ mate::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
-  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
+  v8::Isolate* isolate = context->GetIsolate();
   mate::Dictionary dict(isolate, exports);
   dict.Set("autoUpdater", atom::api::AutoUpdater::Create(isolate));
 }
 
 }  // namespace
 
-NODE_MODULE_X(atom_browser_auto_updater, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_auto_updater, Initialize)
index 217aab0c7900e94f2f71c79a159cdd722a9c3db9..ffc01603393650f2d59ff31c1376966602ab8ed6 100644 (file)
@@ -76,8 +76,9 @@ void ShowSaveDialog(const std::string& title,
   }
 }
 
-void Initialize(v8::Handle<v8::Object> exports) {
-  mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
+  mate::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("showMessageBox", &ShowMessageBox);
   dict.SetMethod("showOpenDialog", &ShowOpenDialog);
   dict.SetMethod("showSaveDialog", &ShowSaveDialog);
@@ -85,4 +86,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_browser_dialog, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_dialog, Initialize)
index 73464456d472654a1b9a951c6d03f4d877b6923c..a6d729254cbb59b91c5b8e27630222a231eb399d 100644 (file)
@@ -262,9 +262,10 @@ void Menu::BuildPrototype(v8::Isolate* isolate,
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
   using atom::api::Menu;
-  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Isolate* isolate = context->GetIsolate();
   v8::Local<v8::Function> constructor = mate::CreateConstructor<Menu>(
       isolate, "Menu", base::Bind(&Menu::Create));
   mate::Dictionary dict(isolate, exports);
@@ -278,4 +279,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_browser_menu, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_menu, Initialize)
index 4ceb2a168bd33e5b339bd2000a3b6fe64e16991d..ecfb3fdfc334a12c99683912bcf613a5e7f88566 100644 (file)
@@ -49,13 +49,14 @@ mate::Handle<PowerMonitor> PowerMonitor::Create(v8::Isolate* isolate) {
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
 #if defined(OS_MACOSX)
   base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
 #endif
 
   using atom::api::PowerMonitor;
-  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Isolate* isolate = context->GetIsolate();
   mate::Handle<PowerMonitor> power_monitor = PowerMonitor::Create(isolate);
   mate::Dictionary dict(isolate, exports);
   dict.Set("powerMonitor", power_monitor);
@@ -63,4 +64,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_browser_power_monitor, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_power_monitor, Initialize)
index 4eeca5ab9ceb776a3254509826a81148fa52d1e7..29ec8507c54232665f22690e3a0545441d420dc9 100644 (file)
@@ -322,16 +322,17 @@ mate::Handle<Protocol> Protocol::Create(v8::Isolate* isolate) {
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
   // Make sure the job factory has been created.
   atom::AtomBrowserContext::Get()->url_request_context_getter()->
       GetURLRequestContext();
 
-  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Isolate* isolate = context->GetIsolate();
   mate::Dictionary dict(isolate, exports);
   dict.Set("protocol", atom::api::Protocol::Create(isolate));
 }
 
 }  // namespace
 
-NODE_MODULE_X(atom_browser_protocol, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_protocol, Initialize)
index 32fa4ee62085db23ce6426f2905ec0a50ef2642c..86e6cb299532e388044bb0ec49379f0904a2af94 100644 (file)
@@ -69,9 +69,10 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
   using atom::api::Tray;
-  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Isolate* isolate = context->GetIsolate();
   v8::Handle<v8::Function> constructor = mate::CreateConstructor<Tray>(
       isolate, "Tray", base::Bind(&Tray::New));
   mate::Dictionary dict(isolate, exports);
@@ -80,4 +81,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_browser_tray, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_tray, Initialize)
index 1f87e549daa9663affea91a2df124e880d1bb6b9..278a929a814a95576b802e33804e5fa8ee1f9a80 100644 (file)
@@ -388,9 +388,10 @@ void Window::BuildPrototype(v8::Isolate* isolate,
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
   using atom::api::Window;
-  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Isolate* isolate = context->GetIsolate();
   v8::Local<v8::Function> constructor = mate::CreateConstructor<Window>(
       isolate, "BrowserWindow", base::Bind(&Window::New));
   mate::Dictionary dict(isolate, exports);
@@ -399,4 +400,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_browser_window, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_window, Initialize)
index 64e53a78cd26689ff8786b9289bf50a9d56013fa..e5cc30905b51659e2a1d9bc43f44078b6b39f985 100644 (file)
@@ -67,8 +67,9 @@ void Clear(ui::ClipboardType type) {
   ui::Clipboard::GetForCurrentThread()->Clear(type);
 }
 
-void Initialize(v8::Handle<v8::Object> exports) {
-  mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
+  mate::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("_has", &Has);
   dict.SetMethod("_read", &Read);
   dict.SetMethod("_readText", &ReadText);
@@ -78,4 +79,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_common_clipboard, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_clipboard, Initialize)
index 2bd5ce4342eb25aef2b591212bfb71fd7e12db7a..06ce7fadbab6f912c8baad39807dc94bcffc4434 100644 (file)
@@ -35,9 +35,10 @@ struct Converter<std::map<std::string, std::string> > {
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
   using crash_reporter::CrashReporter;
-  mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+  mate::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("start",
                  base::Bind(&CrashReporter::Start,
                             base::Unretained(CrashReporter::GetInstance())));
@@ -45,4 +46,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_common_crash_reporter, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_crash_reporter, Initialize)
index 3461f0e0b102523128971304cd8692f25351c143..652e8f75ccbcba925a7687778b1bb7f9e3fa6553 100644 (file)
@@ -91,10 +91,10 @@ void IDWeakMap::WeakCallback(
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
   using atom::api::IDWeakMap;
-
-  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+  v8::Isolate* isolate = context->GetIsolate();
   v8::Local<v8::Function> constructor = mate::CreateConstructor<IDWeakMap>(
       isolate,
       "IDWeakMap",
@@ -104,4 +104,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_common_id_weak_map, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_id_weak_map, Initialize)
index 547adc4a284b44880a29aed50e94365b3f849cd7..9f77863450e6419f4367010e72d497b02f54276b 100644 (file)
@@ -86,13 +86,14 @@ struct Converter<gfx::Display> {
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
 #if defined(TOOLKIT_GTK)
   gfx::GdkInitFromCommandLine(*CommandLine::ForCurrentProcess());
 #endif
 
   gfx::Screen* screen = gfx::Screen::GetNativeScreen();
-  mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+  mate::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("getCursorScreenPoint",
                  base::Bind(&gfx::Screen::GetCursorScreenPoint,
                             base::Unretained(screen)));
@@ -103,4 +104,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_common_screen, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_screen, Initialize)
index d88a0e4c8eed33be6301f8472920e4a03fbe2040..876e448240e48ee2d53b82c7a7dbfa36fad2e011 100644 (file)
@@ -13,8 +13,9 @@
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
-  mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
+  mate::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
   dict.SetMethod("openItem", &platform_util::OpenItem);
   dict.SetMethod("openExternal", &platform_util::OpenExternal);
@@ -24,4 +25,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_common_shell, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_shell, Initialize)
index f585df720e1c6220da8408607f94f977a83739e1..4332d029c22cb175ad4aed91e2bf76162cb49f8f 100644 (file)
@@ -43,8 +43,9 @@ void TakeHeapSnapshot(v8::Isolate* isolate) {
       mate::StringToV8(isolate, "test"));
 }
 
-void Initialize(v8::Handle<v8::Object> exports) {
-  mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
+  mate::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("createObjectWithName", &CreateObjectWithName);
   dict.SetMethod("getHiddenValue", &GetHiddenValue);
   dict.SetMethod("setHiddenValue", &SetHiddenValue);
@@ -55,4 +56,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
 
 }  // namespace
 
-NODE_MODULE_X(atom_common_v8_util, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_v8_util, Initialize)
index baf9ec606c3f7e8a196d6a3d5086838941bfa48a..678a0c7e1fc63c7f042c0123b6a381bd8b5f70af 100644 (file)
@@ -62,12 +62,13 @@ base::string16 SendSync(const base::string16& channel,
   return json;
 }
 
-void Initialize(v8::Handle<v8::Object> exports) {
-  mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
+  mate::Dictionary dict(context->GetIsolate(), exports);
   dict.SetMethod("send", &Send);
   dict.SetMethod("sendSync", &SendSync);
 }
 
 }  // namespace
 
-NODE_MODULE_X(atom_renderer_ipc, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_ipc, Initialize)
index 81ce35521c2dc06a512d466dafbc6f6dd1e21c90..1f983cdf96a8dbb16b1424d05a116d95409e0775 100644 (file)
@@ -69,12 +69,13 @@ mate::Handle<WebView> WebView::Create(v8::Isolate* isolate) {
 
 namespace {
 
-void Initialize(v8::Handle<v8::Object> exports) {
-  v8::Isolate* isolate = v8::Isolate::GetCurrent();
+void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
+                v8::Handle<v8::Context> context, void* priv) {
+  v8::Isolate* isolate = context->GetIsolate();
   mate::Dictionary dict(isolate, exports);
   dict.Set("webView", atom::api::WebView::Create(isolate));
 }
 
 }  // namespace
 
-NODE_MODULE_X(atom_renderer_web_view, Initialize, NULL, NM_F_BUILTIN)
+NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_web_view, Initialize)