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_impl.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" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // a SiteInstance is only live as long as it is accessible, either from new | 52 // a SiteInstance is only live as long as it is accessible, either from new |
53 // tabs with no NavigationEntries or in NavigationEntries in the history. | 53 // tabs with no NavigationEntries or in NavigationEntries in the history. |
54 // | 54 // |
55 /////////////////////////////////////////////////////////////////////////////// | 55 /////////////////////////////////////////////////////////////////////////////// |
56 class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance>, | 56 class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance>, |
57 public content::NotificationObserver { | 57 public content::NotificationObserver { |
58 public: | 58 public: |
59 // Returns a unique ID for this SiteInstance. | 59 // Returns a unique ID for this SiteInstance. |
60 int32 id() { return id_; } | 60 int32 id() { return id_; } |
61 | 61 |
62 // Get the BrowsingInstance to which this SiteInstance belongs. | |
63 BrowsingInstance* browsing_instance() { return browsing_instance_; } | |
64 | |
65 // Sets the factory used to create new RenderProcessHosts. This will also be | 62 // Sets the factory used to create new RenderProcessHosts. This will also be |
66 // passed on to SiteInstances spawned by this one. | 63 // passed on to SiteInstances spawned by this one. |
67 // | 64 // |
68 // The factory must outlive the SiteInstance; ownership is not transferred. It | 65 // The factory must outlive the SiteInstance; ownership is not transferred. It |
69 // may be NULL, in which case the default BrowserRenderProcessHost will be | 66 // may be NULL, in which case the default BrowserRenderProcessHost will be |
70 // created (this is the behavior if you don't call this function). | 67 // created (this is the behavior if you don't call this function). |
71 void set_render_process_host_factory( | 68 void set_render_process_host_factory( |
72 content::RenderProcessHostFactory* rph_factory) { | 69 content::RenderProcessHostFactory* rph_factory) { |
73 render_process_host_factory_ = rph_factory; | 70 render_process_host_factory_ = rph_factory; |
74 } | 71 } |
(...skipping 28 matching lines...) Expand all Loading... |
103 // class from the rest of the codebase.) | 100 // class from the rest of the codebase.) |
104 // TODO(creis): This may be an argument to build a pass_refptr<T> class, as | 101 // TODO(creis): This may be an argument to build a pass_refptr<T> class, as |
105 // Darin suggests. | 102 // Darin suggests. |
106 SiteInstance* GetRelatedSiteInstance(const GURL& url); | 103 SiteInstance* GetRelatedSiteInstance(const GURL& url); |
107 | 104 |
108 // Returns whether this SiteInstance has a process that is the wrong type for | 105 // Returns whether this SiteInstance has a process that is the wrong type for |
109 // the given URL. If so, the browser should force a process swap when | 106 // the given URL. If so, the browser should force a process swap when |
110 // navigating to the URL. | 107 // navigating to the URL. |
111 bool HasWrongProcessForURL(const GURL& url) const; | 108 bool HasWrongProcessForURL(const GURL& url) const; |
112 | 109 |
| 110 // Browser context to which this SiteInstance (and all related |
| 111 // SiteInstances) belongs. |
| 112 content::BrowserContext* GetBrowserContext() const; |
| 113 |
113 // Factory method to create a new SiteInstance. This will create a new | 114 // Factory method to create a new SiteInstance. This will create a new |
114 // new BrowsingInstance, so it should only be used when creating a new tab | 115 // new BrowsingInstance, so it should only be used when creating a new tab |
115 // from scratch (or similar circumstances). Callers should ensure that | 116 // from scratch (or similar circumstances). Callers should ensure that |
116 // this SiteInstance becomes ref counted, by storing it in a scoped_refptr. | 117 // this SiteInstance becomes ref counted, by storing it in a scoped_refptr. |
117 // | 118 // |
118 // The render process host factory may be NULL. See SiteInstance constructor. | 119 // The render process host factory may be NULL. See SiteInstance constructor. |
119 // | 120 // |
120 // TODO(creis): This may be an argument to build a pass_refptr<T> class, as | 121 // TODO(creis): This may be an argument to build a pass_refptr<T> class, as |
121 // Darin suggests. | 122 // Darin suggests. |
122 static SiteInstance* CreateSiteInstance( | 123 static SiteInstance* CreateSiteInstance( |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 // will still remain the same even if the process crashes, since in that | 189 // will still remain the same even if the process crashes, since in that |
189 // scenario the RenderProcessHost remains the same. | 190 // scenario the RenderProcessHost remains the same. |
190 content::RenderProcessHost* process_; | 191 content::RenderProcessHost* process_; |
191 | 192 |
192 // The web site that this SiteInstance is rendering pages for. | 193 // The web site that this SiteInstance is rendering pages for. |
193 GURL site_; | 194 GURL site_; |
194 | 195 |
195 // Whether SetSite has been called. | 196 // Whether SetSite has been called. |
196 bool has_site_; | 197 bool has_site_; |
197 | 198 |
| 199 FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, NewTabPageProcesses); |
| 200 |
198 DISALLOW_COPY_AND_ASSIGN(SiteInstance); | 201 DISALLOW_COPY_AND_ASSIGN(SiteInstance); |
199 }; | 202 }; |
200 | 203 |
201 #endif // CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ | 204 #endif // CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ |
OLD | NEW |