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

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.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: Removed the static variable from the interface and moved the test function. 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) 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 // Represents the browser side of the browser <--> renderer communication 5 // Represents the browser side of the browser <--> renderer communication
6 // channel. There will be one RenderProcessHost per renderer process. 6 // channel. There will be one RenderProcessHost per renderer process.
7 7
8 #include "content/browser/renderer_host/render_process_host_impl.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 9
10 #if defined(OS_WIN) 10 #if defined(OS_WIN)
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return request_context->GetURLRequestContext(); 194 return request_context->GetURLRequestContext();
195 } 195 }
196 196
197 private: 197 private:
198 virtual ~RendererURLRequestContextSelector() {} 198 virtual ~RendererURLRequestContextSelector() {}
199 199
200 scoped_refptr<net::URLRequestContextGetter> request_context_; 200 scoped_refptr<net::URLRequestContextGetter> request_context_;
201 scoped_refptr<net::URLRequestContextGetter> media_request_context_; 201 scoped_refptr<net::URLRequestContextGetter> media_request_context_;
202 }; 202 };
203 203
204 size_t max_renderer_count_override = 0; 204 // the global list of all renderer processes
205 base::LazyInstance<IDMap<content::RenderProcessHost> >::Leaky
206 g_all_hosts = LAZY_INSTANCE_INITIALIZER;
205 207
206 size_t GetMaxRendererProcessCount() { 208 } // namespace
209
210 // Stores the maximum number of renderer processes the content module can
211 // create.
212 static size_t max_renderer_count_override = 0;
jam 2012/02/10 18:02:12 nit: globals should be "g_max_renderer_count_overr
nasko 2012/02/11 00:49:20 Done.
213
214 // static
215 size_t content::RenderProcessHost::GetMaxRendererProcessCount() {
207 if (max_renderer_count_override) 216 if (max_renderer_count_override)
208 return max_renderer_count_override; 217 return max_renderer_count_override;
209 218
210 // Defines the maximum number of renderer processes according to the 219 // Defines the maximum number of renderer processes according to the
211 // amount of installed memory as reported by the OS. The table 220 // amount of installed memory as reported by the OS. The table
212 // values are calculated by assuming that you want the renderers to 221 // values are calculated by assuming that you want the renderers to
213 // use half of the installed ram and assuming that each tab uses 222 // use half of the installed ram and assuming that each tab uses
214 // ~40MB, however the curve is not linear but piecewise linear with 223 // ~40MB, however the curve is not linear but piecewise linear with
215 // interleaved slopes of 3 and 2. 224 // interleaved slopes of 3 and 2.
216 // If you modify this table you need to adjust browser\browser_uitest.cc 225 // If you modify this table you need to adjust browser\browser_uitest.cc
(...skipping 21 matching lines...) Expand all
238 if (!max_count) { 247 if (!max_count) {
239 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; 248 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256;
240 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) 249 if (memory_tier >= arraysize(kMaxRenderersByRamTier))
241 max_count = content::kMaxRendererProcessCount; 250 max_count = content::kMaxRendererProcessCount;
242 else 251 else
243 max_count = kMaxRenderersByRamTier[memory_tier]; 252 max_count = kMaxRenderersByRamTier[memory_tier];
244 } 253 }
245 return max_count; 254 return max_count;
246 } 255 }
247 256
248 // the global list of all renderer processes
249 base::LazyInstance<IDMap<content::RenderProcessHost> >::Leaky
250 g_all_hosts = LAZY_INSTANCE_INITIALIZER;
251
252 } // namespace
253
254 // static 257 // static
255 bool g_run_renderer_in_process_ = false; 258 bool g_run_renderer_in_process_ = false;
256 259
257 // static 260 // static
258 void content::RenderProcessHost::SetMaxRendererProcessCountForTest( 261 void content::RenderProcessHost::SetMaxRendererProcessCount(size_t count) {
259 size_t count) {
260 max_renderer_count_override = count; 262 max_renderer_count_override = count;
261 } 263 }
262 264
263 RenderProcessHostImpl::RenderProcessHostImpl( 265 RenderProcessHostImpl::RenderProcessHostImpl(
264 content::BrowserContext* browser_context) 266 content::BrowserContext* browser_context)
265 : fast_shutdown_started_(false), 267 : fast_shutdown_started_(false),
266 deleting_soon_(false), 268 deleting_soon_(false),
267 pending_views_(0), 269 pending_views_(0),
268 visible_widgets_(0), 270 visible_widgets_(0),
269 backgrounded_(true), 271 backgrounded_(true),
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { 1297 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) {
1296 // Only honor the request if appropriate persmissions are granted. 1298 // Only honor the request if appropriate persmissions are granted.
1297 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path)) 1299 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path))
1298 content::GetContentClient()->browser()->OpenItem(path); 1300 content::GetContentClient()->browser()->OpenItem(path);
1299 } 1301 }
1300 1302
1301 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { 1303 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) {
1302 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> 1304 content::GetContentClient()->browser()->GetMHTMLGenerationManager()->
1303 MHTMLGenerated(job_id, data_size); 1305 MHTMLGenerated(job_id, data_size);
1304 } 1306 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_browsertest.cc ('k') | content/public/browser/render_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698