| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_RENDERER_HOST_SITE_INSTANCE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "content/browser/renderer_host/render_process_host.h" | 9 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 10 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 | 14 |
| 15 class BrowsingInstance; | 15 class BrowsingInstance; |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 class BrowserContext; | 18 class BrowserContext; |
| 19 class RenderProcessHostFactory; |
| 19 } | 20 } |
| 20 | 21 |
| 21 /////////////////////////////////////////////////////////////////////////////// | 22 /////////////////////////////////////////////////////////////////////////////// |
| 22 // | 23 // |
| 23 // SiteInstance class | 24 // SiteInstance class |
| 24 // | 25 // |
| 25 // A SiteInstance is a data structure that is associated with all pages in a | 26 // A SiteInstance is a data structure that is associated with all pages in a |
| 26 // given instance of a web site. Here, a web site is identified by its | 27 // given instance of a web site. Here, a web site is identified by its |
| 27 // registered domain name and scheme. An instance includes all pages | 28 // registered domain name and scheme. An instance includes all pages |
| 28 // that are connected (i.e., either a user or a script navigated from one | 29 // that are connected (i.e., either a user or a script navigated from one |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 61 |
| 61 // Get the BrowsingInstance to which this SiteInstance belongs. | 62 // Get the BrowsingInstance to which this SiteInstance belongs. |
| 62 BrowsingInstance* browsing_instance() { return browsing_instance_; } | 63 BrowsingInstance* browsing_instance() { return browsing_instance_; } |
| 63 | 64 |
| 64 // Sets the factory used to create new RenderProcessHosts. This will also be | 65 // Sets the factory used to create new RenderProcessHosts. This will also be |
| 65 // passed on to SiteInstances spawned by this one. | 66 // passed on to SiteInstances spawned by this one. |
| 66 // | 67 // |
| 67 // The factory must outlive the SiteInstance; ownership is not transferred. It | 68 // The factory must outlive the SiteInstance; ownership is not transferred. It |
| 68 // may be NULL, in which case the default BrowserRenderProcessHost will be | 69 // may be NULL, in which case the default BrowserRenderProcessHost will be |
| 69 // created (this is the behavior if you don't call this function). | 70 // created (this is the behavior if you don't call this function). |
| 70 void set_render_process_host_factory(RenderProcessHostFactory* rph_factory) { | 71 void set_render_process_host_factory( |
| 72 content::RenderProcessHostFactory* rph_factory) { |
| 71 render_process_host_factory_ = rph_factory; | 73 render_process_host_factory_ = rph_factory; |
| 72 } | 74 } |
| 73 | 75 |
| 74 // Update / Get the max page ID for this SiteInstance. | 76 // Update / Get the max page ID for this SiteInstance. |
| 75 void UpdateMaxPageID(int32 page_id) { | 77 void UpdateMaxPageID(int32 page_id) { |
| 76 if (page_id > max_page_id_) | 78 if (page_id > max_page_id_) |
| 77 max_page_id_ = page_id; | 79 max_page_id_ = page_id; |
| 78 } | 80 } |
| 79 int32 max_page_id() const { return max_page_id_; } | 81 int32 max_page_id() const { return max_page_id_; } |
| 80 | 82 |
| 81 // Whether this SiteInstance has a running process associated with it. | 83 // Whether this SiteInstance has a running process associated with it. |
| 82 bool HasProcess() const; | 84 bool HasProcess() const; |
| 83 | 85 |
| 84 // Returns the current process being used to render pages in this | 86 // Returns the current process being used to render pages in this |
| 85 // SiteInstance. If the process has crashed or otherwise gone away, then | 87 // SiteInstance. If the process has crashed or otherwise gone away, then |
| 86 // this method will create a new process and update our host ID accordingly. | 88 // this method will create a new process and update our host ID accordingly. |
| 87 RenderProcessHost* GetProcess(); | 89 content::RenderProcessHost* GetProcess(); |
| 88 | 90 |
| 89 // Set / Get the web site that this SiteInstance is rendering pages for. | 91 // Set / Get the web site that this SiteInstance is rendering pages for. |
| 90 // This includes the scheme and registered domain, but not the port. If the | 92 // This includes the scheme and registered domain, but not the port. If the |
| 91 // URL does not have a valid registered domain, then the full hostname is | 93 // URL does not have a valid registered domain, then the full hostname is |
| 92 // stored. | 94 // stored. |
| 93 void SetSite(const GURL& url); | 95 void SetSite(const GURL& url); |
| 94 const GURL& site() const { return site_; } | 96 const GURL& site() const { return site_; } |
| 95 bool has_site() const { return has_site_; } | 97 bool has_site() const { return has_site_; } |
| 96 | 98 |
| 97 // Returns whether there is currently a related SiteInstance (registered with | 99 // Returns whether there is currently a related SiteInstance (registered with |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // A unique ID for this SiteInstance. | 178 // A unique ID for this SiteInstance. |
| 177 int32 id_; | 179 int32 id_; |
| 178 | 180 |
| 179 content::NotificationRegistrar registrar_; | 181 content::NotificationRegistrar registrar_; |
| 180 | 182 |
| 181 // BrowsingInstance to which this SiteInstance belongs. | 183 // BrowsingInstance to which this SiteInstance belongs. |
| 182 scoped_refptr<BrowsingInstance> browsing_instance_; | 184 scoped_refptr<BrowsingInstance> browsing_instance_; |
| 183 | 185 |
| 184 // Factory for new RenderProcessHosts, not owned by this class. NULL indiactes | 186 // Factory for new RenderProcessHosts, not owned by this class. NULL indiactes |
| 185 // that the default BrowserRenderProcessHost should be created. | 187 // that the default BrowserRenderProcessHost should be created. |
| 186 const RenderProcessHostFactory* render_process_host_factory_; | 188 const content::RenderProcessHostFactory* render_process_host_factory_; |
| 187 | 189 |
| 188 // Current RenderProcessHost that is rendering pages for this SiteInstance. | 190 // Current RenderProcessHost that is rendering pages for this SiteInstance. |
| 189 // This pointer will only change once the RenderProcessHost is destructed. It | 191 // This pointer will only change once the RenderProcessHost is destructed. It |
| 190 // will still remain the same even if the process crashes, since in that | 192 // will still remain the same even if the process crashes, since in that |
| 191 // scenario the RenderProcessHost remains the same. | 193 // scenario the RenderProcessHost remains the same. |
| 192 RenderProcessHost* process_; | 194 content::RenderProcessHost* process_; |
| 193 | 195 |
| 194 // The current max_page_id in the SiteInstance's RenderProcessHost. If the | 196 // The current max_page_id in the SiteInstance's RenderProcessHost. If the |
| 195 // rendering process dies, its replacement should start issuing page IDs that | 197 // rendering process dies, its replacement should start issuing page IDs that |
| 196 // are larger than this value. | 198 // are larger than this value. |
| 197 int32 max_page_id_; | 199 int32 max_page_id_; |
| 198 | 200 |
| 199 // The web site that this SiteInstance is rendering pages for. | 201 // The web site that this SiteInstance is rendering pages for. |
| 200 GURL site_; | 202 GURL site_; |
| 201 | 203 |
| 202 // Whether SetSite has been called. | 204 // Whether SetSite has been called. |
| 203 bool has_site_; | 205 bool has_site_; |
| 204 | 206 |
| 205 DISALLOW_COPY_AND_ASSIGN(SiteInstance); | 207 DISALLOW_COPY_AND_ASSIGN(SiteInstance); |
| 206 }; | 208 }; |
| 207 | 209 |
| 208 #endif // CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ | 210 #endif // CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ |
| OLD | NEW |