| 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.h" |
| 10 #include "content/common/notification_observer.h" | 10 #include "content/common/notification_observer.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // rendered it. Each RenderViewHost also points to the SiteInstance that it is | 43 // rendered it. Each RenderViewHost also points to the SiteInstance that it is |
| 44 // associated with. A SiteInstance keeps track of the number of these | 44 // associated with. A SiteInstance keeps track of the number of these |
| 45 // references and deletes itself when the count goes to zero. This means that | 45 // references and deletes itself when the count goes to zero. This means that |
| 46 // a SiteInstance is only live as long as it is accessible, either from new | 46 // a SiteInstance is only live as long as it is accessible, either from new |
| 47 // tabs with no NavigationEntries or in NavigationEntries in the history. | 47 // tabs with no NavigationEntries or in NavigationEntries in the history. |
| 48 // | 48 // |
| 49 /////////////////////////////////////////////////////////////////////////////// | 49 /////////////////////////////////////////////////////////////////////////////// |
| 50 class SiteInstance : public base::RefCounted<SiteInstance>, | 50 class SiteInstance : public base::RefCounted<SiteInstance>, |
| 51 public NotificationObserver { | 51 public NotificationObserver { |
| 52 public: | 52 public: |
| 53 // Returns a unique ID for this SiteInstance. |
| 54 int32 id() { return id_; } |
| 55 |
| 53 // Get the BrowsingInstance to which this SiteInstance belongs. | 56 // Get the BrowsingInstance to which this SiteInstance belongs. |
| 54 BrowsingInstance* browsing_instance() { return browsing_instance_; } | 57 BrowsingInstance* browsing_instance() { return browsing_instance_; } |
| 55 | 58 |
| 56 // Sets the factory used to create new RenderProcessHosts. This will also be | 59 // Sets the factory used to create new RenderProcessHosts. This will also be |
| 57 // passed on to SiteInstances spawned by this one. | 60 // passed on to SiteInstances spawned by this one. |
| 58 // | 61 // |
| 59 // The factory must outlive the SiteInstance; ownership is not transferred. It | 62 // The factory must outlive the SiteInstance; ownership is not transferred. It |
| 60 // may be NULL, in which case the default BrowserRenderProcessHost will be | 63 // may be NULL, in which case the default BrowserRenderProcessHost will be |
| 61 // created (this is the behavior if you don't call this function). | 64 // created (this is the behavior if you don't call this function). |
| 62 void set_render_process_host_factory(RenderProcessHostFactory* rph_factory) { | 65 void set_render_process_host_factory(RenderProcessHostFactory* rph_factory) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // Returns the type of renderer process this instance belongs in, for grouping | 158 // Returns the type of renderer process this instance belongs in, for grouping |
| 156 // purposes. | 159 // purposes. |
| 157 RenderProcessHost::Type GetRendererType(); | 160 RenderProcessHost::Type GetRendererType(); |
| 158 | 161 |
| 159 private: | 162 private: |
| 160 // NotificationObserver implementation. | 163 // NotificationObserver implementation. |
| 161 virtual void Observe(NotificationType type, | 164 virtual void Observe(NotificationType type, |
| 162 const NotificationSource& source, | 165 const NotificationSource& source, |
| 163 const NotificationDetails& details); | 166 const NotificationDetails& details); |
| 164 | 167 |
| 168 // The next available SiteInstance ID. |
| 169 static int32 next_site_instance_id_; |
| 170 |
| 171 // A unique ID for this SiteInstance. |
| 172 int32 id_; |
| 173 |
| 165 NotificationRegistrar registrar_; | 174 NotificationRegistrar registrar_; |
| 166 | 175 |
| 167 // BrowsingInstance to which this SiteInstance belongs. | 176 // BrowsingInstance to which this SiteInstance belongs. |
| 168 scoped_refptr<BrowsingInstance> browsing_instance_; | 177 scoped_refptr<BrowsingInstance> browsing_instance_; |
| 169 | 178 |
| 170 // Factory for new RenderProcessHosts, not owned by this class. NULL indiactes | 179 // Factory for new RenderProcessHosts, not owned by this class. NULL indiactes |
| 171 // that the default BrowserRenderProcessHost should be created. | 180 // that the default BrowserRenderProcessHost should be created. |
| 172 const RenderProcessHostFactory* render_process_host_factory_; | 181 const RenderProcessHostFactory* render_process_host_factory_; |
| 173 | 182 |
| 174 // Current RenderProcessHost that is rendering pages for this SiteInstance. | 183 // Current RenderProcessHost that is rendering pages for this SiteInstance. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 185 // The web site that this SiteInstance is rendering pages for. | 194 // The web site that this SiteInstance is rendering pages for. |
| 186 GURL site_; | 195 GURL site_; |
| 187 | 196 |
| 188 // Whether SetSite has been called. | 197 // Whether SetSite has been called. |
| 189 bool has_site_; | 198 bool has_site_; |
| 190 | 199 |
| 191 DISALLOW_COPY_AND_ASSIGN(SiteInstance); | 200 DISALLOW_COPY_AND_ASSIGN(SiteInstance); |
| 192 }; | 201 }; |
| 193 | 202 |
| 194 #endif // CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ | 203 #endif // CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ |
| OLD | NEW |