Fix crash due to site_instace being freed early

This commit is contained in:
Cheng Zhao 2016-05-23 12:57:46 +09:00
parent 899cdb48d7
commit 530f19e956

View file

@ -52,6 +52,9 @@ bool g_suppress_renderer_process_restart = false;
// Custom schemes to be registered to handle service worker.
std::string g_custom_service_worker_schemes = "";
void Noop(scoped_refptr<content::SiteInstance>) {
}
} // namespace
// static
@ -133,6 +136,13 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
content::SiteInstance::CreateForURL(browser_context, url);
*new_instance = site_instance.get();
// Make sure the |site_instance| is not freed when this function returns.
// FIXME(zcbenz): We should adjust OverrideSiteInstanceForNavigation's
// interface to solve this.
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&Noop, base::RetainedRef(site_instance)));
// Remember the original renderer process of the pending renderer process.
auto current_process = current_instance->GetProcess();
auto pending_process = (*new_instance)->GetProcess();