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

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

Issue 1797363002: "Top Document Isolation" mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing override Created 4 years, 9 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
(...skipping 26 matching lines...) Expand all
37 int32_t GetId() override; 37 int32_t GetId() override;
38 bool HasProcess() const override; 38 bool HasProcess() const override;
39 RenderProcessHost* GetProcess() override; 39 RenderProcessHost* GetProcess() override;
40 BrowserContext* GetBrowserContext() const override; 40 BrowserContext* GetBrowserContext() const override;
41 const GURL& GetSiteURL() const override; 41 const GURL& GetSiteURL() const override;
42 SiteInstance* GetRelatedSiteInstance(const GURL& url) override; 42 SiteInstance* GetRelatedSiteInstance(const GURL& url) override;
43 bool IsRelatedSiteInstance(const SiteInstance* instance) override; 43 bool IsRelatedSiteInstance(const SiteInstance* instance) override;
44 size_t GetRelatedActiveContentsCount() override; 44 size_t GetRelatedActiveContentsCount() override;
45 bool RequiresDedicatedProcess() override; 45 bool RequiresDedicatedProcess() override;
46 46
47 // Returns the SiteInstance, related to this one, that should be used
48 // for subframes when an oopif is required, but a dedicated process is not.
49 // This SiteInstance will be created if it doesn't already exist. There is
50 // at most one of these per BrowsingInstance.
51 SiteInstance* GetDefaultSubframeSiteInstance();
52
47 // Set the web site that this SiteInstance is rendering pages for. 53 // Set the web site that this SiteInstance is rendering pages for.
48 // This includes the scheme and registered domain, but not the port. If the 54 // This includes the scheme and registered domain, but not the port. If the
49 // URL does not have a valid registered domain, then the full hostname is 55 // URL does not have a valid registered domain, then the full hostname is
50 // stored. 56 // stored.
51 void SetSite(const GURL& url); 57 void SetSite(const GURL& url);
52 bool HasSite() const; 58 bool HasSite() const;
53 59
54 // Returns whether there is currently a related SiteInstance (registered with 60 // Returns whether there is currently a related SiteInstance (registered with
55 // BrowsingInstance) for the site of the given url. If so, we should try to 61 // BrowsingInstance) for the site of the given url. If so, we should try to
56 // avoid dedicating an unused SiteInstance to it (e.g., in a new tab). 62 // avoid dedicating an unused SiteInstance to it (e.g., in a new tab).
(...skipping 24 matching lines...) Expand all
81 // that, unlike active_frame_count, this does not count pending RFHs. 87 // that, unlike active_frame_count, this does not count pending RFHs.
82 void IncrementRelatedActiveContentsCount(); 88 void IncrementRelatedActiveContentsCount();
83 89
84 // Decrease the number of active WebContentses using this SiteInstance. Note 90 // Decrease the number of active WebContentses using this SiteInstance. Note
85 // that, unlike active_frame_count, this does not count pending RFHs. 91 // that, unlike active_frame_count, this does not count pending RFHs.
86 void DecrementRelatedActiveContentsCount(); 92 void DecrementRelatedActiveContentsCount();
87 93
88 void AddObserver(Observer* observer); 94 void AddObserver(Observer* observer);
89 void RemoveObserver(Observer* observer); 95 void RemoveObserver(Observer* observer);
90 96
97 bool is_default_subframe_site_instance() {
98 return is_default_subframe_site_instance_;
99 }
100
91 // Sets the global factory used to create new RenderProcessHosts. It may be 101 // Sets the global factory used to create new RenderProcessHosts. It may be
92 // NULL, in which case the default RenderProcessHost will be created (this is 102 // NULL, in which case the default RenderProcessHost will be created (this is
93 // the behavior if you don't call this function). The factory must be set 103 // the behavior if you don't call this function). The factory must be set
94 // back to NULL before it's destroyed; ownership is not transferred. 104 // back to NULL before it's destroyed; ownership is not transferred.
95 static void set_render_process_host_factory( 105 static void set_render_process_host_factory(
96 const RenderProcessHostFactory* rph_factory); 106 const RenderProcessHostFactory* rph_factory);
97 107
98 // Get the effective URL for the given actual URL. This allows the 108 // Get the effective URL for the given actual URL. This allows the
99 // ContentBrowserClient to override the SiteInstance's site for certain URLs. 109 // ContentBrowserClient to override the SiteInstance's site for certain URLs.
100 // For example, Chrome uses this to replace hosted app URLs with extension 110 // For example, Chrome uses this to replace hosted app URLs with extension
(...skipping 17 matching lines...) Expand all
118 friend class SiteInstance; 128 friend class SiteInstance;
119 129
120 // Virtual to allow tests to extend it. 130 // Virtual to allow tests to extend it.
121 ~SiteInstanceImpl() override; 131 ~SiteInstanceImpl() override;
122 132
123 // Create a new SiteInstance. Protected to give access to BrowsingInstance 133 // Create a new SiteInstance. Protected to give access to BrowsingInstance
124 // and tests; most callers should use Create or GetRelatedSiteInstance 134 // and tests; most callers should use Create or GetRelatedSiteInstance
125 // instead. 135 // instead.
126 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); 136 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance);
127 137
138 // Only BrowsingInstance should call this.
139 void set_is_default_subframe_site_instance() {
140 is_default_subframe_site_instance_ = true;
141 }
142
128 private: 143 private:
129 // RenderProcessHostObserver implementation. 144 // RenderProcessHostObserver implementation.
130 void RenderProcessHostDestroyed(RenderProcessHost* host) override; 145 void RenderProcessHostDestroyed(RenderProcessHost* host) override;
131 void RenderProcessWillExit(RenderProcessHost* host) override; 146 void RenderProcessWillExit(RenderProcessHost* host) override;
132 void RenderProcessExited(RenderProcessHost* host, 147 void RenderProcessExited(RenderProcessHost* host,
133 base::TerminationStatus status, 148 base::TerminationStatus status,
134 int exit_code) override; 149 int exit_code) override;
135 150
136 // Used to restrict a process' origin access rights. 151 // Used to restrict a process' origin access rights.
137 void LockToOrigin(); 152 void LockToOrigin();
138 153
139 // An object used to construct RenderProcessHosts. 154 // An object used to construct RenderProcessHosts.
140 static const RenderProcessHostFactory* g_render_process_host_factory_; 155 static const RenderProcessHostFactory* g_render_process_host_factory_;
141 156
142 // The next available SiteInstance ID. 157 // The next available SiteInstance ID.
143 static int32_t next_site_instance_id_; 158 static int32_t next_site_instance_id_;
144 159
145 // A unique ID for this SiteInstance. 160 // A unique ID for this SiteInstance.
146 int32_t id_; 161 int32_t id_;
147 162
148 // The number of active frames in this SiteInstance. 163 // The number of active frames in this SiteInstance.
149 size_t active_frame_count_; 164 size_t active_frame_count_ = 0;
Charlie Reis 2016/03/25 19:47:13 Style question: Is this a new practice that we're
ncarter (slow) 2016/03/28 22:00:29 It's been allowed for over a year: https://groups.
Charlie Reis 2016/03/29 17:17:12 Ah, interesting. Thanks for letting me know.
150 165
151 // BrowsingInstance to which this SiteInstance belongs. 166 // BrowsingInstance to which this SiteInstance belongs.
152 scoped_refptr<BrowsingInstance> browsing_instance_; 167 scoped_refptr<BrowsingInstance> browsing_instance_;
153 168
154 // Current RenderProcessHost that is rendering pages for this SiteInstance. 169 // Current RenderProcessHost that is rendering pages for this SiteInstance.
155 // This pointer will only change once the RenderProcessHost is destructed. It 170 // This pointer will only change once the RenderProcessHost is destructed. It
156 // will still remain the same even if the process crashes, since in that 171 // will still remain the same even if the process crashes, since in that
157 // scenario the RenderProcessHost remains the same. 172 // scenario the RenderProcessHost remains the same.
158 RenderProcessHost* process_; 173 RenderProcessHost* process_ = nullptr;
159 174
160 // The web site that this SiteInstance is rendering pages for. 175 // The web site that this SiteInstance is rendering pages for.
161 GURL site_; 176 GURL site_;
162 177
163 // Whether SetSite has been called. 178 // Whether SetSite has been called.
164 bool has_site_; 179 bool has_site_ = false;
180 bool is_default_subframe_site_instance_ = false;
Charlie Reis 2016/03/25 19:47:13 nit: Add a blank line before and a comment about t
ncarter (slow) 2016/03/28 22:00:29 Done.
165 181
166 base::ObserverList<Observer, true> observers_; 182 base::ObserverList<Observer, true> observers_;
167 183
168 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); 184 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl);
169 }; 185 };
170 186
171 } // namespace content 187 } // namespace content
172 188
173 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ 189 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698