| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/renderer_host/render_process_host.h" | 5 #include "chrome/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" | 9 #include "chrome/common/chrome_constants.h" |
| 10 #include "chrome/common/notification_service.h" | 10 #include "chrome/common/notification_service.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 unsigned int GetMaxRendererProcessCount() { | 14 unsigned int GetMaxRendererProcessCount() { |
| 15 // Defines the maximum number of renderer processes according to the amount | 15 // Defines the maximum number of renderer processes according to the |
| 16 // of installed memory as reported by the OS. The table values are calculated | 16 // amount of installed memory as reported by the OS. The table |
| 17 // by assuming that you want the renderers to use half of the installed ram | 17 // values are calculated by assuming that you want the renderers to |
| 18 // and assuming that each tab uses ~25MB. | 18 // use half of the installed ram and assuming that each tab uses |
| 19 // ~25MB. |
| 19 static const int kMaxRenderersByRamTier[] = { | 20 static const int kMaxRenderersByRamTier[] = { |
| 20 4, // less than 256MB | 21 4, // less than 256MB |
| 21 8, // 256MB | 22 8, // 256MB |
| 22 12, // 512MB | 23 12, // 512MB |
| 23 16, // 768MB | 24 16, // 768MB |
| 24 }; | 25 }; |
| 25 | 26 |
| 26 static unsigned int max_count = 0; | 27 static unsigned int max_count = 0; |
| 27 if (!max_count) { | 28 if (!max_count) { |
| 28 int memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; | 29 size_t memory_tier = base::SysInfo::AmountOfPhysicalMemoryMB() / 256; |
| 29 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) | 30 if (memory_tier >= arraysize(kMaxRenderersByRamTier)) |
| 30 max_count = chrome::kMaxRendererProcessCount; | 31 max_count = chrome::kMaxRendererProcessCount; |
| 31 else | 32 else |
| 32 max_count = kMaxRenderersByRamTier[memory_tier]; | 33 max_count = kMaxRenderersByRamTier[memory_tier]; |
| 33 } | 34 } |
| 34 return max_count; | 35 return max_count; |
| 35 } | 36 } |
| 36 | 37 |
| 37 // Returns true if the given host is suitable for launching a new view | 38 // Returns true if the given host is suitable for launching a new view |
| 38 // associated with the given profile. | 39 // associated with the given profile. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 151 |
| 151 return NULL; | 152 return NULL; |
| 152 } | 153 } |
| 153 | 154 |
| 154 void RenderProcessHost::Unregister() { | 155 void RenderProcessHost::Unregister() { |
| 155 if (host_id_ >= 0) { | 156 if (host_id_ >= 0) { |
| 156 all_hosts.Remove(host_id_); | 157 all_hosts.Remove(host_id_); |
| 157 host_id_ = -1; | 158 host_id_ = -1; |
| 158 } | 159 } |
| 159 } | 160 } |
| OLD | NEW |