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_BROWSING_INSTANCE_H_ | 5 #ifndef CONTENT_BROWSER_BROWSING_INSTANCE_H_ |
6 #define CONTENT_BROWSER_BROWSING_INSTANCE_H_ | 6 #define CONTENT_BROWSER_BROWSING_INSTANCE_H_ |
7 | 7 |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 // Adds the given SiteInstance to our map, to ensure that we do not create | 72 // Adds the given SiteInstance to our map, to ensure that we do not create |
73 // another SiteInstance for the same site. | 73 // another SiteInstance for the same site. |
74 void RegisterSiteInstance(SiteInstance* site_instance); | 74 void RegisterSiteInstance(SiteInstance* site_instance); |
75 | 75 |
76 // Removes the given SiteInstance from our map, after all references to it | 76 // Removes the given SiteInstance from our map, after all references to it |
77 // have been deleted. This means it is safe to create a new SiteInstance | 77 // have been deleted. This means it is safe to create a new SiteInstance |
78 // if the user later visits a page from this site, within this | 78 // if the user later visits a page from this site, within this |
79 // BrowsingInstance. | 79 // BrowsingInstance. |
80 void UnregisterSiteInstance(SiteInstance* site_instance); | 80 void UnregisterSiteInstance(SiteInstance* site_instance); |
81 | 81 |
82 size_t active_contents_count() const { return active_contents_count_; } | |
83 void increment_active_contents_count() { active_contents_count_++; } | |
84 void decrement_active_contents_count() { active_contents_count_--; } | |
85 | |
82 friend class SiteInstanceImpl; | 86 friend class SiteInstanceImpl; |
83 friend class SiteInstance; | 87 friend class SiteInstance; |
84 | 88 |
85 friend class base::RefCounted<BrowsingInstance>; | 89 friend class base::RefCounted<BrowsingInstance>; |
86 | 90 |
87 // Virtual to allow tests to extend it. | 91 // Virtual to allow tests to extend it. |
88 virtual ~BrowsingInstance(); | 92 virtual ~BrowsingInstance(); |
89 | 93 |
90 private: | 94 private: |
91 // Map of site to SiteInstance, to ensure we only have one SiteInstance per | 95 // Map of site to SiteInstance, to ensure we only have one SiteInstance per |
96 // site. | |
Charlie Reis
2014/04/29 17:31:08
Oops, wonder how that got deleted. (Looks like it
| |
92 typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap; | 97 typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap; |
93 | 98 |
94 // Common browser context to which all SiteInstances in this BrowsingInstance | 99 // Common browser context to which all SiteInstances in this BrowsingInstance |
95 // must belong. | 100 // must belong. |
96 BrowserContext* const browser_context_; | 101 BrowserContext* const browser_context_; |
97 | 102 |
98 // Map of site to SiteInstance, to ensure we only have one SiteInstance per | 103 // Map of site to SiteInstance, to ensure we only have one SiteInstance per |
99 // site. The site string should be the possibly_invalid_spec() of a GURL | 104 // site. The site string should be the possibly_invalid_spec() of a GURL |
100 // obtained with SiteInstanceImpl::GetSiteForURL. Note that this map may not | 105 // obtained with SiteInstanceImpl::GetSiteForURL. Note that this map may not |
101 // contain every active SiteInstance, because a race exists where two | 106 // contain every active SiteInstance, because a race exists where two |
102 // SiteInstances can be assigned to the same site. This is ok in rare cases. | 107 // SiteInstances can be assigned to the same site. This is ok in rare cases. |
108 // It also does not contain SiteInstances which have not yet been assigned a | |
109 // site, such as about:blank. See NavigatorImpl::ShouldAssignSiteForURL. | |
103 SiteInstanceMap site_instance_map_; | 110 SiteInstanceMap site_instance_map_; |
104 | 111 |
112 // Number of WebContentses currently on this SiteInstance. | |
Charlie Reis
2014/04/29 17:31:08
on this SiteInstance -> in this BrowsingInstance
davidben
2014/04/29 21:31:40
Done.
| |
113 size_t active_contents_count_; | |
114 | |
105 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance); | 115 DISALLOW_COPY_AND_ASSIGN(BrowsingInstance); |
106 }; | 116 }; |
107 | 117 |
108 } // namespace content | 118 } // namespace content |
109 | 119 |
110 #endif // CONTENT_BROWSER_BROWSING_INSTANCE_H_ | 120 #endif // CONTENT_BROWSER_BROWSING_INSTANCE_H_ |
OLD | NEW |