From 83f01096c017de42a3b7c9c6de6f4bd3f530d81a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 9 Mar 2018 16:13:51 +0900 Subject: [PATCH] When a render process is crashed, it might be reused --- atom/browser/atom_browser_client.cc | 9 +++++++++ atom/browser/atom_browser_client.h | 1 + 2 files changed, 10 insertions(+) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 69fd274f6e80..42892025b04d 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -140,6 +140,11 @@ void AtomBrowserClient::RemoveProcessPreferences(int process_id) { process_preferences_.erase(process_id); } +bool AtomBrowserClient::IsProcessObserved(int process_id) { + base::AutoLock auto_lock(process_preferences_lock_); + return process_preferences_.find(process_id) != process_preferences_.end(); +} + bool AtomBrowserClient::IsRendererSandboxed(int process_id) { base::AutoLock auto_lock(process_preferences_lock_); auto it = process_preferences_.find(process_id); @@ -160,7 +165,11 @@ bool AtomBrowserClient::RendererDisablesPopups(int process_id) { void AtomBrowserClient::RenderProcessWillLaunch( content::RenderProcessHost* host) { + // When a render process is crashed, it might be reused. int process_id = host->GetID(); + if (IsProcessObserved(process_id)) + return; + host->AddFilter(new printing::PrintingMessageFilter(process_id)); host->AddFilter(new TtsMessageFilter(process_id, host->GetBrowserContext())); host->AddFilter( diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index 54ade8170a73..14633370ff00 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -126,6 +126,7 @@ class AtomBrowserClient : public brightray::BrowserClient, }; void AddProcessPreferences(int process_id, ProcessPreferences prefs); void RemoveProcessPreferences(int process_id); + bool IsProcessObserved(int process_id); bool IsRendererSandboxed(int process_id); bool RendererUsesNativeWindowOpen(int process_id); bool RendererDisablesPopups(int process_id);