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 |
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" |
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 : 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 { |
27 public: | 27 public: |
28 // Called when this SiteInstance transitions to having no active frames, | 28 // Called when this SiteInstance transitions to having no active frames, |
29 // as measured by active_frame_count(). | 29 // as measured by active_frame_count(). |
30 virtual void ActiveFrameCountIsZero(SiteInstanceImpl* site_instance) {} | 30 virtual void ActiveFrameCountIsZero(SiteInstanceImpl* site_instance) {} |
31 | 31 |
32 // Called when the renderer process of this SiteInstance has exited. | 32 // Called when the renderer process of this SiteInstance has exited. |
33 virtual void RenderProcessGone(SiteInstanceImpl* site_instance) = 0; | 33 virtual void RenderProcessGone(SiteInstanceImpl* site_instance) = 0; |
34 }; | 34 }; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 | 122 |
123 // Returns true if pages loaded from |effective_url| ought to be handled only | 123 // Returns true if pages loaded from |effective_url| ought to be handled only |
124 // by a renderer process isolated from other sites. If --site-per-process is | 124 // by a renderer process isolated from other sites. If --site-per-process is |
125 // on the command line, this is true for all sites. In other site isolation | 125 // on the command line, this is true for all sites. In other site isolation |
126 // modes, only a subset of sites will require dedicated processes. | 126 // modes, only a subset of sites will require dedicated processes. |
127 // | 127 // |
128 // |effective_url| must be an effective URL. | 128 // |effective_url| must be an effective URL. |
129 static bool DoesSiteRequireDedicatedProcess(BrowserContext* browser_context, | 129 static bool DoesSiteRequireDedicatedProcess(BrowserContext* browser_context, |
130 const GURL& effective_url); | 130 const GURL& effective_url); |
131 | 131 |
132 protected: | 132 protected: |
ncarter (slow)
2016/03/31 16:53:47
Do we still need a protected section?
I think thi
Charlie Reis
2016/04/01 21:50:41
Ah yes, we should reflect reality. Putting the fr
ncarter (slow)
2016/04/04 21:47:33
Done.
| |
133 friend class BrowsingInstance; | 133 friend class BrowsingInstance; |
134 | 134 |
135 // Virtual to allow tests to extend it. | |
136 ~SiteInstanceImpl() override; | 135 ~SiteInstanceImpl() override; |
137 | 136 |
138 // Create a new SiteInstance. Protected to give access to BrowsingInstance | 137 // Create a new SiteInstance. Protected to give access to BrowsingInstance; |
Charlie Reis
2016/04/01 21:50:41
Guess this will be stale if we remove protected.
ncarter (slow)
2016/04/04 21:47:33
Done.
| |
139 // and tests; most callers should use Create or GetRelatedSiteInstance | 138 // use Create or GetRelatedSiteInstance instead. |
140 // instead. | |
141 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); | 139 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); |
142 | 140 |
143 // Only BrowsingInstance should call this. | 141 // Only BrowsingInstance should call this. |
144 void set_is_default_subframe_site_instance() { | 142 void set_is_default_subframe_site_instance() { |
145 is_default_subframe_site_instance_ = true; | 143 is_default_subframe_site_instance_ = true; |
146 } | 144 } |
147 | 145 |
148 private: | 146 private: |
147 friend class SiteInstanceTestBrowserClient; | |
Charlie Reis
2016/04/01 21:50:41
nit: Add blank line after.
ncarter (slow)
2016/04/04 21:47:33
Done.
| |
149 // RenderProcessHostObserver implementation. | 148 // RenderProcessHostObserver implementation. |
150 void RenderProcessHostDestroyed(RenderProcessHost* host) override; | 149 void RenderProcessHostDestroyed(RenderProcessHost* host) override; |
151 void RenderProcessWillExit(RenderProcessHost* host) override; | 150 void RenderProcessWillExit(RenderProcessHost* host) override; |
152 void RenderProcessExited(RenderProcessHost* host, | 151 void RenderProcessExited(RenderProcessHost* host, |
153 base::TerminationStatus status, | 152 base::TerminationStatus status, |
154 int exit_code) override; | 153 int exit_code) override; |
155 | 154 |
156 // Used to restrict a process' origin access rights. | 155 // Used to restrict a process' origin access rights. |
157 void LockToOrigin(); | 156 void LockToOrigin(); |
158 | 157 |
(...skipping 30 matching lines...) Expand all Loading... | |
189 bool is_default_subframe_site_instance_; | 188 bool is_default_subframe_site_instance_; |
190 | 189 |
191 base::ObserverList<Observer, true> observers_; | 190 base::ObserverList<Observer, true> observers_; |
192 | 191 |
193 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); | 192 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); |
194 }; | 193 }; |
195 | 194 |
196 } // namespace content | 195 } // namespace content |
197 | 196 |
198 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 197 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
OLD | NEW |