OLD | NEW |
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 #include "content/public/browser/user_metrics.h" | 137 #include "content/public/browser/user_metrics.h" |
138 #include "content/public/browser/worker_service.h" | 138 #include "content/public/browser/worker_service.h" |
139 #include "content/public/common/child_process_host.h" | 139 #include "content/public/common/child_process_host.h" |
140 #include "content/public/common/content_constants.h" | 140 #include "content/public/common/content_constants.h" |
141 #include "content/public/common/content_switches.h" | 141 #include "content/public/common/content_switches.h" |
142 #include "content/public/common/mojo_channel_switches.h" | 142 #include "content/public/common/mojo_channel_switches.h" |
143 #include "content/public/common/process_type.h" | 143 #include "content/public/common/process_type.h" |
144 #include "content/public/common/resource_type.h" | 144 #include "content/public/common/resource_type.h" |
145 #include "content/public/common/result_codes.h" | 145 #include "content/public/common/result_codes.h" |
146 #include "content/public/common/sandboxed_process_launcher_delegate.h" | 146 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| 147 #include "content/public/common/site_isolation_policy.h" |
147 #include "content/public/common/url_constants.h" | 148 #include "content/public/common/url_constants.h" |
148 #include "device/battery/battery_monitor_impl.h" | 149 #include "device/battery/battery_monitor_impl.h" |
149 #include "device/vibration/vibration_manager_impl.h" | 150 #include "device/vibration/vibration_manager_impl.h" |
150 #include "gpu/GLES2/gl2extchromium.h" | 151 #include "gpu/GLES2/gl2extchromium.h" |
151 #include "gpu/command_buffer/client/gpu_switches.h" | 152 #include "gpu/command_buffer/client/gpu_switches.h" |
152 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 153 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
153 #include "gpu/command_buffer/service/gpu_switches.h" | 154 #include "gpu/command_buffer/service/gpu_switches.h" |
154 #include "ipc/ipc_channel.h" | 155 #include "ipc/ipc_channel.h" |
155 #include "ipc/ipc_logging.h" | 156 #include "ipc/ipc_logging.h" |
156 #include "ipc/ipc_switches.h" | 157 #include "ipc/ipc_switches.h" |
(...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
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 Loading... |
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. |
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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2514 void RenderProcessHostImpl::GetAudioOutputControllers( | 2515 void RenderProcessHostImpl::GetAudioOutputControllers( |
2515 const GetAudioOutputControllersCallback& callback) const { | 2516 const GetAudioOutputControllersCallback& callback) const { |
2516 audio_renderer_host()->GetOutputControllers(callback); | 2517 audio_renderer_host()->GetOutputControllers(callback); |
2517 } | 2518 } |
2518 | 2519 |
2519 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { | 2520 BluetoothDispatcherHost* RenderProcessHostImpl::GetBluetoothDispatcherHost() { |
2520 return bluetooth_dispatcher_host_.get(); | 2521 return bluetooth_dispatcher_host_.get(); |
2521 } | 2522 } |
2522 | 2523 |
2523 } // namespace content | 2524 } // namespace content |
OLD | NEW |