| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 bool HasProcess() const override; | 44 bool HasProcess() const override; |
| 45 RenderProcessHost* GetProcess() override; | 45 RenderProcessHost* GetProcess() override; |
| 46 BrowserContext* GetBrowserContext() const override; | 46 BrowserContext* GetBrowserContext() const override; |
| 47 const GURL& GetSiteURL() const override; | 47 const GURL& GetSiteURL() const override; |
| 48 scoped_refptr<SiteInstance> GetRelatedSiteInstance(const GURL& url) override; | 48 scoped_refptr<SiteInstance> GetRelatedSiteInstance(const GURL& url) override; |
| 49 bool IsRelatedSiteInstance(const SiteInstance* instance) override; | 49 bool IsRelatedSiteInstance(const SiteInstance* instance) override; |
| 50 size_t GetRelatedActiveContentsCount() override; | 50 size_t GetRelatedActiveContentsCount() override; |
| 51 bool RequiresDedicatedProcess() override; | 51 bool RequiresDedicatedProcess() override; |
| 52 bool IsDefaultSubframeSiteInstance() const override; | 52 bool IsDefaultSubframeSiteInstance() const override; |
| 53 | 53 |
| 54 void set_process_reuse_policy( |
| 55 RenderProcessHostImpl::ProcessReusePolicy policy) { |
| 56 process_reuse_policy_ = policy; |
| 57 } |
| 58 RenderProcessHostImpl::ProcessReusePolicy process_reuse_policy() const { |
| 59 return process_reuse_policy_; |
| 60 } |
| 61 |
| 54 // Returns the SiteInstance, related to this one, that should be used | 62 // Returns the SiteInstance, related to this one, that should be used |
| 55 // for subframes when an oopif is required, but a dedicated process is not. | 63 // for subframes when an oopif is required, but a dedicated process is not. |
| 56 // This SiteInstance will be created if it doesn't already exist. There is | 64 // This SiteInstance will be created if it doesn't already exist. There is |
| 57 // at most one of these per BrowsingInstance. | 65 // at most one of these per BrowsingInstance. |
| 58 scoped_refptr<SiteInstanceImpl> GetDefaultSubframeSiteInstance(); | 66 scoped_refptr<SiteInstanceImpl> GetDefaultSubframeSiteInstance(); |
| 59 | 67 |
| 60 // Set the web site that this SiteInstance is rendering pages for. | 68 // Set the web site that this SiteInstance is rendering pages for. |
| 61 // This includes the scheme and registered domain, but not the port. If the | 69 // This includes the scheme and registered domain, but not the port. If the |
| 62 // URL does not have a valid registered domain, then the full hostname is | 70 // URL does not have a valid registered domain, then the full hostname is |
| 63 // stored. | 71 // stored. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 94 // that, unlike active_frame_count, this does not count pending RFHs. | 102 // that, unlike active_frame_count, this does not count pending RFHs. |
| 95 void IncrementRelatedActiveContentsCount(); | 103 void IncrementRelatedActiveContentsCount(); |
| 96 | 104 |
| 97 // Decrease the number of active WebContentses using this SiteInstance. Note | 105 // Decrease the number of active WebContentses using this SiteInstance. Note |
| 98 // that, unlike active_frame_count, this does not count pending RFHs. | 106 // that, unlike active_frame_count, this does not count pending RFHs. |
| 99 void DecrementRelatedActiveContentsCount(); | 107 void DecrementRelatedActiveContentsCount(); |
| 100 | 108 |
| 101 void AddObserver(Observer* observer); | 109 void AddObserver(Observer* observer); |
| 102 void RemoveObserver(Observer* observer); | 110 void RemoveObserver(Observer* observer); |
| 103 | 111 |
| 104 // Sets the global factory used to create new RenderProcessHosts. It may be | |
| 105 // NULL, in which case the default RenderProcessHost will be created (this is | |
| 106 // the behavior if you don't call this function). The factory must be set | |
| 107 // back to NULL before it's destroyed; ownership is not transferred. | |
| 108 static void set_render_process_host_factory( | |
| 109 const RenderProcessHostFactory* rph_factory); | |
| 110 | |
| 111 // Get the effective URL for the given actual URL. This allows the | 112 // Get the effective URL for the given actual URL. This allows the |
| 112 // ContentBrowserClient to override the SiteInstance's site for certain URLs. | 113 // ContentBrowserClient to override the SiteInstance's site for certain URLs. |
| 113 // For example, Chrome uses this to replace hosted app URLs with extension | 114 // For example, Chrome uses this to replace hosted app URLs with extension |
| 114 // hosts. | 115 // hosts. |
| 115 // Only public so that we can make a consistent process swap decision in | 116 // Only public so that we can make a consistent process swap decision in |
| 116 // RenderFrameHostManager. | 117 // RenderFrameHostManager. |
| 117 static GURL GetEffectiveURL(BrowserContext* browser_context, | 118 static GURL GetEffectiveURL(BrowserContext* browser_context, |
| 118 const GURL& url); | 119 const GURL& url); |
| 119 | 120 |
| 120 // Returns true if pages loaded from |url| ought to be handled only by a | 121 // Returns true if pages loaded from |url| ought to be handled only by a |
| (...skipping 21 matching lines...) Expand all Loading... |
| 142 int exit_code) override; | 143 int exit_code) override; |
| 143 | 144 |
| 144 // Used to restrict a process' origin access rights. | 145 // Used to restrict a process' origin access rights. |
| 145 void LockToOrigin(); | 146 void LockToOrigin(); |
| 146 | 147 |
| 147 // This gets the render process to use for default subframe site instances. | 148 // This gets the render process to use for default subframe site instances. |
| 148 RenderProcessHost* GetDefaultSubframeProcessHost( | 149 RenderProcessHost* GetDefaultSubframeProcessHost( |
| 149 BrowserContext* browser_context, | 150 BrowserContext* browser_context, |
| 150 bool is_for_guests_only); | 151 bool is_for_guests_only); |
| 151 | 152 |
| 152 void set_is_default_subframe_site_instance() { | |
| 153 is_default_subframe_site_instance_ = true; | |
| 154 } | |
| 155 | |
| 156 // An object used to construct RenderProcessHosts. | 153 // An object used to construct RenderProcessHosts. |
| 157 static const RenderProcessHostFactory* g_render_process_host_factory_; | 154 static const RenderProcessHostFactory* g_render_process_host_factory_; |
| 158 | 155 |
| 159 // The next available SiteInstance ID. | 156 // The next available SiteInstance ID. |
| 160 static int32_t next_site_instance_id_; | 157 static int32_t next_site_instance_id_; |
| 161 | 158 |
| 162 // A unique ID for this SiteInstance. | 159 // A unique ID for this SiteInstance. |
| 163 int32_t id_; | 160 int32_t id_; |
| 164 | 161 |
| 165 // The number of active frames in this SiteInstance. | 162 // The number of active frames in this SiteInstance. |
| 166 size_t active_frame_count_; | 163 size_t active_frame_count_; |
| 167 | 164 |
| 168 // BrowsingInstance to which this SiteInstance belongs. | 165 // BrowsingInstance to which this SiteInstance belongs. |
| 169 scoped_refptr<BrowsingInstance> browsing_instance_; | 166 scoped_refptr<BrowsingInstance> browsing_instance_; |
| 170 | 167 |
| 171 // Current RenderProcessHost that is rendering pages for this SiteInstance. | 168 // Current RenderProcessHost that is rendering pages for this SiteInstance. |
| 172 // This pointer will only change once the RenderProcessHost is destructed. It | 169 // This pointer will only change once the RenderProcessHost is destructed. It |
| 173 // will still remain the same even if the process crashes, since in that | 170 // will still remain the same even if the process crashes, since in that |
| 174 // scenario the RenderProcessHost remains the same. | 171 // scenario the RenderProcessHost remains the same. |
| 175 RenderProcessHost* process_; | 172 RenderProcessHost* process_; |
| 176 | 173 |
| 177 // The web site that this SiteInstance is rendering pages for. | 174 // The web site that this SiteInstance is rendering pages for. |
| 178 GURL site_; | 175 GURL site_; |
| 179 | 176 |
| 180 // Whether SetSite has been called. | 177 // Whether SetSite has been called. |
| 181 bool has_site_; | 178 bool has_site_; |
| 182 | 179 |
| 183 // Whether this SiteInstance is the default subframe SiteInstance for its | 180 // The ProcessReusePolicy to use when creating a RenderProcessHost for this |
| 184 // BrowsingInstance. Only one SiteInstance per BrowsingInstance can have this | 181 // SiteInstance. |
| 185 // be true. | 182 RenderProcessHostImpl::ProcessReusePolicy process_reuse_policy_; |
| 186 bool is_default_subframe_site_instance_; | |
| 187 | 183 |
| 188 base::ObserverList<Observer, true> observers_; | 184 base::ObserverList<Observer, true> observers_; |
| 189 | 185 |
| 190 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); | 186 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); |
| 191 }; | 187 }; |
| 192 | 188 |
| 193 } // namespace content | 189 } // namespace content |
| 194 | 190 |
| 195 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 191 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
| OLD | NEW |