From 8ffad4ed0b910af30b2404fdfd26e44fa73c50c0 Mon Sep 17 00:00:00 2001 From: "avi@chromium.org" Date: Thu, 2 Jan 2014 23:18:26 +0000 Subject: Introduce RenderProcessHostObserver::RenderProcessExited, use it in a new RenderProcessHostWatcher, and switch browser tests over to that new watcher. BUG=170921 TEST=no change Review URL: https://codereview.chromium.org/121493002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242832 0039d316-1c4b-4281-b951-d872f2087c98 --- .../frame_host/render_frame_host_manager_browsertest.cc | 17 ++++++----------- .../loader/resource_dispatcher_host_browsertest.cc | 8 +++----- .../browser/renderer_host/render_process_host_impl.cc | 3 +++ content/browser/security_exploit_browsertest.cc | 8 +++----- 4 files changed, 15 insertions(+), 21 deletions(-) (limited to 'content/browser') diff --git a/content/browser/frame_host/render_frame_host_manager_browsertest.cc b/content/browser/frame_host/render_frame_host_manager_browsertest.cc index 576e138..23fec72 100644 --- a/content/browser/frame_host/render_frame_host_manager_browsertest.cc +++ b/content/browser/frame_host/render_frame_host_manager_browsertest.cc @@ -15,10 +15,6 @@ #include "content/common/content_constants_internal.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" -#include "content/public/browser/notification_types.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" @@ -713,9 +709,8 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, // 2) Post a message containing a MessagePort from opener to the the foo // window. The foo window will reply via the passed port, causing the opener // to update its own title. - WindowedNotificationObserver title_observer( - NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, - Source(opener_contents)); + base::string16 expected_title = ASCIIToUTF16("msg-back-via-port"); + TitleWatcher title_observer(opener_contents, expected_title); EXPECT_TRUE(ExecuteScriptAndExtractBool( opener_contents, "window.domAutomationController.send(postWithPortToFoo());", @@ -723,7 +718,7 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, EXPECT_TRUE(success); ASSERT_FALSE( opener_manager->GetSwappedOutRenderViewHost(orig_site_instance.get())); - title_observer.Wait(); + ASSERT_EQ(expected_title, title_observer.WaitAndGetTitle()); // Check message counts. int opener_received_messages_via_port = 0; @@ -874,9 +869,9 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, // Navigate the first window to a different site as well. The original // process should exit, since all of its views are now swapped out. - WindowedNotificationObserver exit_observer( - NOTIFICATION_RENDERER_PROCESS_TERMINATED, - Source(orig_process)); + RenderProcessHostWatcher exit_observer( + orig_process, + RenderProcessHostWatcher::WATCH_FOR_HOST_DESTRUCTION); NavigateToURL(shell(), https_server.GetURL("files/title1.html")); exit_observer.Wait(); scoped_refptr new_site_instance2( diff --git a/content/browser/loader/resource_dispatcher_host_browsertest.cc b/content/browser/loader/resource_dispatcher_host_browsertest.cc index 23a0cca..a2af83b 100644 --- a/content/browser/loader/resource_dispatcher_host_browsertest.cc +++ b/content/browser/loader/resource_dispatcher_host_browsertest.cc @@ -9,8 +9,6 @@ #include "content/browser/web_contents/web_contents_impl.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_types.h" #include "content/public/browser/web_contents.h" #include "content/public/common/url_constants.h" #include "content/public/test/browser_test_utils.h" @@ -304,9 +302,9 @@ IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, // strip the app on the build bots, this is bad times. IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, CrossSiteAfterCrash) { // Cause the renderer to crash. - WindowedNotificationObserver crash_observer( - NOTIFICATION_RENDERER_PROCESS_CLOSED, - NotificationService::AllSources()); + RenderProcessHostWatcher crash_observer( + shell()->web_contents(), + RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); NavigateToURL(shell(), GURL(kChromeUICrashURL)); // Wait for browser to notice the renderer crash. crash_observer.Wait(); diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index c841640..9812a04 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -1821,6 +1821,9 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead) { NOTIFICATION_RENDERER_PROCESS_CLOSED, Source(this), Details(&details)); + FOR_EACH_OBSERVER(RenderProcessHostObserver, + observers_, + RenderProcessExited(this, GetHandle(), status, exit_code)); child_process_launcher_.reset(); channel_.reset(); diff --git a/content/browser/security_exploit_browsertest.cc b/content/browser/security_exploit_browsertest.cc index fc648f0..62241ac 100644 --- a/content/browser/security_exploit_browsertest.cc +++ b/content/browser/security_exploit_browsertest.cc @@ -11,8 +11,6 @@ #include "content/browser/web_contents/web_contents_impl.h" #include "content/common/view_messages.h" #include "content/public/browser/browser_context.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_types.h" #include "content/public/browser/storage_partition.h" #include "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" @@ -107,9 +105,9 @@ IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, SetWebUIProperty) { EXPECT_EQ(0, shell()->web_contents()->GetRenderViewHost()->GetEnabledBindings()); - content::WindowedNotificationObserver terminated( - content::NOTIFICATION_RENDERER_PROCESS_CLOSED, - content::NotificationService::AllSources()); + content::RenderProcessHostWatcher terminated( + shell()->web_contents(), + content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); shell()->web_contents()->GetRenderViewHost()->SetWebUIProperty( "toolkit", "views"); terminated.Wait(); -- cgit v1.1