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 "content/browser/renderer_host/render_process_host_impl.h" | 8 #include "content/browser/renderer_host/render_process_host_impl.h" |
9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
10 #include "content/public/browser/render_process_host_observer.h" | 10 #include "content/public/browser/render_process_host_observer.h" |
11 #include "content/public/browser/site_instance.h" | 11 #include "content/public/browser/site_instance.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 class RenderProcessHostFactory; | 15 class RenderProcessHostFactory; |
16 | 16 |
17 class CONTENT_EXPORT SiteInstanceImpl : public SiteInstance, | 17 class CONTENT_EXPORT SiteInstanceImpl : public SiteInstance, |
18 public RenderProcessHostObserver { | 18 public RenderProcessHostObserver { |
19 public: | 19 public: |
20 // SiteInstance interface overrides. | 20 // SiteInstance interface overrides. |
21 virtual int32 GetId() OVERRIDE; | 21 virtual int32 GetId() OVERRIDE; |
22 virtual bool HasProcess() const OVERRIDE; | 22 virtual bool HasProcess() const OVERRIDE; |
23 virtual RenderProcessHost* GetProcess() OVERRIDE; | 23 virtual RenderProcessHost* GetProcess() OVERRIDE; |
24 virtual BrowserContext* GetBrowserContext() const OVERRIDE; | |
24 virtual const GURL& GetSiteURL() const OVERRIDE; | 25 virtual const GURL& GetSiteURL() const OVERRIDE; |
25 virtual SiteInstance* GetRelatedSiteInstance(const GURL& url) OVERRIDE; | 26 virtual SiteInstance* GetRelatedSiteInstance(const GURL& url) OVERRIDE; |
26 virtual bool IsRelatedSiteInstance(const SiteInstance* instance) OVERRIDE; | 27 virtual bool IsRelatedSiteInstance(const SiteInstance* instance) OVERRIDE; |
27 virtual BrowserContext* GetBrowserContext() const OVERRIDE; | 28 virtual size_t GetRelatedActiveContentsCount() const OVERRIDE; |
28 | 29 |
29 // Set the web site that this SiteInstance is rendering pages for. | 30 // Set the web site that this SiteInstance is rendering pages for. |
30 // This includes the scheme and registered domain, but not the port. If the | 31 // This includes the scheme and registered domain, but not the port. If the |
31 // URL does not have a valid registered domain, then the full hostname is | 32 // URL does not have a valid registered domain, then the full hostname is |
32 // stored. | 33 // stored. |
33 void SetSite(const GURL& url); | 34 void SetSite(const GURL& url); |
34 bool HasSite() const; | 35 bool HasSite() const; |
35 | 36 |
36 // Returns whether there is currently a related SiteInstance (registered with | 37 // Returns whether there is currently a related SiteInstance (registered with |
37 // BrowsingInstance) for the site of the given url. If so, we should try to | 38 // BrowsingInstance) for the site of the given url. If so, we should try to |
(...skipping 12 matching lines...) Expand all Loading... | |
50 | 51 |
51 // Decrease the number of active views in this SiteInstance. This is | 52 // Decrease the number of active views in this SiteInstance. This is |
52 // decreased when a view is destroyed, or a currently active view is | 53 // decreased when a view is destroyed, or a currently active view is |
53 // swapped out. | 54 // swapped out. |
54 void decrement_active_view_count() { active_view_count_--; } | 55 void decrement_active_view_count() { active_view_count_--; } |
55 | 56 |
56 // Get the number of active views which belong to this | 57 // Get the number of active views which belong to this |
57 // SiteInstance. If there is no active view left in this | 58 // SiteInstance. If there is no active view left in this |
58 // SiteInstance, all view in this SiteInstance can be safely | 59 // SiteInstance, all view in this SiteInstance can be safely |
59 // discarded to save memory. | 60 // discarded to save memory. |
60 size_t active_view_count() { return active_view_count_; } | 61 size_t active_view_count() { return active_view_count_; } |
davidben
2014/04/29 17:01:25
Oh, I mentioned this out-of-band, but the reason t
Charlie Reis
2014/04/29 17:31:08
This count is also specific to the SiteInstance an
davidben
2014/04/29 21:31:40
Yeah. Though if that were the only issue, Browsing
| |
61 | 62 |
63 void IncrementRelatedActiveContentsCount(); | |
Charlie Reis
2014/04/29 17:31:08
These need comments explaining that they're for tr
davidben
2014/04/29 21:31:40
Done.
| |
64 void DecrementRelatedActiveContentsCount(); | |
65 | |
62 // Sets the global factory used to create new RenderProcessHosts. It may be | 66 // Sets the global factory used to create new RenderProcessHosts. It may be |
63 // NULL, in which case the default BrowserRenderProcessHost will be created | 67 // NULL, in which case the default BrowserRenderProcessHost will be created |
64 // (this is the behavior if you don't call this function). The factory must | 68 // (this is the behavior if you don't call this function). The factory must |
65 // be set back to NULL before it's destroyed; ownership is not transferred. | 69 // be set back to NULL before it's destroyed; ownership is not transferred. |
66 static void set_render_process_host_factory( | 70 static void set_render_process_host_factory( |
67 const RenderProcessHostFactory* rph_factory); | 71 const RenderProcessHostFactory* rph_factory); |
68 | 72 |
69 // Get the effective URL for the given actual URL. This allows the | 73 // Get the effective URL for the given actual URL. This allows the |
70 // ContentBrowserClient to override the SiteInstance's site for certain URLs. | 74 // ContentBrowserClient to override the SiteInstance's site for certain URLs. |
71 // For example, Chrome uses this to replace hosted app URLs with extension | 75 // For example, Chrome uses this to replace hosted app URLs with extension |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 | 124 |
121 // Whether SetSite has been called. | 125 // Whether SetSite has been called. |
122 bool has_site_; | 126 bool has_site_; |
123 | 127 |
124 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); | 128 DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); |
125 }; | 129 }; |
126 | 130 |
127 } // namespace content | 131 } // namespace content |
128 | 132 |
129 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ | 133 #endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ |
OLD | NEW |