Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: content/browser/renderer_host/render_process_host_browsertest.cc

Issue 9328011: Adding a command line flag to specify renderer process limit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/renderer_host/render_process_host_browsertest.h" 5 #include "content/browser/renderer_host/render_process_host_browsertest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/process.h" 10 #include "base/process.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 content::BrowserThread::PostTaskAndReply( 50 content::BrowserThread::PostTaskAndReply(
51 content::BrowserThread::PROCESS_LAUNCHER, FROM_HERE, 51 content::BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
52 base::Bind(&base::DoNothing), MessageLoop::QuitClosure()); 52 base::Bind(&base::DoNothing), MessageLoop::QuitClosure());
53 MessageLoop::current()->Run(); 53 MessageLoop::current()->Run();
54 54
55 return wc->GetRenderProcessHost()->GetHandle(); 55 return wc->GetRenderProcessHost()->GetHandle();
56 } 56 }
57 57
58 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) { 58 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) {
59 // Set max renderers to 1 to force running out of processes. 59 // Set max renderers to 1 to force running out of processes.
60 content::RenderProcessHost::SetMaxRendererProcessCountForTest(1); 60 content::RenderProcessHost::SetMaxRendererProcessCount(1);
61 61
62 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); 62 CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
63 parsed_command_line.AppendSwitch(switches::kProcessPerTab); 63 parsed_command_line.AppendSwitch(switches::kProcessPerTab);
64 64
65 int tab_count = 1; 65 int tab_count = 1;
66 int host_count = 1; 66 int host_count = 1;
67 67
68 #if defined(USE_VIRTUAL_KEYBOARD) 68 #if defined(USE_VIRTUAL_KEYBOARD)
69 ++host_count; // For the virtual keyboard. 69 ++host_count; // For the virtual keyboard.
70 #endif 70 #endif
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 EXPECT_TRUE(base::Process(pid2).IsProcessBackgrounded()); 146 EXPECT_TRUE(base::Process(pid2).IsProcessBackgrounded());
147 } 147 }
148 #endif 148 #endif
149 149
150 // When we hit the max number of renderers, verify that the way we do process 150 // When we hit the max number of renderers, verify that the way we do process
151 // sharing behaves correctly. In particular, this test is verifying that even 151 // sharing behaves correctly. In particular, this test is verifying that even
152 // when we hit the max process limit, that renderers of each type will wind up 152 // when we hit the max process limit, that renderers of each type will wind up
153 // in a process of that type, even if that means creating a new process. 153 // in a process of that type, even if that means creating a new process.
154 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessOverflow) { 154 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessOverflow) {
155 // Set max renderers to 1 to force running out of processes. 155 // Set max renderers to 1 to force running out of processes.
156 content::RenderProcessHost::SetMaxRendererProcessCountForTest(1); 156 content::RenderProcessHost::SetMaxRendererProcessCount(1);
157 157
158 int tab_count = 1; 158 int tab_count = 1;
159 int host_count = 1; 159 int host_count = 1;
160 WebContents* tab1 = NULL; 160 WebContents* tab1 = NULL;
161 WebContents* tab2 = NULL; 161 WebContents* tab2 = NULL;
162 content::RenderProcessHost* rph1 = NULL; 162 content::RenderProcessHost* rph1 = NULL;
163 content::RenderProcessHost* rph2 = NULL; 163 content::RenderProcessHost* rph2 = NULL;
164 content::RenderProcessHost* rph3 = NULL; 164 content::RenderProcessHost* rph3 = NULL;
165 165
166 #if defined(USE_VIRTUAL_KEYBOARD) 166 #if defined(USE_VIRTUAL_KEYBOARD)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 host_count++; 230 host_count++;
231 #endif 231 #endif
232 EXPECT_EQ(tab_count, browser()->tab_count()); 232 EXPECT_EQ(tab_count, browser()->tab_count());
233 tab1 = browser()->GetWebContentsAt(tab_count - 1); 233 tab1 = browser()->GetWebContentsAt(tab_count - 1);
234 rph3 = tab1->GetRenderProcessHost(); 234 rph3 = tab1->GetRenderProcessHost();
235 EXPECT_EQ(tab1->GetURL(), bookmarks); 235 EXPECT_EQ(tab1->GetURL(), bookmarks);
236 EXPECT_EQ(host_count, RenderProcessHostCount()); 236 EXPECT_EQ(host_count, RenderProcessHostCount());
237 EXPECT_NE(rph1, rph3); 237 EXPECT_NE(rph1, rph3);
238 EXPECT_NE(rph2, rph3); 238 EXPECT_NE(rph2, rph3);
239 } 239 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698