Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 1208143002: Move existing kSitePerProcess checks to a policy-oracle object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@swapped_out_cmdline_checks
Patch Set: Fix some includes Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 #include "content/browser/webui/web_ui_controller_factory_registry.h" 115 #include "content/browser/webui/web_ui_controller_factory_registry.h"
116 #include "content/common/child_process_host_impl.h" 116 #include "content/common/child_process_host_impl.h"
117 #include "content/common/child_process_messages.h" 117 #include "content/common/child_process_messages.h"
118 #include "content/common/content_switches_internal.h" 118 #include "content/common/content_switches_internal.h"
119 #include "content/common/frame_messages.h" 119 #include "content/common/frame_messages.h"
120 #include "content/common/gpu/gpu_messages.h" 120 #include "content/common/gpu/gpu_messages.h"
121 #include "content/common/in_process_child_thread_params.h" 121 #include "content/common/in_process_child_thread_params.h"
122 #include "content/common/mojo/channel_init.h" 122 #include "content/common/mojo/channel_init.h"
123 #include "content/common/mojo/mojo_messages.h" 123 #include "content/common/mojo/mojo_messages.h"
124 #include "content/common/resource_messages.h" 124 #include "content/common/resource_messages.h"
125 #include "content/common/site_isolation_policy.h"
125 #include "content/common/view_messages.h" 126 #include "content/common/view_messages.h"
126 #include "content/public/browser/browser_context.h" 127 #include "content/public/browser/browser_context.h"
127 #include "content/public/browser/content_browser_client.h" 128 #include "content/public/browser/content_browser_client.h"
128 #include "content/public/browser/navigator_connect_context.h" 129 #include "content/public/browser/navigator_connect_context.h"
129 #include "content/public/browser/notification_service.h" 130 #include "content/public/browser/notification_service.h"
130 #include "content/public/browser/notification_types.h" 131 #include "content/public/browser/notification_types.h"
131 #include "content/public/browser/render_process_host_factory.h" 132 #include "content/public/browser/render_process_host_factory.h"
132 #include "content/public/browser/render_process_host_observer.h" 133 #include "content/public/browser/render_process_host_observer.h"
133 #include "content/public/browser/render_widget_host.h" 134 #include "content/public/browser/render_widget_host.h"
134 #include "content/public/browser/render_widget_host_iterator.h" 135 #include "content/public/browser/render_widget_host_iterator.h"
(...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 1884
1884 // Do not allow sharing of guest hosts. This is to prevent bugs where guest 1885 // Do not allow sharing of guest hosts. This is to prevent bugs where guest
1885 // and non-guest storage gets mixed. In the future, we might consider enabling 1886 // and non-guest storage gets mixed. In the future, we might consider enabling
1886 // the sharing of guests, in this case this check should be removed and 1887 // the sharing of guests, in this case this check should be removed and
1887 // InSameStoragePartition should handle the possible sharing. 1888 // InSameStoragePartition should handle the possible sharing.
1888 if (host->IsForGuestsOnly()) 1889 if (host->IsForGuestsOnly())
1889 return false; 1890 return false;
1890 1891
1891 // Check whether the given host and the intended site_url will be using the 1892 // Check whether the given host and the intended site_url will be using the
1892 // same StoragePartition, since a RenderProcessHost can only support a single 1893 // same StoragePartition, since a RenderProcessHost can only support a single
1893 // StoragePartition. This is relevant for packaged apps and isolated sites. 1894 // StoragePartition. This is relevant for packaged apps.
1894 StoragePartition* dest_partition = 1895 StoragePartition* dest_partition =
1895 BrowserContext::GetStoragePartitionForSite(browser_context, site_url); 1896 BrowserContext::GetStoragePartitionForSite(browser_context, site_url);
1896 if (!host->InSameStoragePartition(dest_partition)) 1897 if (!host->InSameStoragePartition(dest_partition))
1897 return false; 1898 return false;
1898 1899
1900 // TODO(nick): Consult the SiteIsolationPolicy here.
1899 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( 1901 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
1900 host->GetID()) != 1902 host->GetID()) !=
1901 WebUIControllerFactoryRegistry::GetInstance()->UseWebUIBindingsForURL( 1903 WebUIControllerFactoryRegistry::GetInstance()->UseWebUIBindingsForURL(
1902 browser_context, site_url)) { 1904 browser_context, site_url)) {
1903 return false; 1905 return false;
1904 } 1906 }
1905 1907
1906 return GetContentClient()->browser()->IsSuitableHost(host, site_url); 1908 return GetContentClient()->browser()->IsSuitableHost(host, site_url);
1907 } 1909 }
1908 1910
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 // static 1942 // static
1941 RenderProcessHost* RenderProcessHost::FromID(int render_process_id) { 1943 RenderProcessHost* RenderProcessHost::FromID(int render_process_id) {
1942 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1944 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1943 return g_all_hosts.Get().Lookup(render_process_id); 1945 return g_all_hosts.Get().Lookup(render_process_id);
1944 } 1946 }
1945 1947
1946 // static 1948 // static
1947 bool RenderProcessHost::ShouldTryToUseExistingProcessHost( 1949 bool RenderProcessHost::ShouldTryToUseExistingProcessHost(
1948 BrowserContext* browser_context, const GURL& url) { 1950 BrowserContext* browser_context, const GURL& url) {
1949 // If --site-per-process is enabled, do not try to reuse renderer processes 1951 // If --site-per-process is enabled, do not try to reuse renderer processes
1950 // when over the limit. (We could allow pages from the same site to share, if 1952 // when over the limit.
1951 // we knew what the given process was dedicated to. Allowing no sharing is 1953 // TODO(nick): This is overly conservative and isn't launchable. Move this
Charlie Reis 2015/07/21 16:58:23 Can you file a bug for this so it doesn't fall bet
ncarter (slow) 2015/07/22 23:29:08 Done.
1952 // simpler for now.) This may cause resource exhaustion issues if too many 1954 // logic into IsSuitableHost, and check |url| against the URL the process is
1953 // sites are open at once. 1955 // dedicated to. This will allow pages from the same site to share, and will
1954 const base::CommandLine& command_line = 1956 // also allow non-isolated sites to share processes.
1955 *base::CommandLine::ForCurrentProcess(); 1957 if (SiteIsolationPolicy::AreCrossProcessFramesPossible())
1956 if (command_line.HasSwitch(switches::kSitePerProcess))
1957 return false; 1958 return false;
1958 1959
1959 if (run_renderer_in_process()) 1960 if (run_renderer_in_process())
1960 return true; 1961 return true;
1961 1962
1962 // NOTE: Sometimes it's necessary to create more render processes than 1963 // NOTE: Sometimes it's necessary to create more render processes than
1963 // GetMaxRendererProcessCount(), for instance when we want to create 1964 // GetMaxRendererProcessCount(), for instance when we want to create
1964 // a renderer process for a browser context that has no existing 1965 // a renderer process for a browser context that has no existing
1965 // renderers. This is OK in moderation, since the 1966 // renderers. This is OK in moderation, since the
1966 // GetMaxRendererProcessCount() is conservative. 1967 // GetMaxRendererProcessCount() is conservative.
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2510 void RenderProcessHostImpl::GetAudioOutputControllers( 2511 void RenderProcessHostImpl::GetAudioOutputControllers(
2511 const GetAudioOutputControllersCallback& callback) const { 2512 const GetAudioOutputControllersCallback& callback) const {
2512 audio_renderer_host()->GetOutputControllers(callback); 2513 audio_renderer_host()->GetOutputControllers(callback);
2513 } 2514 }
2514 2515
2515 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { 2516 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() {
2516 return bluetooth_dispatcher_host_.get(); 2517 return bluetooth_dispatcher_host_.get();
2517 } 2518 }
2518 2519
2519 } // namespace content 2520 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698