From b527846ee41abeb35d5f30d10340be10b47ff179 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 26 Apr 2015 12:28:27 +0800 Subject: [PATCH] Use our new way to restart renderer process As a side effect, it will also restart the renderer process of webview tag guests. --- atom/browser/atom_browser_client.cc | 24 ++++++++++++------------ atom/browser/atom_browser_client.h | 9 +++++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 2a246f2..df32284 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -119,22 +119,22 @@ void AtomBrowserClient::OverrideWebkitPrefs( window->OverrideWebkitPrefs(prefs); } -bool AtomBrowserClient::ShouldSwapBrowsingInstancesForNavigation( - content::SiteInstance* site_instance, - const GURL& current_url, - const GURL& new_url) { - if (site_instance->HasProcess()) - dying_render_process_ = site_instance->GetProcess(); - - // Restart renderer process for all navigations, this relies on a patch to - // Chromium: http://git.io/_PaNyg. - return true; -} - std::string AtomBrowserClient::GetApplicationLocale() { return l10n_util::GetApplicationLocale(""); } +void AtomBrowserClient::OverrideSiteInstanceForNavigation( + content::BrowserContext* browser_context, + content::SiteInstance* current_instance, + const GURL& url, + content::SiteInstance** new_instance) { + if (current_instance->HasProcess()) + dying_render_process_ = current_instance->GetProcess(); + + // Restart renderer process for all navigations. + *new_instance = content::SiteInstance::CreateForURL(browser_context, url); +} + void AtomBrowserClient::AppendExtraCommandLineSwitches( base::CommandLine* command_line, int child_process_id) { diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index 828b3f7..629ac96 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -27,11 +27,12 @@ class AtomBrowserClient : public brightray::BrowserClient { void ResourceDispatcherHostCreated() override; void OverrideWebkitPrefs(content::RenderViewHost* render_view_host, content::WebPreferences* prefs) override; - bool ShouldSwapBrowsingInstancesForNavigation( - content::SiteInstance* site_instance, - const GURL& current_url, - const GURL& new_url) override; std::string GetApplicationLocale() override; + void OverrideSiteInstanceForNavigation( + content::BrowserContext* browser_context, + content::SiteInstance* current_instance, + const GURL& dest_url, + content::SiteInstance** new_instance); void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) override; -- 2.7.4