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 #ifndef CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
6 #define CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 6 #define CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 static GURL GetEffectiveURL(BrowserContext* browser_context, | 117 static GURL GetEffectiveURL(BrowserContext* browser_context, |
118 const GURL& url); | 118 const GURL& url); |
119 | 119 |
120 // Returns true if pages loaded from |url| ought to be handled only by a | 120 // Returns true if pages loaded from |url| ought to be handled only by a |
121 // renderer process isolated from other sites. If --site-per-process is on the | 121 // renderer process isolated from other sites. If --site-per-process is on the |
122 // command line, this is true for all sites. In other site isolation modes, | 122 // command line, this is true for all sites. In other site isolation modes, |
123 // only a subset of sites will require dedicated processes. | 123 // only a subset of sites will require dedicated processes. |
124 static bool DoesSiteRequireDedicatedProcess(BrowserContext* browser_context, | 124 static bool DoesSiteRequireDedicatedProcess(BrowserContext* browser_context, |
125 const GURL& url); | 125 const GURL& url); |
126 | 126 |
| 127 // Add an origin to the list of origins that require process isolation. |
| 128 // When making process model decisions for such origins, the full |
| 129 // scheme+host+port tuple rather than eTLD+1 will be used. SiteInstances for |
| 130 // these origins will also use the full origin as site URL. |
| 131 static void AddIsolatedOrigin(const url::Origin& origin); |
| 132 |
| 133 // Register a set of isolated origins as specified on the command line with |
| 134 // the --isolate-origins flag. |origin_list| is the flag's value, which |
| 135 // contains the list of comma-separated scheme-host-port origins. See |
| 136 // AddIsolatedOrigin for definition of an isolated origin. |
| 137 static void AddIsolatedOriginsFromCommandLine(const std::string& origin_list); |
| 138 |
| 139 // Helper to check whether an origin requires origin-wide process isolation. |
| 140 static bool IsIsolatedOrigin(const url::Origin& origin); |
| 141 |
127 private: | 142 private: |
128 friend class BrowsingInstance; | 143 friend class BrowsingInstance; |
129 friend class SiteInstanceTestBrowserClient; | 144 friend class SiteInstanceTestBrowserClient; |
| 145 FRIEND_TEST_ALL_PREFIXES(SiteInstanceTest, IsolateOriginsFromCommandLine); |
130 | 146 |
131 // Create a new SiteInstance. Only BrowsingInstance should call this | 147 // Create a new SiteInstance. Only BrowsingInstance should call this |
132 // directly; clients should use Create() or GetRelatedSiteInstance() instead. | 148 // directly; clients should use Create() or GetRelatedSiteInstance() instead. |
133 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); | 149 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); |
134 | 150 |
135 ~SiteInstanceImpl() override; | 151 ~SiteInstanceImpl() override; |
136 | 152 |
137 // RenderProcessHostObserver implementation. | 153 // RenderProcessHostObserver implementation. |
138 void RenderProcessHostDestroyed(RenderProcessHost* host) override; | 154 void RenderProcessHostDestroyed(RenderProcessHost* host) override; |
139 void RenderProcessWillExit(RenderProcessHost* host) override; | 155 void RenderProcessWillExit(RenderProcessHost* host) override; |
140 void RenderProcessExited(RenderProcessHost* host, | 156 void RenderProcessExited(RenderProcessHost* host, |
141 base::TerminationStatus status, | 157 base::TerminationStatus status, |
142 int exit_code) override; | 158 int exit_code) override; |
143 | 159 |
144 // Used to restrict a process' origin access rights. | 160 // Used to restrict a process' origin access rights. |
145 void LockToOrigin(); | 161 void LockToOrigin(); |
146 | 162 |
147 // This gets the render process to use for default subframe site instances. | 163 // This gets the render process to use for default subframe site instances. |
148 RenderProcessHost* GetDefaultSubframeProcessHost( | 164 RenderProcessHost* GetDefaultSubframeProcessHost( |
149 BrowserContext* browser_context, | 165 BrowserContext* browser_context, |
150 bool is_for_guests_only); | 166 bool is_for_guests_only); |
151 | 167 |
152 void set_is_default_subframe_site_instance() { | 168 void set_is_default_subframe_site_instance() { |
153 is_default_subframe_site_instance_ = true; | 169 is_default_subframe_site_instance_ = true; |
154 } | 170 } |
155 | 171 |
| 172 // Tracks origins for which the entire origin should be treated as a site |
| 173 // when making process model decisions, rather than the origin's eTLD+1. Each |
| 174 // of these origins requires a dedicated process. |
| 175 using IsolatedOriginSet = std::set<url::Origin>; |
| 176 static IsolatedOriginSet* GetIsolatedOrigins(); |
| 177 |
156 // An object used to construct RenderProcessHosts. | 178 // An object used to construct RenderProcessHosts. |
157 static const RenderProcessHostFactory* g_render_process_host_factory_; | 179 static const RenderProcessHostFactory* g_render_process_host_factory_; |
158 | 180 |
159 // The next available SiteInstance ID. | 181 // The next available SiteInstance ID. |
160 static int32_t next_site_instance_id_; | 182 static int32_t next_site_instance_id_; |
161 | 183 |
162 // A unique ID for this SiteInstance. | 184 // A unique ID for this SiteInstance. |
163 int32_t id_; | 185 int32_t id_; |
164 | 186 |
165 // The number of active frames in this SiteInstance. | 187 // The number of active frames in this SiteInstance. |
(...skipping 20 matching lines...) Expand all Loading... |
186 bool is_default_subframe_site_instance_; | 208 bool is_default_subframe_site_instance_; |
187 | 209 |
188 base::ObserverList<Observer, true> observers_; | 210 base::ObserverList<Observer, true> observers_; |
189 | 211 |
190 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); | 212 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); |
191 }; | 213 }; |
192 | 214 |
193 } // namespace content | 215 } // namespace content |
194 | 216 |
195 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 217 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
OLD | NEW |