From 085b1a45ee3412626b7bfb848f9bd9e51eae0d42 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 6 Dec 2013 15:53:40 +0800 Subject: [PATCH] Report the right render view that is deleted. --- browser/api/atom_api_window.cc | 7 +++++-- browser/api/atom_api_window.h | 2 +- browser/api/lib/browser-window.coffee | 4 ++-- browser/native_window.cc | 11 ++++++++--- browser/native_window_observer.h | 2 +- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/browser/api/atom_api_window.cc b/browser/api/atom_api_window.cc index 1002aa8..ddc5d5c 100644 --- a/browser/api/atom_api_window.cc +++ b/browser/api/atom_api_window.cc @@ -76,8 +76,11 @@ void Window::OnRendererResponsive() { Emit("responsive"); } -void Window::OnRenderViewDeleted() { - Emit("render-view-deleted"); +void Window::OnRenderViewDeleted(int process_id, int routing_id) { + base::ListValue args; + args.AppendInteger(process_id); + args.AppendInteger(routing_id); + Emit("render-view-deleted", &args); } void Window::OnRendererCrashed() { diff --git a/browser/api/atom_api_window.h b/browser/api/atom_api_window.h index 334e8f5..92c4702 100644 --- a/browser/api/atom_api_window.h +++ b/browser/api/atom_api_window.h @@ -43,7 +43,7 @@ class Window : public EventEmitter, virtual void OnWindowBlur() OVERRIDE; virtual void OnRendererUnresponsive() OVERRIDE; virtual void OnRendererResponsive() OVERRIDE; - virtual void OnRenderViewDeleted() OVERRIDE; + virtual void OnRenderViewDeleted(int process_id, int routing_id) OVERRIDE; virtual void OnRendererCrashed() OVERRIDE; private: diff --git a/browser/api/lib/browser-window.coffee b/browser/api/lib/browser-window.coffee index b95c2e7..3d1e818 100644 --- a/browser/api/lib/browser-window.coffee +++ b/browser/api/lib/browser-window.coffee @@ -13,8 +13,8 @@ BrowserWindow::_init = -> # Tell the rpc server that a render view has been deleted and we need to # release all objects owned by it. - @on 'render-view-deleted', -> - process.emit 'ATOM_BROWSER_RELEASE_RENDER_VIEW', @getProcessId(), @getRoutingId() + @on 'render-view-deleted', (event, processId, routingId) -> + process.emit 'ATOM_BROWSER_RELEASE_RENDER_VIEW', processId, routingId BrowserWindow::toggleDevTools = -> if @isDevToolsOpened() then @closeDevTools() else @openDevTools() diff --git a/browser/native_window.cc b/browser/native_window.cc index 7a2353e..b85ca5c 100644 --- a/browser/native_window.cc +++ b/browser/native_window.cc @@ -271,7 +271,10 @@ void NativeWindow::NotifyWindowClosed() { // The OnRenderViewDeleted is not called when the WebContents is destroyed // directly (e.g. when closing the window), so we make sure it's always // emitted to users by sending it before window is closed.. - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRenderViewDeleted()); + FOR_EACH_OBSERVER(NativeWindowObserver, observers_, + OnRenderViewDeleted( + GetWebContents()->GetRenderProcessHost()->GetID(), + GetWebContents()->GetRoutingID())); is_closed_ = true; FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowClosed()); @@ -398,8 +401,10 @@ bool NativeWindow::OnMessageReceived(const IPC::Message& message) { return handled; } -void NativeWindow::RenderViewDeleted(content::RenderViewHost*) { - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRenderViewDeleted()); +void NativeWindow::RenderViewDeleted(content::RenderViewHost* rvh) { + FOR_EACH_OBSERVER(NativeWindowObserver, observers_, + OnRenderViewDeleted(rvh->GetProcess()->GetID(), + rvh->GetRoutingID())); } void NativeWindow::RenderViewGone(base::TerminationStatus status) { diff --git a/browser/native_window_observer.h b/browser/native_window_observer.h index 20b8ddc..5d69748 100644 --- a/browser/native_window_observer.h +++ b/browser/native_window_observer.h @@ -36,7 +36,7 @@ class NativeWindowObserver { virtual void OnRendererResponsive() {} // Called when a render view has been deleted. - virtual void OnRenderViewDeleted() {} + virtual void OnRenderViewDeleted(int process_id, int routing_id) {} // Called when renderer has crashed. virtual void OnRendererCrashed() {} -- 2.7.4