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

Side by Side Diff: content/public/browser/site_instance.h

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: rparen 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 (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_PUBLIC_BROWSER_SITE_INSTANCE_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_SITE_INSTANCE_H_
6 #define CONTENT_PUBLIC_BROWSER_SITE_INSTANCE_H_ 6 #define CONTENT_PUBLIC_BROWSER_SITE_INSTANCE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 namespace content { 13 namespace content {
14 class BrowserContext; 14 class BrowserContext;
15 class RenderProcessHost; 15 class RenderProcessHost;
16 16
17 /////////////////////////////////////////////////////////////////////////////// 17 ///////////////////////////////////////////////////////////////////////////////
18 // SiteInstance interface. 18 // SiteInstance interface.
19 // 19 //
20 // A SiteInstance represents a group of web pages that may be able to 20 // A SiteInstance represents a group of web pages that must live in the same
21 // synchronously script each other, and thus must live in the same renderer 21 // renderer process. Pages able to synchronously script each other will always
22 // process. 22 // be placed in the same SiteInstance. Pages unable to synchronously script
23 // each other may also be placed in the same SiteInstance, as determined by the
24 // process model.
23 // 25 //
24 // We identify this group using a combination of where the page comes from 26 // A page's SiteInstance is determined by a combination of where the page comes
25 // (the site) and which tabs have references to each other (the instance). 27 // from (the site) and which tabs have references to each other (the instance).
Charlie Reis 2015/07/08 23:42:59 s/tabs/frames/
ncarter (slow) 2015/07/20 17:45:46 Done.
26 // Here, a "site" is similar to the page's origin, but it only includes the 28 // Here, a "site" is similar to the page's origin, but includes only the
27 // registered domain name and scheme, not the port or subdomains. This accounts 29 // registered domain name and scheme, not the port or subdomains. This accounts
28 // for the fact that changes to document.domain allow similar origin pages with 30 // for the fact that changes to document.domain allow similar origin pages with
29 // different ports or subdomains to script each other. An "instance" includes 31 // different ports or subdomains to script each other. An "instance" includes
30 // all tabs that might be able to script each other because of how they were 32 // all tabs that might be able to script each other because of how they were
Charlie Reis 2015/07/08 23:42:59 s/tabs/frames/
ncarter (slow) 2015/07/20 17:45:46 Done.
31 // created (e.g., window.open or targeted links). We represent instances using 33 // created (e.g., window.open or targeted links). We represent instances using
32 // the BrowsingInstance class. 34 // the BrowsingInstance class.
33 // 35 //
34 // Process models: 36 // Four process models are currently supported:
35 // 37 //
36 // In process-per-site-instance (the current default process model), 38 // PROCESS PER SITE INSTANCE (the current default), SiteInstances are created
nasko 2015/07/08 12:52:23 Why all caps?
Charlie Reis 2015/07/08 23:42:59 I'm ok with either caps or a numbered list. Pleas
ncarter (slow) 2015/07/20 17:45:46 Done.
37 // SiteInstances are created (1) when the user manually creates a new tab 39 // (1) when the user manually creates a new tab (which also creates a new
38 // (which also creates a new BrowsingInstance), and (2) when the user navigates 40 // BrowsingInstance), and (2) when the user navigates across site boundaries
39 // across site boundaries (which uses the same BrowsingInstance). If the user 41 // (which uses the same BrowsingInstance). If the user navigates within a site,
40 // navigates within a site, the same SiteInstance is used. 42 // the same SiteInstance is used. Caveat: we currently allow renderer-initiated
41 // (Caveat: we currently allow renderer-initiated cross-site navigations to 43 // cross-site navigations to stay in the same SiteInstance, to preserve
42 // stay in the same SiteInstance, to preserve compatibility in cases like 44 // compatibility in cases like cross-site iframes that open popups.
43 // cross-site iframes that open popups.)
44 // 45 //
45 // In --process-per-tab, SiteInstances are created when the user manually 46 // SITE PER PROCESS (currently experimental) is the most granular process model,
Charlie Reis 2015/07/08 23:42:59 Colon after close paren.
ncarter (slow) 2015/07/20 17:45:46 Done.
46 // creates a new tab, but not when navigating across site boundaries (unless 47 // and is made possible by our support for out-of-process iframes. A subframe
nasko 2015/07/08 12:52:23 nit: s/our support/supporting/
ncarter (slow) 2015/07/20 17:45:46 Not done.
47 // a process swap is required for security reasons, such as navigating from 48 // will be given a different SiteInstance if its site differs from the
48 // a privileged WebUI page to a normal web page). This corresponds to one 49 // containing document. Cross-site navigation of top-level frames or subframes
nasko 2015/07/08 12:52:23 If the wording is "top-level frames or subframes"
nasko 2015/07/08 12:52:23 nit: The usage of one or two spaces after a senten
ncarter (slow) 2015/07/20 17:45:46 Done.
ncarter (slow) 2015/07/20 17:45:46 I mentioned "top level frames or subframes" explic
49 // process per BrowsingInstance. 50 // will trigger a change of SiteInstances, even if the navigation is renderer
51 // initiated. In this model, each process can be dedicated to documents from
52 // just one site, allowing the same origin policy to be enforced by the IPC
nasko 2015/07/08 12:52:23 We have a sandbox and an IPC channel to communicat
ncarter (slow) 2015/07/08 23:28:38 What would you say instead? I was actually paraphr
Charlie Reis 2015/07/08 23:42:59 I'd just say sandbox, or renderer sandbox if you w
ncarter (slow) 2015/07/20 17:45:46 Done.
53 // sandbox.
50 // 54 //
51 // In --process-per-site, we consolidate all SiteInstances for a given site into 55 // PROCESS PER TAB: SiteInstances are created when the user manually creates a
52 // the same process, throughout the entire browser context. This ensures that 56 // new tab, but not when navigating across site boundaries. (unless a process
53 // only one process will be used for each site. 57 // swap is required for security reasons, such as navigating from a privileged
58 // WebUI page to a normal web page). This corresponds to one process per
59 // BrowsingInstance.
60 //
61 // PROCESS PER SITE: we consolidate all SiteInstances for a given site into the
62 // same process, throughout the entire browser context. This ensures that only
63 // one process will be used for each site.
54 // 64 //
55 // Each NavigationEntry for a WebContents points to the SiteInstance that 65 // Each NavigationEntry for a WebContents points to the SiteInstance that
56 // rendered it. Each RenderViewHost also points to the SiteInstance that it is 66 // rendered it. Each RenderFrameHost also points to the SiteInstance that it is
57 // associated with. A SiteInstance keeps track of the number of these 67 // associated with. A SiteInstance keeps track of the number of these
58 // references and deletes itself when the count goes to zero. This means that 68 // references and deletes itself when the count goes to zero. This means that
59 // a SiteInstance is only live as long as it is accessible, either from new 69 // a SiteInstance is only live as long as it is accessible, either from new
60 // tabs with no NavigationEntries or in NavigationEntries in the history. 70 // tabs with no NavigationEntries or in NavigationEntries in the history.
61 // 71 //
62 /////////////////////////////////////////////////////////////////////////////// 72 ///////////////////////////////////////////////////////////////////////////////
63 class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance> { 73 class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance> {
64 public: 74 public:
65 // Returns a unique ID for this SiteInstance. 75 // Returns a unique ID for this SiteInstance.
66 virtual int32 GetId() = 0; 76 virtual int32 GetId() = 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 113
104 // Returns whether the given SiteInstance is in the same BrowsingInstance as 114 // Returns whether the given SiteInstance is in the same BrowsingInstance as
105 // this one. If so, JavaScript interactions that are permitted across 115 // this one. If so, JavaScript interactions that are permitted across
106 // origins (e.g., postMessage) should be supported. 116 // origins (e.g., postMessage) should be supported.
107 virtual bool IsRelatedSiteInstance(const SiteInstance* instance) = 0; 117 virtual bool IsRelatedSiteInstance(const SiteInstance* instance) = 0;
108 118
109 // Returns the total active WebContents count for this SiteInstance and all 119 // Returns the total active WebContents count for this SiteInstance and all
110 // related SiteInstances in the same BrowsingInstance. 120 // related SiteInstances in the same BrowsingInstance.
111 virtual size_t GetRelatedActiveContentsCount() = 0; 121 virtual size_t GetRelatedActiveContentsCount() = 0;
112 122
123 // Returns true if this SiteInstance is for a site that requires a dedicated
124 // process. This only returns true under the "site per process" process model.
125 // TODO(nick): Does this name suck?
126 virtual bool RequiresDedicatedProcess() = 0;
127
113 // Factory method to create a new SiteInstance. This will create a new 128 // Factory method to create a new SiteInstance. This will create a new
114 // new BrowsingInstance, so it should only be used when creating a new tab 129 // new BrowsingInstance, so it should only be used when creating a new tab
115 // from scratch (or similar circumstances). Callers should ensure that 130 // from scratch (or similar circumstances). Callers should ensure that
116 // this SiteInstance becomes ref counted, by storing it in a scoped_refptr. 131 // this SiteInstance becomes ref counted, by storing it in a scoped_refptr.
117 // 132 //
118 // The render process host factory may be nullptr. See SiteInstance 133 // The render process host factory may be nullptr. See SiteInstance
119 // constructor. 134 // constructor.
120 // 135 //
121 // TODO(creis): This may be an argument to build a pass_refptr<T> class, as 136 // TODO(creis): This may be an argument to build a pass_refptr<T> class, as
122 // Darin suggests. 137 // Darin suggests.
(...skipping 26 matching lines...) Expand all
149 protected: 164 protected:
150 friend class base::RefCounted<SiteInstance>; 165 friend class base::RefCounted<SiteInstance>;
151 166
152 SiteInstance() {} 167 SiteInstance() {}
153 virtual ~SiteInstance() {} 168 virtual ~SiteInstance() {}
154 }; 169 };
155 170
156 } // namespace content. 171 } // namespace content.
157 172
158 #endif // CONTENT_PUBLIC_BROWSER_SITE_INSTANCE_H_ 173 #endif // CONTENT_PUBLIC_BROWSER_SITE_INSTANCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698