diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 420878664d22..48a1e6a020de 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -12,6 +12,7 @@ #include "atom/browser/atom_browser_main_parts.h" #include "atom/browser/native_window.h" #include "atom/common/api/api_messages.h" +#include "atom/common/event_emitter_caller.h" #include "atom/common/native_mate_converters/gfx_converter.h" #include "atom/common/native_mate_converters/gurl_converter.h" #include "atom/common/native_mate_converters/image_converter.h" @@ -249,7 +250,17 @@ void WebContents::ExitFullscreenModeForTab(content::WebContents* source) { } void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) { - Emit("render-view-deleted", render_view_host->GetProcess()->GetID()); + int process_id = render_view_host->GetProcess()->GetID(); + Emit("render-view-deleted", process_id); + + // process.emit('ATOM_BROWSER_RELEASE_RENDER_VIEW', processId); + // Tell the rpc server that a render view has been deleted and we need to + // release all objects owned by it. + v8::Locker locker(isolate()); + v8::HandleScope handle_scope(isolate()); + node::Environment* env = node::Environment::GetCurrent(isolate()); + mate::EmitEvent(isolate(), env->process_object(), + "ATOM_BROWSER_RELEASE_RENDER_VIEW", process_id); } void WebContents::RenderProcessGone(base::TerminationStatus status) { diff --git a/atom/browser/api/lib/web-contents.coffee b/atom/browser/api/lib/web-contents.coffee index b635ab2a5f26..35c11dfe4be1 100644 --- a/atom/browser/api/lib/web-contents.coffee +++ b/atom/browser/api/lib/web-contents.coffee @@ -30,11 +30,6 @@ wrapWebContents = (webContents) -> do (name, method) -> webContents[name] = -> method.apply controller, arguments - # Tell the rpc server that a render view has been deleted and we need to - # release all objects owned by it. - webContents.on 'render-view-deleted', (event, processId) -> - process.emit 'ATOM_BROWSER_RELEASE_RENDER_VIEW', processId - # Dispatch IPC messages to the ipc module. webContents.on 'ipc-message', (event, packed) -> [channel, args...] = packed