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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 static size_t g_max_renderer_count_override = 0; | 223 static size_t g_max_renderer_count_override = 0; |
224 | 224 |
225 // static | 225 // static |
226 size_t content::RenderProcessHost::GetMaxRendererProcessCount() { | 226 size_t content::RenderProcessHost::GetMaxRendererProcessCount() { |
227 if (g_max_renderer_count_override) | 227 if (g_max_renderer_count_override) |
228 return g_max_renderer_count_override; | 228 return g_max_renderer_count_override; |
229 | 229 |
230 // Defines the maximum number of renderer processes according to the | 230 // Defines the maximum number of renderer processes according to the |
231 // amount of installed memory as reported by the OS. The calculation | 231 // amount of installed memory as reported by the OS. The calculation |
232 // assumes that you want the renderers to use half of the installed | 232 // assumes that you want the renderers to use half of the installed |
233 // RAM and assuming that each tab uses ~40MB. | 233 // RAM and assuming that each WebContents uses ~40MB. |
234 // If you modify this assumption, you need to adjust the | 234 // If you modify this assumption, you need to adjust the |
235 // ThirtyFourTabs test to match the expected number of processes. | 235 // ThirtyFourTabs test to match the expected number of processes. |
236 // | 236 // |
237 // With the given amounts of installed memory below on a 32-bit CPU, | 237 // With the given amounts of installed memory below on a 32-bit CPU, |
238 // the maximum renderer count will roughly be as follows: | 238 // the maximum renderer count will roughly be as follows: |
239 // | 239 // |
240 // 128 MB -> 3 | 240 // 128 MB -> 3 |
241 // 512 MB -> 6 | 241 // 512 MB -> 6 |
242 // 1024 MB -> 12 | 242 // 1024 MB -> 12 |
243 // 4096 MB -> 51 | 243 // 4096 MB -> 51 |
244 // 16384 MB -> 82 (kMaxRendererProcessCount) | 244 // 16384 MB -> 82 (kMaxRendererProcessCount) |
245 | 245 |
246 static size_t max_count = 0; | 246 static size_t max_count = 0; |
247 if (!max_count) { | 247 if (!max_count) { |
248 const size_t kEstimatedTabMemoryUsage = | 248 const size_t kEstimatedWebContentsMemoryUsage = |
249 #if defined(ARCH_CPU_64_BITS) | 249 #if defined(ARCH_CPU_64_BITS) |
250 60; // In MB | 250 60; // In MB |
251 #else | 251 #else |
252 40; // In MB | 252 40; // In MB |
253 #endif | 253 #endif |
254 max_count = base::SysInfo::AmountOfPhysicalMemoryMB() / 2; | 254 max_count = base::SysInfo::AmountOfPhysicalMemoryMB() / 2; |
255 max_count /= kEstimatedTabMemoryUsage; | 255 max_count /= kEstimatedWebContentsMemoryUsage; |
256 | 256 |
257 const size_t kMinRendererProcessCount = 3; | 257 const size_t kMinRendererProcessCount = 3; |
258 max_count = std::max(max_count, kMinRendererProcessCount); | 258 max_count = std::max(max_count, kMinRendererProcessCount); |
259 max_count = std::min(max_count, content::kMaxRendererProcessCount); | 259 max_count = std::min(max_count, content::kMaxRendererProcessCount); |
260 } | 260 } |
261 return max_count; | 261 return max_count; |
262 } | 262 } |
263 | 263 |
264 // static | 264 // static |
265 bool g_run_renderer_in_process_ = false; | 265 bool g_run_renderer_in_process_ = false; |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 // this object is not deleted at this point and may be reused later. | 1256 // this object is not deleted at this point and may be reused later. |
1257 // TODO(darin): clean this up | 1257 // TODO(darin): clean this up |
1258 } | 1258 } |
1259 | 1259 |
1260 void RenderProcessHostImpl::OnShutdownRequest() { | 1260 void RenderProcessHostImpl::OnShutdownRequest() { |
1261 // Don't shut down if there are more RenderViews than the one asking to | 1261 // Don't shut down if there are more RenderViews than the one asking to |
1262 // close, or if there are pending RenderViews being swapped back in. | 1262 // close, or if there are pending RenderViews being swapped back in. |
1263 if (pending_views_ || render_widget_hosts_.size() > 1) | 1263 if (pending_views_ || render_widget_hosts_.size() > 1) |
1264 return; | 1264 return; |
1265 | 1265 |
1266 // Notify any tabs that might have swapped out renderers from this process. | 1266 // Notify any contents that might have swapped out renderers from this |
1267 // They should not attempt to swap them back in. | 1267 // process. They should not attempt to swap them back in. |
1268 content::NotificationService::current()->Notify( | 1268 content::NotificationService::current()->Notify( |
1269 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | 1269 content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
1270 content::Source<RenderProcessHost>(this), | 1270 content::Source<RenderProcessHost>(this), |
1271 content::NotificationService::NoDetails()); | 1271 content::NotificationService::NoDetails()); |
1272 | 1272 |
1273 Send(new ChildProcessMsg_Shutdown()); | 1273 Send(new ChildProcessMsg_Shutdown()); |
1274 } | 1274 } |
1275 | 1275 |
1276 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { | 1276 void RenderProcessHostImpl::SuddenTerminationChanged(bool enabled) { |
1277 SetSuddenTerminationAllowed(enabled); | 1277 SetSuddenTerminationAllowed(enabled); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { | 1346 void RenderProcessHostImpl::OnRevealFolderInOS(const FilePath& path) { |
1347 // Only honor the request if appropriate persmissions are granted. | 1347 // Only honor the request if appropriate persmissions are granted. |
1348 if (ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(GetID(), | 1348 if (ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(GetID(), |
1349 path)) | 1349 path)) |
1350 content::GetContentClient()->browser()->OpenItem(path); | 1350 content::GetContentClient()->browser()->OpenItem(path); |
1351 } | 1351 } |
1352 | 1352 |
1353 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { | 1353 void RenderProcessHostImpl::OnSavedPageAsMHTML(int job_id, int64 data_size) { |
1354 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); | 1354 MHTMLGenerationManager::GetInstance()->MHTMLGenerated(job_id, data_size); |
1355 } | 1355 } |
OLD | NEW |