| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "content/browser/renderer_host/render_process_host.h" | 5 #include "content/browser/renderer_host/render_process_host.h" |
| 6 | 6 |
| 7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "chrome/common/chrome_constants.h" | |
| 10 #include "content/browser/browser_thread.h" | 9 #include "content/browser/browser_thread.h" |
| 11 #include "content/browser/child_process_security_policy.h" | 10 #include "content/browser/child_process_security_policy.h" |
| 12 #include "content/common/child_process_info.h" | 11 #include "content/common/child_process_info.h" |
| 12 #include "content/common/content_constants.h" |
| 13 #include "content/common/notification_service.h" | 13 #include "content/common/notification_service.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 size_t max_renderer_count_override = 0; | 17 size_t max_renderer_count_override = 0; |
| 18 | 18 |
| 19 size_t GetMaxRendererProcessCount() { | 19 size_t GetMaxRendererProcessCount() { |
| 20 if (max_renderer_count_override) | 20 if (max_renderer_count_override) |
| 21 return max_renderer_count_override; | 21 return max_renderer_count_override; |
| 22 | 22 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 44 32, // 2816MB | 44 32, // 2816MB |
| 45 35, // 3072MB | 45 35, // 3072MB |
| 46 38, // 3328MB | 46 38, // 3328MB |
| 47 40 // 3584MB | 47 40 // 3584MB |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 static size_t max_count = 0; | 50 static size_t max_count = 0; |
| 51 if (!max_count) { | 51 if (!max_count) { |
| 52 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; | 52 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; |
| 53 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) | 53 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) |
| 54 max_count = chrome::kMaxRendererProcessCount; | 54 max_count = content::kMaxRendererProcessCount; |
| 55 else | 55 else |
| 56 max_count = kMaxRenderersByRamTier[memory_tier]; | 56 max_count = kMaxRenderersByRamTier[memory_tier]; |
| 57 } | 57 } |
| 58 return max_count; | 58 return max_count; |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Returns true if the given host is suitable for launching a new view | 61 // Returns true if the given host is suitable for launching a new view |
| 62 // associated with the given profile. | 62 // associated with the given profile. |
| 63 static bool IsSuitableHost(RenderProcessHost* host, Profile* profile, | 63 static bool IsSuitableHost(RenderProcessHost* host, Profile* profile, |
| 64 RenderProcessHost::Type type) { | 64 RenderProcessHost::Type type) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 209 |
| 210 // Now pick a random suitable renderer, if we have any. | 210 // Now pick a random suitable renderer, if we have any. |
| 211 if (!suitable_renderers.empty()) { | 211 if (!suitable_renderers.empty()) { |
| 212 int suitable_count = static_cast<int>(suitable_renderers.size()); | 212 int suitable_count = static_cast<int>(suitable_renderers.size()); |
| 213 int random_index = base::RandInt(0, suitable_count - 1); | 213 int random_index = base::RandInt(0, suitable_count - 1); |
| 214 return suitable_renderers[random_index]; | 214 return suitable_renderers[random_index]; |
| 215 } | 215 } |
| 216 | 216 |
| 217 return NULL; | 217 return NULL; |
| 218 } | 218 } |
| OLD | NEW |