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 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 // static | 1704 // static |
1705 RenderProcessHost* RenderProcessHost::GetExistingProcessHost( | 1705 RenderProcessHost* RenderProcessHost::GetExistingProcessHost( |
1706 BrowserContext* browser_context, | 1706 BrowserContext* browser_context, |
1707 const GURL& site_url) { | 1707 const GURL& site_url) { |
1708 // First figure out which existing renderers we can use. | 1708 // First figure out which existing renderers we can use. |
1709 std::vector<RenderProcessHost*> suitable_renderers; | 1709 std::vector<RenderProcessHost*> suitable_renderers; |
1710 suitable_renderers.reserve(g_all_hosts.Get().size()); | 1710 suitable_renderers.reserve(g_all_hosts.Get().size()); |
1711 | 1711 |
1712 iterator iter(AllHostsIterator()); | 1712 iterator iter(AllHostsIterator()); |
1713 while (!iter.IsAtEnd()) { | 1713 while (!iter.IsAtEnd()) { |
1714 if (RenderProcessHostImpl::IsSuitableHost( | 1714 if (GetContentClient()->browser()->MayReuseHost(iter.GetCurrentValue()) && |
| 1715 RenderProcessHostImpl::IsSuitableHost( |
1715 iter.GetCurrentValue(), | 1716 iter.GetCurrentValue(), |
1716 browser_context, site_url)) | 1717 browser_context, site_url)) { |
1717 suitable_renderers.push_back(iter.GetCurrentValue()); | 1718 suitable_renderers.push_back(iter.GetCurrentValue()); |
1718 | 1719 } |
1719 iter.Advance(); | 1720 iter.Advance(); |
1720 } | 1721 } |
1721 | 1722 |
1722 // Now pick a random suitable renderer, if we have any. | 1723 // Now pick a random suitable renderer, if we have any. |
1723 if (!suitable_renderers.empty()) { | 1724 if (!suitable_renderers.empty()) { |
1724 int suitable_count = static_cast<int>(suitable_renderers.size()); | 1725 int suitable_count = static_cast<int>(suitable_renderers.size()); |
1725 int random_index = base::RandInt(0, suitable_count - 1); | 1726 int random_index = base::RandInt(0, suitable_count - 1); |
1726 return suitable_renderers[random_index]; | 1727 return suitable_renderers[random_index]; |
1727 } | 1728 } |
1728 | 1729 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 const GURL& url) { | 1762 const GURL& url) { |
1762 // Look up the map of site to process for the given browser_context. | 1763 // Look up the map of site to process for the given browser_context. |
1763 SiteProcessMap* map = | 1764 SiteProcessMap* map = |
1764 GetSiteProcessMapForBrowserContext(browser_context); | 1765 GetSiteProcessMapForBrowserContext(browser_context); |
1765 | 1766 |
1766 // See if we have an existing process with appropriate bindings for this site. | 1767 // See if we have an existing process with appropriate bindings for this site. |
1767 // If not, the caller should create a new process and register it. | 1768 // If not, the caller should create a new process and register it. |
1768 std::string site = SiteInstance::GetSiteForURL(browser_context, url) | 1769 std::string site = SiteInstance::GetSiteForURL(browser_context, url) |
1769 .possibly_invalid_spec(); | 1770 .possibly_invalid_spec(); |
1770 RenderProcessHost* host = map->FindProcess(site); | 1771 RenderProcessHost* host = map->FindProcess(site); |
1771 if (host && !IsSuitableHost(host, browser_context, url)) { | 1772 if (host && (!GetContentClient()->browser()->MayReuseHost(host) || |
| 1773 !IsSuitableHost(host, browser_context, url))) { |
1772 // The registered process does not have an appropriate set of bindings for | 1774 // The registered process does not have an appropriate set of bindings for |
1773 // the url. Remove it from the map so we can register a better one. | 1775 // the url. Remove it from the map so we can register a better one. |
1774 RecordAction( | 1776 RecordAction( |
1775 base::UserMetricsAction("BindingsMismatch_GetProcessHostPerSite")); | 1777 base::UserMetricsAction("BindingsMismatch_GetProcessHostPerSite")); |
1776 map->RemoveProcess(host); | 1778 map->RemoveProcess(host); |
1777 host = NULL; | 1779 host = NULL; |
1778 } | 1780 } |
1779 | 1781 |
1780 return host; | 1782 return host; |
1781 } | 1783 } |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 mojo::ScopedMessagePipeHandle handle) { | 2075 mojo::ScopedMessagePipeHandle handle) { |
2074 mojo_activation_required_ = true; | 2076 mojo_activation_required_ = true; |
2075 MaybeActivateMojo(); | 2077 MaybeActivateMojo(); |
2076 | 2078 |
2077 mojo::AllocationScope scope; | 2079 mojo::AllocationScope scope; |
2078 mojo_application_host_->shell_client()->AcceptConnection(service_name, | 2080 mojo_application_host_->shell_client()->AcceptConnection(service_name, |
2079 handle.Pass()); | 2081 handle.Pass()); |
2080 } | 2082 } |
2081 | 2083 |
2082 } // namespace content | 2084 } // namespace content |
OLD | NEW |