From 8bdf06131bd43be3cb0c3c2eec4bf8ca6682d8d5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 4 Jul 2013 19:47:48 +0800 Subject: [PATCH] Separate the creation function of NodeBindings for renderer and browser. On Windows the message loop integration would need two different implementations. --- browser/atom_browser_main_parts.cc | 2 +- common/node_bindings.h | 3 ++- common/node_bindings_mac.mm | 9 +++++++-- renderer/atom_renderer_client.cc | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/browser/atom_browser_main_parts.cc b/browser/atom_browser_main_parts.cc index 31fe68f34d5b..a23cf36e65c0 100644 --- a/browser/atom_browser_main_parts.cc +++ b/browser/atom_browser_main_parts.cc @@ -20,7 +20,7 @@ AtomBrowserMainParts* AtomBrowserMainParts::self_ = NULL; AtomBrowserMainParts::AtomBrowserMainParts() : atom_bindings_(new AtomBrowserBindings), browser_(new Browser), - node_bindings_(NodeBindings::Create(true)) { + node_bindings_(NodeBindings::CreateInBrowser()) { DCHECK(!self_) << "Cannot have two AtomBrowserMainParts"; self_ = this; } diff --git a/common/node_bindings.h b/common/node_bindings.h index 4f4edec1725d..887979c39135 100644 --- a/common/node_bindings.h +++ b/common/node_bindings.h @@ -15,7 +15,8 @@ namespace atom { class NodeBindings { public: - static NodeBindings* Create(bool is_browser); + static NodeBindings* CreateInBrowser(); + static NodeBindings* CreateInRenderer(); virtual ~NodeBindings(); diff --git a/common/node_bindings_mac.mm b/common/node_bindings_mac.mm index 0c15387ced23..f7a7585f48ee 100644 --- a/common/node_bindings_mac.mm +++ b/common/node_bindings_mac.mm @@ -123,8 +123,13 @@ void NodeBindingsMac::OnWatcherQueueChanged(uv_loop_t* loop) { } // static -NodeBindings* NodeBindings::Create(bool is_browser) { - return new NodeBindingsMac(is_browser); +NodeBindings* NodeBindings::CreateInBrowser() { + return new NodeBindingsMac(true); +} + +// static +NodeBindings* NodeBindings::CreateInRenderer() { + return new NodeBindingsMac(false); } } // namespace atom diff --git a/renderer/atom_renderer_client.cc b/renderer/atom_renderer_client.cc index 36cb4052532d..a22f8a8f3dbf 100644 --- a/renderer/atom_renderer_client.cc +++ b/renderer/atom_renderer_client.cc @@ -23,7 +23,7 @@ v8::Handle GetNodeContext() { } // namespace AtomRendererClient::AtomRendererClient() - : node_bindings_(NodeBindings::Create(false)) { + : node_bindings_(NodeBindings::CreateInRenderer()) { } AtomRendererClient::~AtomRendererClient() {