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

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: Addressed feedback by creis. 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
207 if (max_renderer_count_override) 209
208 return max_renderer_count_override; 210 // static
211 size_t content::RenderProcessHost::max_renderer_count_override_ = 0;
212
213 // static
214 size_t content::RenderProcessHost::GetMaxRendererProcessCount() {
215 if (max_renderer_count_override_)
216 return max_renderer_count_override_;
209 217
210 // Defines the maximum number of renderer processes according to the 218 // Defines the maximum number of renderer processes according to the
211 // amount of installed memory as reported by the OS. The table 219 // amount of installed memory as reported by the OS. The table
212 // values are calculated by assuming that you want the renderers to 220 // values are calculated by assuming that you want the renderers to
213 // use half of the installed ram and assuming that each tab uses 221 // use half of the installed ram and assuming that each tab uses
214 // ~40MB, however the curve is not linear but piecewise linear with 222 // ~40MB, however the curve is not linear but piecewise linear with
215 // interleaved slopes of 3 and 2. 223 // interleaved slopes of 3 and 2.
216 // If you modify this table you need to adjust browser\browser_uitest.cc 224 // If you modify this table you need to adjust browser\browser_uitest.cc
217 // to match the expected number of processes. 225 // to match the expected number of processes.
218 226
(...skipping 19 matching lines...) Expand all
238 if (!max_count) { 246 if (!max_count) {
239 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; 247 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256;
240 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) 248 if (memory_tier >= arraysize(kMaxRenderersByRamTier))
241 max_count = content::kMaxRendererProcessCount; 249 max_count = content::kMaxRendererProcessCount;
242 else 250 else
243 max_count = kMaxRenderersByRamTier[memory_tier]; 251 max_count = kMaxRenderersByRamTier[memory_tier];
244 } 252 }
245 return max_count; 253 return max_count;
246 } 254 }
247 255
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 256 // static
255 bool g_run_renderer_in_process_ = false; 257 bool g_run_renderer_in_process_ = false;
256 258
257 // static 259 // static
258 void content::RenderProcessHost::SetMaxRendererProcessCountForTest( 260 void content::RenderProcessHost::SetMaxRendererProcessCount(size_t count) {
259 size_t count) { 261 max_renderer_count_override_ = count;
260 max_renderer_count_override = count;
261 } 262 }
262 263
263 RenderProcessHostImpl::RenderProcessHostImpl( 264 RenderProcessHostImpl::RenderProcessHostImpl(
264 content::BrowserContext* browser_context) 265 content::BrowserContext* browser_context)
265 : fast_shutdown_started_(false), 266 : fast_shutdown_started_(false),
266 deleting_soon_(false), 267 deleting_soon_(false),
267 pending_views_(0), 268 pending_views_(0),
268 visible_widgets_(0), 269 visible_widgets_(0),
269 backgrounded_(true), 270 backgrounded_(true),
270 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( 271 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_(
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { 1296 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) {
1296 // Only honor the request if appropriate persmissions are granted. 1297 // Only honor the request if appropriate persmissions are granted.
1297 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path)) 1298 if (ChildProcessSecurityPolicy::GetInstance()->CanReadFile(GetID(), path))
1298 content::GetContentClient()->browser()->OpenItem(path); 1299 content::GetContentClient()->browser()->OpenItem(path);
1299 } 1300 }
1300 1301
1301 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { 1302 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) {
1302 content::GetContentClient()->browser()->GetMHTMLGenerationManager()-> 1303 content::GetContentClient()->browser()->GetMHTMLGenerationManager()->
1303 MHTMLGenerated(job_id, data_size); 1304 MHTMLGenerated(job_id, data_size);
1304 } 1305 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698