| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 return request_context->GetURLRequestContext(); | 195 return request_context->GetURLRequestContext(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 private: | 198 private: |
| 199 virtual ~RendererURLRequestContextSelector() {} | 199 virtual ~RendererURLRequestContextSelector() {} |
| 200 | 200 |
| 201 scoped_refptr<net::URLRequestContextGetter> request_context_; | 201 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 202 scoped_refptr<net::URLRequestContextGetter> media_request_context_; | 202 scoped_refptr<net::URLRequestContextGetter> media_request_context_; |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 size_t max_renderer_count_override = 0; | 205 // the global list of all renderer processes |
| 206 base::LazyInstance<IDMap<content::RenderProcessHost> >::Leaky |
| 207 g_all_hosts = LAZY_INSTANCE_INITIALIZER; |
| 206 | 208 |
| 207 size_t GetMaxRendererProcessCount() { | 209 } // namespace |
| 208 if (max_renderer_count_override) | 210 |
| 209 return max_renderer_count_override; | 211 // Stores the maximum number of renderer processes the content module can |
| 212 // create. |
| 213 static size_t g_max_renderer_count_override = 0; |
| 214 |
| 215 // static |
| 216 size_t content::RenderProcessHost::GetMaxRendererProcessCount() { |
| 217 if (g_max_renderer_count_override) |
| 218 return g_max_renderer_count_override; |
| 210 | 219 |
| 211 // Defines the maximum number of renderer processes according to the | 220 // Defines the maximum number of renderer processes according to the |
| 212 // amount of installed memory as reported by the OS. The table | 221 // amount of installed memory as reported by the OS. The table |
| 213 // values are calculated by assuming that you want the renderers to | 222 // values are calculated by assuming that you want the renderers to |
| 214 // use half of the installed ram and assuming that each tab uses | 223 // use half of the installed ram and assuming that each tab uses |
| 215 // ~40MB, however the curve is not linear but piecewise linear with | 224 // ~40MB, however the curve is not linear but piecewise linear with |
| 216 // interleaved slopes of 3 and 2. | 225 // interleaved slopes of 3 and 2. |
| 217 // If you modify this table you need to adjust browser\browser_uitest.cc | 226 // If you modify this table you need to adjust browser\browser_uitest.cc |
| 218 // to match the expected number of processes. | 227 // to match the expected number of processes. |
| 219 | 228 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 239 if (!max_count) { | 248 if (!max_count) { |
| 240 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; | 249 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; |
| 241 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) | 250 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) |
| 242 max_count = content::kMaxRendererProcessCount; | 251 max_count = content::kMaxRendererProcessCount; |
| 243 else | 252 else |
| 244 max_count = kMaxRenderersByRamTier[memory_tier]; | 253 max_count = kMaxRenderersByRamTier[memory_tier]; |
| 245 } | 254 } |
| 246 return max_count; | 255 return max_count; |
| 247 } | 256 } |
| 248 | 257 |
| 249 // the global list of all renderer processes | |
| 250 base::LazyInstance<IDMap<content::RenderProcessHost> >::Leaky | |
| 251 g_all_hosts = LAZY_INSTANCE_INITIALIZER; | |
| 252 | |
| 253 } // namespace | |
| 254 | |
| 255 // static | 258 // static |
| 256 bool g_run_renderer_in_process_ = false; | 259 bool g_run_renderer_in_process_ = false; |
| 257 | 260 |
| 258 // static | 261 // static |
| 259 void content::RenderProcessHost::SetMaxRendererProcessCountForTest( | 262 void content::RenderProcessHost::SetMaxRendererProcessCount(size_t count) { |
| 260 size_t count) { | 263 g_max_renderer_count_override = count; |
| 261 max_renderer_count_override = count; | |
| 262 } | 264 } |
| 263 | 265 |
| 264 RenderProcessHostImpl::RenderProcessHostImpl( | 266 RenderProcessHostImpl::RenderProcessHostImpl( |
| 265 content::BrowserContext* browser_context) | 267 content::BrowserContext* browser_context) |
| 266 : fast_shutdown_started_(false), | 268 : fast_shutdown_started_(false), |
| 267 deleting_soon_(false), | 269 deleting_soon_(false), |
| 268 pending_views_(0), | 270 pending_views_(0), |
| 269 visible_widgets_(0), | 271 visible_widgets_(0), |
| 270 backgrounded_(true), | 272 backgrounded_(true), |
| 271 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( | 273 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 // Only honor the request if appropriate persmissions are granted. | 1297 // Only honor the request if appropriate persmissions are granted. |
| 1296 if (ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(GetID(), | 1298 if (ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(GetID(), |
| 1297 path)) | 1299 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 } |
| OLD | NEW |