| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 return false; | 197 return false; |
| 198 } | 198 } |
| 199 | 199 |
| 200 // static | 200 // static |
| 201 RenderProcessHost::iterator RenderProcessHost::AllHostsIterator() { | 201 RenderProcessHost::iterator RenderProcessHost::AllHostsIterator() { |
| 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 203 return iterator(g_all_hosts.Pointer()); | 203 return iterator(g_all_hosts.Pointer()); |
| 204 } | 204 } |
| 205 | 205 |
| 206 // static | 206 // static |
| 207 int RenderProcessHost::AllHostsCount() { |
| 208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 209 return g_all_hosts.Get().size(); |
| 210 } |
| 211 |
| 212 // static |
| 207 RenderProcessHost* RenderProcessHost::FromID(int render_process_id) { | 213 RenderProcessHost* RenderProcessHost::FromID(int render_process_id) { |
| 208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 209 return g_all_hosts.Get().Lookup(render_process_id); | 215 return g_all_hosts.Get().Lookup(render_process_id); |
| 210 } | 216 } |
| 211 | 217 |
| 212 // static | 218 // static |
| 213 bool RenderProcessHost::ShouldTryToUseExistingProcessHost() { | 219 bool RenderProcessHost::ShouldTryToUseExistingProcessHost() { |
| 214 size_t renderer_process_count = g_all_hosts.Get().size(); | 220 size_t renderer_process_count = g_all_hosts.Get().size(); |
| 215 | 221 |
| 216 // NOTE: Sometimes it's necessary to create more render processes than | 222 // NOTE: Sometimes it's necessary to create more render processes than |
| (...skipping 25 matching lines...) Expand all Loading... |
| 242 | 248 |
| 243 // Now pick a random suitable renderer, if we have any. | 249 // Now pick a random suitable renderer, if we have any. |
| 244 if (!suitable_renderers.empty()) { | 250 if (!suitable_renderers.empty()) { |
| 245 int suitable_count = static_cast<int>(suitable_renderers.size()); | 251 int suitable_count = static_cast<int>(suitable_renderers.size()); |
| 246 int random_index = base::RandInt(0, suitable_count - 1); | 252 int random_index = base::RandInt(0, suitable_count - 1); |
| 247 return suitable_renderers[random_index]; | 253 return suitable_renderers[random_index]; |
| 248 } | 254 } |
| 249 | 255 |
| 250 return NULL; | 256 return NULL; |
| 251 } | 257 } |
| OLD | NEW |