| 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 "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/browser/child_process_security_policy.h" | 9 #include "chrome/browser/child_process_security_policy.h" |
| 10 #include "chrome/common/child_process_info.h" | 10 #include "chrome/common/child_process_info.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 | 59 |
| 60 // Returns true if the given host is suitable for launching a new view | 60 // Returns true if the given host is suitable for launching a new view |
| 61 // associated with the given profile. | 61 // associated with the given profile. |
| 62 static bool IsSuitableHost(RenderProcessHost* host, Profile* profile, | 62 static bool IsSuitableHost(RenderProcessHost* host, Profile* profile, |
| 63 RenderProcessHost::Type type) { | 63 RenderProcessHost::Type type) { |
| 64 if (host->profile() != profile) | 64 if (host->profile() != profile) |
| 65 return false; | 65 return false; |
| 66 | 66 |
| 67 RenderProcessHost::Type host_type = RenderProcessHost::TYPE_NORMAL; | 67 RenderProcessHost::Type host_type = RenderProcessHost::TYPE_NORMAL; |
| 68 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings(host->id())) | 68 if (ChildProcessSecurityPolicy::GetInstance()->HasWebUIBindings(host->id())) |
| 69 host_type = RenderProcessHost::TYPE_DOMUI; | 69 host_type = RenderProcessHost::TYPE_WEBUI; |
| 70 if (ChildProcessSecurityPolicy::GetInstance()-> | 70 if (ChildProcessSecurityPolicy::GetInstance()-> |
| 71 HasExtensionBindings(host->id())) | 71 HasExtensionBindings(host->id())) |
| 72 host_type = RenderProcessHost::TYPE_EXTENSION; | 72 host_type = RenderProcessHost::TYPE_EXTENSION; |
| 73 | 73 |
| 74 return host_type == type; | 74 return host_type == type; |
| 75 } | 75 } |
| 76 | 76 |
| 77 // the global list of all renderer processes | 77 // the global list of all renderer processes |
| 78 IDMap<RenderProcessHost> all_hosts; | 78 IDMap<RenderProcessHost> all_hosts; |
| 79 | 79 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 195 |
| 196 // Now pick a random suitable renderer, if we have any. | 196 // Now pick a random suitable renderer, if we have any. |
| 197 if (!suitable_renderers.empty()) { | 197 if (!suitable_renderers.empty()) { |
| 198 int suitable_count = static_cast<int>(suitable_renderers.size()); | 198 int suitable_count = static_cast<int>(suitable_renderers.size()); |
| 199 int random_index = base::RandInt(0, suitable_count - 1); | 199 int random_index = base::RandInt(0, suitable_count - 1); |
| 200 return suitable_renderers[random_index]; | 200 return suitable_renderers[random_index]; |
| 201 } | 201 } |
| 202 | 202 |
| 203 return NULL; | 203 return NULL; |
| 204 } | 204 } |
| OLD | NEW |