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