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

Side by Side Diff: content/browser/site_instance_impl.h

Issue 2831683002: Introduce support for origins that require process isolation. (Closed)
Patch Set: Rebase Created 3 years, 7 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 (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
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "content/browser/renderer_host/render_process_host_impl.h" 13 #include "content/browser/renderer_host/render_process_host_impl.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/public/browser/render_process_host_observer.h" 15 #include "content/public/browser/render_process_host_observer.h"
16 #include "content/public/browser/site_instance.h" 16 #include "content/public/browser/site_instance.h"
Charlie Reis 2017/05/05 23:18:51 I wonder if we should update the comments at the t
alexmos 2017/05/16 17:26:37 Yes, I've considered updating those and came to th
17 #include "url/gurl.h" 17 #include "url/gurl.h"
18 18
19 namespace content { 19 namespace content {
20 class BrowsingInstance; 20 class BrowsingInstance;
21 class RenderProcessHostFactory; 21 class RenderProcessHostFactory;
22 22
23 class CONTENT_EXPORT SiteInstanceImpl final : public SiteInstance, 23 class CONTENT_EXPORT SiteInstanceImpl final : public SiteInstance,
24 public RenderProcessHostObserver { 24 public RenderProcessHostObserver {
25 public: 25 public:
26 class CONTENT_EXPORT Observer { 26 class CONTENT_EXPORT Observer {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
Charlie Reis 2017/05/05 23:18:51 Maybe clarify that the default is scheme + eTLD+1?
alexmos 2017/05/16 17:26:38 Yes, thanks, I was sloppy there. Updated here and
130 // these origins will also use the full origin as site URL.
Charlie Reis 2017/05/05 23:18:51 This is the first use of url::Origin in this class
alexmos 2017/05/16 17:26:38 Yes, good idea. This moved to ChildProcessSecurit
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
Charlie Reis 2017/05/05 23:18:51 Same nit about previous definition of site.
alexmos 2017/05/16 17:26:38 Done.
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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698