Commit 9bde960d authored by Alexander Semashko's avatar Alexander Semashko Committed by Commit Bot

Simplify render_process_host_chrome_browsertest.cc

This is a prerequisite for switching WindowedNotificationObserver to use
base::RunLoop instead of deprecated MessageLoopRunner. There were two
nested waits for the same notification which does not make sense and
does not work as is with the upcoming change.

This CL was split out from https://crrev.com/c/982612 and uploaded by
git cl split.

R=jochen@chromium.org

Bug: 668707
Change-Id: I217e5ea431d4a58b15ed1eef51a912142124c8b8
Reviewed-on: https://chromium-review.googlesource.com/1120488Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Commit-Queue: Alexander Semashko <ahest@yandex-team.ru>
Cr-Commit-Position: refs/heads/master@{#572171}
parent 37bb67e8
...@@ -527,21 +527,21 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ...@@ -527,21 +527,21 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest,
class WindowDestroyer : public content::WebContentsObserver { class WindowDestroyer : public content::WebContentsObserver {
public: public:
WindowDestroyer(content::WebContents* web_contents, TabStripModel* model) WindowDestroyer(content::WebContents* web_contents, TabStripModel* model)
: content::WebContentsObserver(web_contents), tab_strip_model_(model) {} : content::WebContentsObserver(web_contents),
tab_strip_model_(model),
browser_closed_observer_(chrome::NOTIFICATION_BROWSER_CLOSED,
content::NotificationService::AllSources()) {}
// Wait for the browser window to be destroyed.
void Wait() { browser_closed_observer_.Wait(); }
void RenderProcessGone(base::TerminationStatus status) override { void RenderProcessGone(base::TerminationStatus status) override {
// Wait for the window to be destroyed, which will ensure all other
// RenderViewHost objects are deleted before we return and proceed with
// the next iteration of notifications.
content::WindowedNotificationObserver observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::NotificationService::AllSources());
tab_strip_model_->CloseAllTabs(); tab_strip_model_->CloseAllTabs();
observer.Wait();
} }
private: private:
TabStripModel* tab_strip_model_; TabStripModel* tab_strip_model_;
content::WindowedNotificationObserver browser_closed_observer_;
DISALLOW_COPY_AND_ASSIGN(WindowDestroyer); DISALLOW_COPY_AND_ASSIGN(WindowDestroyer);
}; };
...@@ -575,16 +575,12 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ...@@ -575,16 +575,12 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest,
// Create an object that will close the window on a process crash. // Create an object that will close the window on a process crash.
WindowDestroyer destroyer(wc1, browser()->tab_strip_model()); WindowDestroyer destroyer(wc1, browser()->tab_strip_model());
content::WindowedNotificationObserver observer(
chrome::NOTIFICATION_BROWSER_CLOSED,
content::NotificationService::AllSources());
// Kill the renderer process, simulating a crash. This should the ProcessDied // Kill the renderer process, simulating a crash. This should the ProcessDied
// method to be called. Alternatively, RenderProcessHost::OnChannelError can // method to be called. Alternatively, RenderProcessHost::OnChannelError can
// be called to directly force a call to ProcessDied. // be called to directly force a call to ProcessDied.
wc1->GetMainFrame()->GetProcess()->Shutdown(-1); wc1->GetMainFrame()->GetProcess()->Shutdown(-1);
observer.Wait(); destroyer.Wait();
} }
// Sets up the browser in order to start the tests with two tabs open: one // Sets up the browser in order to start the tests with two tabs open: one
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment