| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
| 7 #include "chrome/browser/devtools/devtools_window.h" | 7 #include "chrome/browser/devtools/devtools_window.h" |
| 8 #include "chrome/browser/search/search.h" | 8 #include "chrome/browser/search/search.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 EXPECT_EQ(host_count, RenderProcessHostCount()); | 195 EXPECT_EQ(host_count, RenderProcessHostCount()); |
| 196 EXPECT_NE(rph1, rph3); | 196 EXPECT_NE(rph1, rph3); |
| 197 EXPECT_NE(rph2, rph3); | 197 EXPECT_NE(rph2, rph3); |
| 198 } | 198 } |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 | 201 |
| 202 class ChromeRenderProcessHostTestWithCommandLine | 202 class ChromeRenderProcessHostTestWithCommandLine |
| 203 : public ChromeRenderProcessHostTest { | 203 : public ChromeRenderProcessHostTest { |
| 204 protected: | 204 protected: |
| 205 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 205 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 206 command_line->AppendSwitchASCII(switches::kRendererProcessLimit, "1"); | 206 command_line->AppendSwitchASCII(switches::kRendererProcessLimit, "1"); |
| 207 } | 207 } |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ProcessPerTab) { | 210 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ProcessPerTab) { |
| 211 // Set max renderers to 1 to force running out of processes. | 211 // Set max renderers to 1 to force running out of processes. |
| 212 content::RenderProcessHost::SetMaxRendererProcessCount(1); | 212 content::RenderProcessHost::SetMaxRendererProcessCount(1); |
| 213 | 213 |
| 214 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 214 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 215 parsed_command_line.AppendSwitch(switches::kProcessPerTab); | 215 parsed_command_line.AppendSwitch(switches::kProcessPerTab); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // This class's goal is to close the browser window when a renderer process has | 435 // This class's goal is to close the browser window when a renderer process has |
| 436 // crashed. It does so by monitoring WebContents for RenderProcessGone event and | 436 // crashed. It does so by monitoring WebContents for RenderProcessGone event and |
| 437 // closing the passed in TabStripModel. This is used in the following test case. | 437 // closing the passed in TabStripModel. This is used in the following test case. |
| 438 class WindowDestroyer : public content::WebContentsObserver { | 438 class WindowDestroyer : public content::WebContentsObserver { |
| 439 public: | 439 public: |
| 440 WindowDestroyer(content::WebContents* web_contents, TabStripModel* model) | 440 WindowDestroyer(content::WebContents* web_contents, TabStripModel* model) |
| 441 : content::WebContentsObserver(web_contents), | 441 : content::WebContentsObserver(web_contents), |
| 442 tab_strip_model_(model) { | 442 tab_strip_model_(model) { |
| 443 } | 443 } |
| 444 | 444 |
| 445 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE { | 445 virtual void RenderProcessGone(base::TerminationStatus status) override { |
| 446 // Wait for the window to be destroyed, which will ensure all other | 446 // Wait for the window to be destroyed, which will ensure all other |
| 447 // RenderViewHost objects are deleted before we return and proceed with | 447 // RenderViewHost objects are deleted before we return and proceed with |
| 448 // the next iteration of notifications. | 448 // the next iteration of notifications. |
| 449 content::WindowedNotificationObserver observer( | 449 content::WindowedNotificationObserver observer( |
| 450 chrome::NOTIFICATION_BROWSER_CLOSED, | 450 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 451 content::NotificationService::AllSources()); | 451 content::NotificationService::AllSources()); |
| 452 tab_strip_model_->CloseAllTabs(); | 452 tab_strip_model_->CloseAllTabs(); |
| 453 observer.Wait(); | 453 observer.Wait(); |
| 454 } | 454 } |
| 455 | 455 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 chrome::NOTIFICATION_BROWSER_CLOSED, | 487 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 488 content::NotificationService::AllSources()); | 488 content::NotificationService::AllSources()); |
| 489 | 489 |
| 490 // Kill the renderer process, simulating a crash. This should the ProcessDied | 490 // Kill the renderer process, simulating a crash. This should the ProcessDied |
| 491 // method to be called. Alternatively, RenderProcessHost::OnChannelError can | 491 // method to be called. Alternatively, RenderProcessHost::OnChannelError can |
| 492 // be called to directly force a call to ProcessDied. | 492 // be called to directly force a call to ProcessDied. |
| 493 base::KillProcess(wc1->GetRenderProcessHost()->GetHandle(), -1, true); | 493 base::KillProcess(wc1->GetRenderProcessHost()->GetHandle(), -1, true); |
| 494 | 494 |
| 495 observer.Wait(); | 495 observer.Wait(); |
| 496 } | 496 } |
| OLD | NEW |