Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 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 SiteInstance* GetRelatedSiteInstanceForThirdPartySubframes(const GURL& url); | |
|
Charlie Reis
2016/03/18 21:15:13
Maybe drop "Related" and |url|?
| |
| 48 | |
| 47 // Set the web site that this SiteInstance is rendering pages for. | 49 // 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 | 50 // 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 | 51 // URL does not have a valid registered domain, then the full hostname is |
| 50 // stored. | 52 // stored. |
| 51 void SetSite(const GURL& url); | 53 void SetSite(const GURL& url); |
| 52 bool HasSite() const; | 54 bool HasSite() const; |
| 53 | 55 |
| 54 // Returns whether there is currently a related SiteInstance (registered with | 56 // 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 | 57 // 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). | 58 // avoid dedicating an unused SiteInstance to it (e.g., in a new tab). |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 81 // that, unlike active_frame_count, this does not count pending RFHs. | 83 // that, unlike active_frame_count, this does not count pending RFHs. |
| 82 void IncrementRelatedActiveContentsCount(); | 84 void IncrementRelatedActiveContentsCount(); |
| 83 | 85 |
| 84 // Decrease the number of active WebContentses using this SiteInstance. Note | 86 // Decrease the number of active WebContentses using this SiteInstance. Note |
| 85 // that, unlike active_frame_count, this does not count pending RFHs. | 87 // that, unlike active_frame_count, this does not count pending RFHs. |
| 86 void DecrementRelatedActiveContentsCount(); | 88 void DecrementRelatedActiveContentsCount(); |
| 87 | 89 |
| 88 void AddObserver(Observer* observer); | 90 void AddObserver(Observer* observer); |
| 89 void RemoveObserver(Observer* observer); | 91 void RemoveObserver(Observer* observer); |
| 90 | 92 |
| 93 bool is_for_third_party_subframes() { return is_for_third_party_subframes_; } | |
| 94 | |
| 91 // Sets the global factory used to create new RenderProcessHosts. It may be | 95 // 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 | 96 // 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 | 97 // 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. | 98 // back to NULL before it's destroyed; ownership is not transferred. |
| 95 static void set_render_process_host_factory( | 99 static void set_render_process_host_factory( |
| 96 const RenderProcessHostFactory* rph_factory); | 100 const RenderProcessHostFactory* rph_factory); |
| 97 | 101 |
| 98 // Get the effective URL for the given actual URL. This allows the | 102 // Get the effective URL for the given actual URL. This allows the |
| 99 // ContentBrowserClient to override the SiteInstance's site for certain URLs. | 103 // ContentBrowserClient to override the SiteInstance's site for certain URLs. |
| 100 // For example, Chrome uses this to replace hosted app URLs with extension | 104 // For example, Chrome uses this to replace hosted app URLs with extension |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 118 friend class SiteInstance; | 122 friend class SiteInstance; |
| 119 | 123 |
| 120 // Virtual to allow tests to extend it. | 124 // Virtual to allow tests to extend it. |
| 121 ~SiteInstanceImpl() override; | 125 ~SiteInstanceImpl() override; |
| 122 | 126 |
| 123 // Create a new SiteInstance. Protected to give access to BrowsingInstance | 127 // Create a new SiteInstance. Protected to give access to BrowsingInstance |
| 124 // and tests; most callers should use Create or GetRelatedSiteInstance | 128 // and tests; most callers should use Create or GetRelatedSiteInstance |
| 125 // instead. | 129 // instead. |
| 126 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); | 130 explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); |
| 127 | 131 |
| 132 // Only BrowsingInstance should call this. | |
| 133 void set_is_for_third_party_subframes() { | |
| 134 CHECK(!HasSite()); | |
| 135 is_for_third_party_subframes_ = true; | |
| 136 } | |
| 137 | |
| 128 private: | 138 private: |
| 129 // RenderProcessHostObserver implementation. | 139 // RenderProcessHostObserver implementation. |
| 130 void RenderProcessHostDestroyed(RenderProcessHost* host) override; | 140 void RenderProcessHostDestroyed(RenderProcessHost* host) override; |
| 131 void RenderProcessWillExit(RenderProcessHost* host) override; | 141 void RenderProcessWillExit(RenderProcessHost* host) override; |
| 132 void RenderProcessExited(RenderProcessHost* host, | 142 void RenderProcessExited(RenderProcessHost* host, |
| 133 base::TerminationStatus status, | 143 base::TerminationStatus status, |
| 134 int exit_code) override; | 144 int exit_code) override; |
| 135 | 145 |
| 136 // Used to restrict a process' origin access rights. | 146 // Used to restrict a process' origin access rights. |
| 137 void LockToOrigin(); | 147 void LockToOrigin(); |
| 138 | 148 |
| 139 // An object used to construct RenderProcessHosts. | 149 // An object used to construct RenderProcessHosts. |
| 140 static const RenderProcessHostFactory* g_render_process_host_factory_; | 150 static const RenderProcessHostFactory* g_render_process_host_factory_; |
| 141 | 151 |
| 142 // The next available SiteInstance ID. | 152 // The next available SiteInstance ID. |
| 143 static int32_t next_site_instance_id_; | 153 static int32_t next_site_instance_id_; |
| 144 | 154 |
| 145 // A unique ID for this SiteInstance. | 155 // A unique ID for this SiteInstance. |
| 146 int32_t id_; | 156 int32_t id_; |
| 147 | 157 |
| 148 // The number of active frames in this SiteInstance. | 158 // The number of active frames in this SiteInstance. |
| 149 size_t active_frame_count_; | 159 size_t active_frame_count_ = 0; |
| 150 | 160 |
| 151 // BrowsingInstance to which this SiteInstance belongs. | 161 // BrowsingInstance to which this SiteInstance belongs. |
| 152 scoped_refptr<BrowsingInstance> browsing_instance_; | 162 scoped_refptr<BrowsingInstance> browsing_instance_; |
| 153 | 163 |
| 154 // Current RenderProcessHost that is rendering pages for this SiteInstance. | 164 // Current RenderProcessHost that is rendering pages for this SiteInstance. |
| 155 // This pointer will only change once the RenderProcessHost is destructed. It | 165 // 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 | 166 // will still remain the same even if the process crashes, since in that |
| 157 // scenario the RenderProcessHost remains the same. | 167 // scenario the RenderProcessHost remains the same. |
| 158 RenderProcessHost* process_; | 168 RenderProcessHost* process_ = nullptr; |
| 159 | 169 |
| 160 // The web site that this SiteInstance is rendering pages for. | 170 // The web site that this SiteInstance is rendering pages for. |
| 161 GURL site_; | 171 GURL site_; |
| 162 | 172 |
| 163 // Whether SetSite has been called. | 173 // Whether SetSite has been called. |
| 164 bool has_site_; | 174 bool has_site_ = false; |
| 175 bool is_for_third_party_subframes_ = false; | |
| 165 | 176 |
| 166 base::ObserverList<Observer, true> observers_; | 177 base::ObserverList<Observer, true> observers_; |
| 167 | 178 |
| 168 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); | 179 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); |
| 169 }; | 180 }; |
| 170 | 181 |
| 171 } // namespace content | 182 } // namespace content |
| 172 | 183 |
| 173 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 184 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
| OLD | NEW |