diff options
24 files changed, 69 insertions, 60 deletions
diff --git a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc index 072aa4d..9a40df8 100644 --- a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc +++ b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc @@ -76,8 +76,8 @@ class ExtensionCrashRecoveryTestBase : public ExtensionBrowserTest { GetBackgroundHostForExtension(extension_id); ASSERT_TRUE(extension_host); - base::KillProcess(extension_host->render_process_host()->GetHandle(), - content::RESULT_CODE_KILLED, false); + extension_host->render_process_host()->Shutdown(content::RESULT_CODE_KILLED, + false); ASSERT_TRUE(WaitForExtensionCrash(extension_id)); ASSERT_FALSE(GetProcessManager()-> GetBackgroundHostForExtension(extension_id)); diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc index a626e16..aa34d26 100644 --- a/chrome/browser/extensions/window_open_apitest.cc +++ b/chrome/browser/extensions/window_open_apitest.cc @@ -401,8 +401,8 @@ IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, ClosePanelsOnExtensionCrash) { extensions::ProcessManager::Get(browser()->profile()) ->GetBackgroundHostForExtension(extension->id()); ASSERT_TRUE(extension_host); - base::KillProcess(extension_host->render_process_host()->GetHandle(), - content::RESULT_CODE_KILLED, false); + extension_host->render_process_host()->Shutdown(content::RESULT_CODE_KILLED, + false); WaitForExtensionCrash(extension->id()); // Only expect panels to close. The rest stay open to show a sad-tab. diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index 4b77848..1d98935 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc @@ -1832,8 +1832,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallForcelist) { extensions::ExtensionHost* extension_host = extensions::ProcessManager::Get(browser()->profile()) ->GetBackgroundHostForExtension(kGoodCrxId); - base::KillProcess(extension_host->render_process_host()->GetHandle(), - content::RESULT_CODE_KILLED, false); + extension_host->render_process_host()->Shutdown(content::RESULT_CODE_KILLED, + false); extension_crashed_observer.Wait(); extension_loaded_observer.Wait(); } diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc index c5e3ac6..3bf775af 100644 --- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc +++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc @@ -510,7 +510,7 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, // Kill the renderer process, simulating a crash. This should the ProcessDied // method to be called. Alternatively, RenderProcessHost::OnChannelError can // be called to directly force a call to ProcessDied. - base::KillProcess(wc1->GetRenderProcessHost()->GetHandle(), -1, true); + wc1->GetRenderProcessHost()->Shutdown(-1, true); observer.Wait(); } diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index 9e2905e..6a08508 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -546,7 +546,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsDialogs) { content::RenderProcessHostWatcher crash_observer( child_process, content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); - base::KillProcess(child_process->GetHandle(), 0, false); + child_process->Shutdown(0, false); crash_observer.Wait(); EXPECT_FALSE(dialog_queue->HasActiveDialog()); @@ -573,7 +573,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsSubframeDialogs) { content::RenderProcessHostWatcher crash_observer( child_process, content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); - base::KillProcess(child_process->GetHandle(), 0, false); + child_process->Shutdown(0, false); crash_observer.Wait(); EXPECT_FALSE(dialog_queue->HasActiveDialog()); diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc index bbbc9f4..aa09929 100644 --- a/chrome/browser/ui/views/hung_renderer_view.cc +++ b/chrome/browser/ui/views/hung_renderer_view.cc @@ -196,12 +196,12 @@ bool HungRendererDialogView::IsFrameActive(WebContents* contents) { // static void HungRendererDialogView::KillRendererProcess( - base::ProcessHandle process_handle) { + content::RenderProcessHost* rph) { #if defined(OS_WIN) // Try to generate a crash report for the hung process. - CrashDumpAndTerminateHungChildProcess(process_handle); + CrashDumpAndTerminateHungChildProcess(rph->GetHandle()); #else - base::KillProcess(process_handle, content::RESULT_CODE_HUNG, false); + rph->Shutdown(content::RESULT_CODE_HUNG, false); #endif } @@ -342,10 +342,7 @@ void HungRendererDialogView::ButtonPressed( views::Button* sender, const ui::Event& event) { if (sender == kill_button_ && hung_pages_table_model_->GetRenderProcessHost()) { - base::ProcessHandle process_handle = - hung_pages_table_model_->GetRenderProcessHost()->GetHandle(); - - KillRendererProcess(process_handle); + KillRendererProcess(hung_pages_table_model_->GetRenderProcessHost()); } } diff --git a/chrome/browser/ui/views/hung_renderer_view.h b/chrome/browser/ui/views/hung_renderer_view.h index 37264b1..27a0f66 100644 --- a/chrome/browser/ui/views/hung_renderer_view.h +++ b/chrome/browser/ui/views/hung_renderer_view.h @@ -105,8 +105,8 @@ class HungRendererDialogView : public views::DialogDelegateView, static HungRendererDialogView* GetInstance(); // Platform specific function to kill the renderer process identified by the - // handle passed in. - static void KillRendererProcess(base::ProcessHandle process_handle); + // render process host passed in. + static void KillRendererProcess(content::RenderProcessHost* rph); // Returns true if the frame is in the foreground. static bool IsFrameActive(content::WebContents* contents); diff --git a/chrome/browser/ui/zoom/zoom_controller_browsertest.cc b/chrome/browser/ui/zoom/zoom_controller_browsertest.cc index 4d0ffd5..73e0690 100644 --- a/chrome/browser/ui/zoom/zoom_controller_browsertest.cc +++ b/chrome/browser/ui/zoom/zoom_controller_browsertest.cc @@ -89,7 +89,7 @@ IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, { content::RenderProcessHostWatcher crash_observer( host, content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); - base::KillProcess(host->GetHandle(), 0, false); + host->Shutdown(0, false); crash_observer.Wait(); } EXPECT_FALSE(web_contents->GetRenderViewHost()->IsRenderViewLive()); diff --git a/content/browser/child_process_security_policy_browsertest.cc b/content/browser/child_process_security_policy_browsertest.cc index b509a49..c1e3c39 100644 --- a/content/browser/child_process_security_policy_browsertest.cc +++ b/content/browser/child_process_security_policy_browsertest.cc @@ -48,8 +48,7 @@ IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, NoLeak) { 1U); WebContents* web_contents = shell()->web_contents(); - base::KillProcess(web_contents->GetRenderProcessHost()->GetHandle(), - RESULT_CODE_KILLED, true); + web_contents->GetRenderProcessHost()->Shutdown(RESULT_CODE_KILLED, true); web_contents->GetController().Reload(true); EXPECT_EQ( diff --git a/content/browser/indexed_db/indexed_db_browsertest.cc b/content/browser/indexed_db/indexed_db_browsertest.cc index 871d9f5..1080ad4 100644 --- a/content/browser/indexed_db/indexed_db_browsertest.cc +++ b/content/browser/indexed_db/indexed_db_browsertest.cc @@ -686,8 +686,7 @@ IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ConnectionsClosedOnTabClose) { base::string16 expected_title16(ASCIIToUTF16("setVersion(3) complete")); TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); - base::KillProcess( - shell()->web_contents()->GetRenderProcessHost()->GetHandle(), 0, true); + shell()->web_contents()->GetRenderProcessHost()->Shutdown(0, true); shell()->Close(); EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); diff --git a/content/browser/manifest/manifest_manager_host.cc b/content/browser/manifest/manifest_manager_host.cc index 50b3eca..d32a8c34 100644 --- a/content/browser/manifest/manifest_manager_host.cc +++ b/content/browser/manifest/manifest_manager_host.cc @@ -19,7 +19,8 @@ void KillRenderer(RenderFrameHost* render_frame_host) { render_frame_host->GetProcess()->GetHandle(); if (process_handle == base::kNullProcessHandle) return; - base::KillProcess(process_handle, RESULT_CODE_KILLED_BAD_MESSAGE, false); + render_frame_host->GetProcess()->Shutdown(RESULT_CODE_KILLED_BAD_MESSAGE, + false); } } // anonymous namespace diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index ba59c98..c812ec0 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -152,6 +152,7 @@ #include "ui/native_theme/native_theme_switches.h" #if defined(OS_ANDROID) +#include "content/browser/android/child_process_launcher_android.h" #include "content/browser/media/android/browser_demuxer_android.h" #include "content/browser/screen_orientation/screen_orientation_message_filter_android.h" #endif @@ -974,8 +975,7 @@ void RenderProcessHostImpl::ReceivedBadMessage() { } // We kill the renderer but don't include a NOTREACHED, because we want the // browser to try to survive when it gets illegal messages from the renderer. - base::KillProcess(GetHandle(), RESULT_CODE_KILLED_BAD_MESSAGE, - false); + Shutdown(RESULT_CODE_KILLED_BAD_MESSAGE, false); } void RenderProcessHostImpl::WidgetRestored() { @@ -1331,9 +1331,22 @@ base::ProcessHandle RenderProcessHostImpl::GetHandle() const { return child_process_launcher_->GetProcess().Handle(); } +bool RenderProcessHostImpl::Shutdown(int exit_code, bool wait) { + if (run_renderer_in_process()) + return false; // Single process mode never shuts down the renderer. + +#if defined(OS_ANDROID) + // Android requires a different approach for killing. + StopChildProcess(GetHandle()); + return true; +#else + return base::KillProcess(GetHandle(), exit_code, wait); +#endif +} + bool RenderProcessHostImpl::FastShutdownIfPossible() { if (run_renderer_in_process()) - return false; // Single process mode never shutdown the renderer. + return false; // Single process mode never shuts down the renderer. if (!GetContentClient()->browser()->IsFastShutdownPossible()) return false; diff --git a/content/browser/renderer_host/render_process_host_impl.h b/content/browser/renderer_host/render_process_host_impl.h index b4e77d4..9175a2c 100644 --- a/content/browser/renderer_host/render_process_host_impl.h +++ b/content/browser/renderer_host/render_process_host_impl.h @@ -104,6 +104,7 @@ class CONTENT_EXPORT RenderProcessHostImpl int VisibleWidgetCount() const override; bool IsIsolatedGuest() const override; StoragePartition* GetStoragePartition() const override; + bool Shutdown(int exit_code, bool wait) override; bool FastShutdownIfPossible() override; void DumpHandles() override; base::ProcessHandle GetHandle() const override; diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 37a0353..e31cde9 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -752,8 +752,7 @@ void RenderViewHostImpl::SetWebUIProperty(const std::string& name, } else { RecordAction( base::UserMetricsAction("BindingsMismatchTerminate_RVH_WebUI")); - base::KillProcess( - GetProcess()->GetHandle(), content::RESULT_CODE_KILLED, false); + GetProcess()->Shutdown(content::RESULT_CODE_KILLED, false); } } diff --git a/content/browser/security_exploit_browsertest.cc b/content/browser/security_exploit_browsertest.cc index 68430ad..be65a56 100644 --- a/content/browser/security_exploit_browsertest.cc +++ b/content/browser/security_exploit_browsertest.cc @@ -110,17 +110,9 @@ class SecurityExploitBrowserTest : public ContentBrowserTest { } }; -// Fails because the process kill on Android does not succeed. -// http://crbug.com/433068 -#if defined(OS_ANDROID) -#define MAYBE_SetWebUIProperty DISABLED_SetWebUIProperty -#else -#define MAYBE_SetWebUIProperty SetWebUIProperty -#endif - // Ensure that we kill the renderer process if we try to give it WebUI // properties and it doesn't have enabled WebUI bindings. -IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, MAYBE_SetWebUIProperty) { +IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, SetWebUIProperty) { GURL foo("http://foo.com/simple_page.html"); NavigateToURL(shell(), foo); diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc index 145a249..c96fd86 100644 --- a/content/browser/site_per_process_browsertest.cc +++ b/content/browser/site_per_process_browsertest.cc @@ -387,7 +387,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_CrashSubframe) { RenderProcessHostWatcher crash_observer( child_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); - base::KillProcess(child_process->GetHandle(), 0, false); + child_process->Shutdown(0, false); crash_observer.Wait(); } @@ -406,7 +406,7 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_CrashSubframe) { RenderProcessHostWatcher crash_observer( root_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); - base::KillProcess(root_process->GetHandle(), 0, false); + root_process->Shutdown(0, false); crash_observer.Wait(); } EXPECT_EQ(0U, root->child_count()); diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 4a738e6..64679cd 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -1472,12 +1472,12 @@ void WebContentsImpl::CreateNewWindow( // this WebContentsImpl instance. If any other process sends the request, // it is invalid and the process must be terminated. if (GetRenderProcessHost()->GetID() != render_process_id) { - base::ProcessHandle process_handle = - RenderProcessHost::FromID(render_process_id)->GetHandle(); + RenderProcessHost* rph = RenderProcessHost::FromID(render_process_id); + base::ProcessHandle process_handle = rph->GetHandle(); if (process_handle != base::kNullProcessHandle) { RecordAction( base::UserMetricsAction("Terminate_ProcessMismatch_CreateNewWindow")); - base::KillProcess(process_handle, RESULT_CODE_KILLED, false); + rph->Shutdown(RESULT_CODE_KILLED, false); } return; } @@ -1606,12 +1606,12 @@ void WebContentsImpl::CreateNewWidget(int render_process_id, // this WebContentsImpl instance. If any other process sends the request, // it is invalid and the process must be terminated. if (process->GetID() != render_process_id) { - base::ProcessHandle process_handle = - RenderProcessHost::FromID(render_process_id)->GetHandle(); + RenderProcessHost* rph = RenderProcessHost::FromID(render_process_id); + base::ProcessHandle process_handle = rph->GetHandle(); if (process_handle != base::kNullProcessHandle) { RecordAction( base::UserMetricsAction("Terminate_ProcessMismatch_CreateNewWidget")); - base::KillProcess(process_handle, RESULT_CODE_KILLED, false); + rph->Shutdown(RESULT_CODE_KILLED, false); } return; } diff --git a/content/public/browser/render_process_host.h b/content/public/browser/render_process_host.h index dcec7d8..c612995 100644 --- a/content/public/browser/render_process_host.h +++ b/content/public/browser/render_process_host.h @@ -99,10 +99,16 @@ class CONTENT_EXPORT RenderProcessHost : public IPC::Sender, // http://crbug.com/158595 virtual StoragePartition* GetStoragePartition() const = 0; - // Try to shutdown the associated renderer process as fast as possible. + // Try to shut down the associated renderer process without running unload + // handlers, etc, giving it the specified exit code. If |wait| is true, wait + // for the process to be actually terminated before returning. + // Returns true if it was able to shut down. + virtual bool Shutdown(int exit_code, bool wait) = 0; + + // Try to shut down the associated renderer process as fast as possible. // If this renderer has any RenderViews with unload handlers, then this - // function does nothing. The current implementation uses TerminateProcess. - // Returns True if it was able to do fast shutdown. + // function does nothing. + // Returns true if it was able to do fast shutdown. virtual bool FastShutdownIfPossible() = 0; // Returns true if fast shutdown was started for the renderer. diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc index b7fd7ba..a1949d3 100644 --- a/content/public/test/browser_test_utils.cc +++ b/content/public/test/browser_test_utils.cc @@ -299,7 +299,7 @@ void CrashTab(WebContents* web_contents) { RenderProcessHost* rph = web_contents->GetRenderProcessHost(); RenderProcessHostWatcher watcher( rph, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); - base::KillProcess(rph->GetHandle(), 0, false); + rph->Shutdown(0, false); watcher.Wait(); } diff --git a/content/public/test/mock_render_process_host.cc b/content/public/test/mock_render_process_host.cc index d98f6e8..014998f 100644 --- a/content/public/test/mock_render_process_host.cc +++ b/content/public/test/mock_render_process_host.cc @@ -107,6 +107,10 @@ StoragePartition* MockRenderProcessHost::GetStoragePartition() const { void MockRenderProcessHost::AddWord(const base::string16& word) { } +bool MockRenderProcessHost::Shutdown(int exit_code, bool wait) { + return true; +} + bool MockRenderProcessHost::FastShutdownIfPossible() { // We aren't actually going to do anything, but set |fast_shutdown_started_| // to true so that tests know we've been called. diff --git a/content/public/test/mock_render_process_host.h b/content/public/test/mock_render_process_host.h index 81df686..4e2cf8e 100644 --- a/content/public/test/mock_render_process_host.h +++ b/content/public/test/mock_render_process_host.h @@ -47,6 +47,7 @@ class MockRenderProcessHost : public RenderProcessHost { bool IsIsolatedGuest() const override; StoragePartition* GetStoragePartition() const override; virtual void AddWord(const base::string16& word); + bool Shutdown(int exit_code, bool wait) override; bool FastShutdownIfPossible() override; bool FastShutdownStarted() const override; void DumpHandles() override; diff --git a/extensions/browser/guest_view/extension_options/extension_options_guest.cc b/extensions/browser/guest_view/extension_options/extension_options_guest.cc index 038d8ed..07c4e2b 100644 --- a/extensions/browser/guest_view/extension_options/extension_options_guest.cc +++ b/extensions/browser/guest_view/extension_options/extension_options_guest.cc @@ -240,8 +240,7 @@ void ExtensionOptionsGuest::DidNavigateMainFrame( const content::FrameNavigateParams& params) { if (attached() && (params.url.GetOrigin() != options_page_.GetOrigin())) { base::RecordAction(base::UserMetricsAction("BadMessageTerminate_EOG")); - base::KillProcess( - web_contents()->GetRenderProcessHost()->GetHandle(), + web_contents()->GetRenderProcessHost()->Shutdown( content::RESULT_CODE_KILLED_BAD_MESSAGE, false /* wait */); } } diff --git a/extensions/browser/guest_view/guest_view_manager.cc b/extensions/browser/guest_view/guest_view_manager.cc index 80efe79..17198bd 100644 --- a/extensions/browser/guest_view/guest_view_manager.cc +++ b/extensions/browser/guest_view/guest_view_manager.cc @@ -288,10 +288,8 @@ bool GuestViewManager::CanEmbedderAccessInstanceIDMaybeKill( // The embedder process is trying to access a guest it does not own. content::RecordAction( base::UserMetricsAction("BadMessageTerminate_BPGM")); - base::KillProcess( - content::RenderProcessHost::FromID(embedder_render_process_id)-> - GetHandle(), - content::RESULT_CODE_KILLED_BAD_MESSAGE, false); + content::RenderProcessHost::FromID(embedder_render_process_id) + ->Shutdown(content::RESULT_CODE_KILLED_BAD_MESSAGE, false); return false; } return true; diff --git a/extensions/browser/guest_view/web_view/web_view_guest.cc b/extensions/browser/guest_view/web_view/web_view_guest.cc index 1296760..453a7fd 100644 --- a/extensions/browser/guest_view/web_view/web_view_guest.cc +++ b/extensions/browser/guest_view/web_view/web_view_guest.cc @@ -242,9 +242,8 @@ void WebViewGuest::CreateWebContents( if (!base::IsStringUTF8(storage_partition_id)) { content::RecordAction( base::UserMetricsAction("BadMessageTerminate_BPGM")); - base::KillProcess( - owner_render_process_host->GetHandle(), - content::RESULT_CODE_KILLED_BAD_MESSAGE, false); + owner_render_process_host->Shutdown(content::RESULT_CODE_KILLED_BAD_MESSAGE, + false); callback.Run(NULL); return; } @@ -672,7 +671,8 @@ void WebViewGuest::Terminate() { base::ProcessHandle process_handle = web_contents()->GetRenderProcessHost()->GetHandle(); if (process_handle) - base::KillProcess(process_handle, content::RESULT_CODE_KILLED, false); + web_contents()->GetRenderProcessHost()->Shutdown( + content::RESULT_CODE_KILLED, false); } bool WebViewGuest::ClearData(const base::Time remove_since, |