diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 5320db277577..dbd44a40dc74 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -687,17 +687,25 @@ void App::BrowserChildProcessHostDisconnected( ChildProcessDisconnected(base::GetProcId(data.handle)); } +void App::BrowserChildProcessCrashed(const content::ChildProcessData& data, + int exit_code) { + ChildProcessDisconnected(base::GetProcId(data.handle)); +} + +void App::BrowserChildProcessKilled(const content::ChildProcessData& data, + int exit_code) { + ChildProcessDisconnected(base::GetProcId(data.handle)); +} + void App::RenderProcessReady(content::RenderProcessHost* host) { ChildProcessLaunched(content::PROCESS_TYPE_RENDERER, host->GetHandle()); } -void App::RenderProcessDisconnected(content::RenderProcessHost* host) { - ChildProcessDisconnected(base::GetProcId(host->GetHandle())); +void App::RenderProcessDisconnected(base::ProcessId host_pid) { + ChildProcessDisconnected(host_pid); } -void App::ChildProcessLaunched( - int process_type, - base::ProcessHandle handle) { +void App::ChildProcessLaunched(int process_type, base::ProcessHandle handle) { auto pid = base::GetProcId(handle); #if defined(OS_MACOSX) diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index 16fd25a148bb..353eba6883c1 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -5,6 +5,7 @@ #ifndef ATOM_BROWSER_API_ATOM_API_APP_H_ #define ATOM_BROWSER_API_ATOM_API_APP_H_ +#include #include #include #include @@ -92,7 +93,7 @@ class App : public AtomBrowserClient::Delegate, base::FilePath GetAppPath() const; void RenderProcessReady(content::RenderProcessHost* host); - void RenderProcessDisconnected(content::RenderProcessHost* host); + void RenderProcessDisconnected(base::ProcessId host_pid); protected: explicit App(v8::Isolate* isolate); @@ -143,6 +144,10 @@ class App : public AtomBrowserClient::Delegate, const content::ChildProcessData& data) override; void BrowserChildProcessHostDisconnected( const content::ChildProcessData& data) override; + void BrowserChildProcessCrashed( + const content::ChildProcessData& data, int exit_code) override; + void BrowserChildProcessKilled( + const content::ChildProcessData& data, int exit_code) override; private: void SetAppPath(const base::FilePath& app_path); diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index a49c1f7e6169..be4ee262adf1 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -408,15 +408,26 @@ void AtomBrowserClient::RenderProcessHostDestroyed( } } RemoveProcessPreferences(process_id); - if (delegate_) { - static_cast(delegate_)->RenderProcessDisconnected(host); - } } void AtomBrowserClient::RenderProcessReady(content::RenderProcessHost* host) { + render_process_host_pids_[host->GetID()] = base::GetProcId(host->GetHandle()); if (delegate_) { static_cast(delegate_)->RenderProcessReady(host); } } +void AtomBrowserClient::RenderProcessExited(content::RenderProcessHost* host, + base::TerminationStatus status, + int exit_code) { + auto host_pid = render_process_host_pids_.find(host->GetID()); + if (host_pid != render_process_host_pids_.end()) { + if (delegate_) { + static_cast(delegate_)->RenderProcessDisconnected( + host_pid->second); + } + render_process_host_pids_.erase(host_pid); + } +} + } // namespace atom diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index ad18885d29a1..69ac51c66310 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -110,6 +110,9 @@ class AtomBrowserClient : public brightray::BrowserClient, // content::RenderProcessHostObserver: void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; void RenderProcessReady(content::RenderProcessHost* host) override; + void RenderProcessExited(content::RenderProcessHost* host, + base::TerminationStatus status, + int exit_code) override; private: bool ShouldCreateNewSiteInstance(content::RenderFrameHost* render_frame_host, @@ -129,6 +132,7 @@ class AtomBrowserClient : public brightray::BrowserClient, std::map pending_processes_; std::map process_preferences_; + std::map render_process_host_pids_; base::Lock process_preferences_lock_; std::unique_ptr