| 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 "base/process/process.h" | 6 #include "base/process/process.h" |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/devtools/devtools_window.h" | 8 #include "chrome/browser/devtools/devtools_window.h" |
| 9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 EXPECT_EQ(host_count, RenderProcessHostCount()); | 212 EXPECT_EQ(host_count, RenderProcessHostCount()); |
| 213 EXPECT_NE(rph1, rph3); | 213 EXPECT_NE(rph1, rph3); |
| 214 EXPECT_NE(rph2, rph3); | 214 EXPECT_NE(rph2, rph3); |
| 215 } | 215 } |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 | 218 |
| 219 class ChromeRenderProcessHostTestWithCommandLine | 219 class ChromeRenderProcessHostTestWithCommandLine |
| 220 : public ChromeRenderProcessHostTest { | 220 : public ChromeRenderProcessHostTest { |
| 221 protected: | 221 protected: |
| 222 virtual void SetUpCommandLine(CommandLine* command_line) override { | 222 void SetUpCommandLine(CommandLine* command_line) override { |
| 223 command_line->AppendSwitchASCII(switches::kRendererProcessLimit, "1"); | 223 command_line->AppendSwitchASCII(switches::kRendererProcessLimit, "1"); |
| 224 } | 224 } |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ProcessPerTab) { | 227 IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ProcessPerTab) { |
| 228 // Set max renderers to 1 to force running out of processes. | 228 // Set max renderers to 1 to force running out of processes. |
| 229 content::RenderProcessHost::SetMaxRendererProcessCount(1); | 229 content::RenderProcessHost::SetMaxRendererProcessCount(1); |
| 230 | 230 |
| 231 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 231 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 232 parsed_command_line.AppendSwitch(switches::kProcessPerTab); | 232 parsed_command_line.AppendSwitch(switches::kProcessPerTab); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 // This class's goal is to close the browser window when a renderer process has | 455 // This class's goal is to close the browser window when a renderer process has |
| 456 // crashed. It does so by monitoring WebContents for RenderProcessGone event and | 456 // crashed. It does so by monitoring WebContents for RenderProcessGone event and |
| 457 // closing the passed in TabStripModel. This is used in the following test case. | 457 // closing the passed in TabStripModel. This is used in the following test case. |
| 458 class WindowDestroyer : public content::WebContentsObserver { | 458 class WindowDestroyer : public content::WebContentsObserver { |
| 459 public: | 459 public: |
| 460 WindowDestroyer(content::WebContents* web_contents, TabStripModel* model) | 460 WindowDestroyer(content::WebContents* web_contents, TabStripModel* model) |
| 461 : content::WebContentsObserver(web_contents), | 461 : content::WebContentsObserver(web_contents), |
| 462 tab_strip_model_(model) { | 462 tab_strip_model_(model) { |
| 463 } | 463 } |
| 464 | 464 |
| 465 virtual void RenderProcessGone(base::TerminationStatus status) override { | 465 void RenderProcessGone(base::TerminationStatus status) override { |
| 466 // Wait for the window to be destroyed, which will ensure all other | 466 // Wait for the window to be destroyed, which will ensure all other |
| 467 // RenderViewHost objects are deleted before we return and proceed with | 467 // RenderViewHost objects are deleted before we return and proceed with |
| 468 // the next iteration of notifications. | 468 // the next iteration of notifications. |
| 469 content::WindowedNotificationObserver observer( | 469 content::WindowedNotificationObserver observer( |
| 470 chrome::NOTIFICATION_BROWSER_CLOSED, | 470 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 471 content::NotificationService::AllSources()); | 471 content::NotificationService::AllSources()); |
| 472 tab_strip_model_->CloseAllTabs(); | 472 tab_strip_model_->CloseAllTabs(); |
| 473 observer.Wait(); | 473 observer.Wait(); |
| 474 } | 474 } |
| 475 | 475 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 chrome::NOTIFICATION_BROWSER_CLOSED, | 507 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 508 content::NotificationService::AllSources()); | 508 content::NotificationService::AllSources()); |
| 509 | 509 |
| 510 // Kill the renderer process, simulating a crash. This should the ProcessDied | 510 // Kill the renderer process, simulating a crash. This should the ProcessDied |
| 511 // method to be called. Alternatively, RenderProcessHost::OnChannelError can | 511 // method to be called. Alternatively, RenderProcessHost::OnChannelError can |
| 512 // be called to directly force a call to ProcessDied. | 512 // be called to directly force a call to ProcessDied. |
| 513 base::KillProcess(wc1->GetRenderProcessHost()->GetHandle(), -1, true); | 513 base::KillProcess(wc1->GetRenderProcessHost()->GetHandle(), -1, true); |
| 514 | 514 |
| 515 observer.Wait(); | 515 observer.Wait(); |
| 516 } | 516 } |
| OLD | NEW |