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

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: Attempt to fix compile. Created 5 years, 4 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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 1885
1885 // Do not allow sharing of guest hosts. This is to prevent bugs where guest 1886 // Do not allow sharing of guest hosts. This is to prevent bugs where guest
1886 // and non-guest storage gets mixed. In the future, we might consider enabling 1887 // and non-guest storage gets mixed. In the future, we might consider enabling
1887 // the sharing of guests, in this case this check should be removed and 1888 // the sharing of guests, in this case this check should be removed and
1888 // InSameStoragePartition should handle the possible sharing. 1889 // InSameStoragePartition should handle the possible sharing.
1889 if (host->IsForGuestsOnly()) 1890 if (host->IsForGuestsOnly())
1890 return false; 1891 return false;
1891 1892
1892 // Check whether the given host and the intended site_url will be using the 1893 // Check whether the given host and the intended site_url will be using the
1893 // same StoragePartition, since a RenderProcessHost can only support a single 1894 // same StoragePartition, since a RenderProcessHost can only support a single
1894 // StoragePartition. This is relevant for packaged apps and isolated sites. 1895 // StoragePartition. This is relevant for packaged apps.
1895 StoragePartition* dest_partition = 1896 StoragePartition* dest_partition =
1896 BrowserContext::GetStoragePartitionForSite(browser_context, site_url); 1897 BrowserContext::GetStoragePartitionForSite(browser_context, site_url);
1897 if (!host->InSameStoragePartition(dest_partition)) 1898 if (!host->InSameStoragePartition(dest_partition))
1898 return false; 1899 return false;
1899 1900
1901 // TODO(nick): Consult the SiteIsolationPolicy here. https://crbug.com/513036
1900 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( 1902 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
1901 host->GetID()) != 1903 host->GetID()) !=
1902 WebUIControllerFactoryRegistry::GetInstance()->UseWebUIBindingsForURL( 1904 WebUIControllerFactoryRegistry::GetInstance()->UseWebUIBindingsForURL(
1903 browser_context, site_url)) { 1905 browser_context, site_url)) {
1904 return false; 1906 return false;
1905 } 1907 }
1906 1908
1907 return GetContentClient()->browser()->IsSuitableHost(host, site_url); 1909 return GetContentClient()->browser()->IsSuitableHost(host, site_url);
1908 } 1910 }
1909 1911
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 // static 1943 // static
1942 RenderProcessHost* RenderProcessHost::FromID(int render_process_id) { 1944 RenderProcessHost* RenderProcessHost::FromID(int render_process_id) {
1943 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1945 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1944 return g_all_hosts.Get().Lookup(render_process_id); 1946 return g_all_hosts.Get().Lookup(render_process_id);
1945 } 1947 }
1946 1948
1947 // static 1949 // static
1948 bool RenderProcessHost::ShouldTryToUseExistingProcessHost( 1950 bool RenderProcessHost::ShouldTryToUseExistingProcessHost(
1949 BrowserContext* browser_context, const GURL& url) { 1951 BrowserContext* browser_context, const GURL& url) {
1950 // If --site-per-process is enabled, do not try to reuse renderer processes 1952 // If --site-per-process is enabled, do not try to reuse renderer processes
1951 // when over the limit. (We could allow pages from the same site to share, if 1953 // when over the limit.
1952 // we knew what the given process was dedicated to. Allowing no sharing is 1954 // TODO(nick): This is overly conservative and isn't launchable. Move this
1953 // simpler for now.) This may cause resource exhaustion issues if too many 1955 // logic into IsSuitableHost, and check |url| against the URL the process is
1954 // sites are open at once. 1956 // dedicated to. This will allow pages from the same site to share, and will
1955 const base::CommandLine& command_line = 1957 // also allow non-isolated sites to share processes. https://crbug.com/513036
1956 *base::CommandLine::ForCurrentProcess(); 1958 if (SiteIsolationPolicy::AreCrossProcessFramesPossible())
1957 if (command_line.HasSwitch(switches::kSitePerProcess))
1958 return false; 1959 return false;
1959 1960
1960 if (run_renderer_in_process()) 1961 if (run_renderer_in_process())
1961 return true; 1962 return true;
1962 1963
1963 // NOTE: Sometimes it's necessary to create more render processes than 1964 // NOTE: Sometimes it's necessary to create more render processes than
1964 // GetMaxRendererProcessCount(), for instance when we want to create 1965 // GetMaxRendererProcessCount(), for instance when we want to create
1965 // a renderer process for a browser context that has no existing 1966 // a renderer process for a browser context that has no existing
1966 // renderers. This is OK in moderation, since the 1967 // renderers. This is OK in moderation, since the
1967 // GetMaxRendererProcessCount() is conservative. 1968 // GetMaxRendererProcessCount() is conservative.
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 void RenderProcessHostImpl::GetAudioOutputControllers( 2510 void RenderProcessHostImpl::GetAudioOutputControllers(
2510 const GetAudioOutputControllersCallback& callback) const { 2511 const GetAudioOutputControllersCallback& callback) const {
2511 audio_renderer_host()->GetOutputControllers(callback); 2512 audio_renderer_host()->GetOutputControllers(callback);
2512 } 2513 }
2513 2514
2514 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { 2515 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() {
2515 return bluetooth_dispatcher_host_.get(); 2516 return bluetooth_dispatcher_host_.get();
2516 } 2517 }
2517 2518
2518 } // namespace content 2519 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698