Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Unified Diff: content/browser/browsing_instance.h

Issue 257083002: Check BrowsingInstance before swapping prerenders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/prerender/prerender_manager.cc ('k') | content/browser/browsing_instance.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browsing_instance.h
diff --git a/content/browser/browsing_instance.h b/content/browser/browsing_instance.h
index 60aa47b19dce5608f3c547d956157a3f42570f16..60518b07c4d9e9191478b3ae31404b81c976bea9 100644
--- a/content/browser/browsing_instance.h
+++ b/content/browser/browsing_instance.h
@@ -7,6 +7,7 @@
#include "base/containers/hash_tables.h"
#include "base/lazy_instance.h"
+#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
#include "content/public/browser/browser_context.h"
@@ -79,6 +80,14 @@ class CONTENT_EXPORT BrowsingInstance
// BrowsingInstance.
void UnregisterSiteInstance(SiteInstance* site_instance);
+ // Tracks the number of WebContents currently in this BrowsingInstance.
+ size_t active_contents_count() const { return active_contents_count_; }
+ void increment_active_contents_count() { active_contents_count_++; }
+ void decrement_active_contents_count() {
+ DCHECK_LT(0u, active_contents_count_);
+ active_contents_count_--;
+ }
+
friend class SiteInstanceImpl;
friend class SiteInstance;
@@ -89,6 +98,7 @@ class CONTENT_EXPORT BrowsingInstance
private:
// Map of site to SiteInstance, to ensure we only have one SiteInstance per
+ // site.
typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap;
// Common browser context to which all SiteInstances in this BrowsingInstance
@@ -100,8 +110,13 @@ class CONTENT_EXPORT BrowsingInstance
// obtained with SiteInstanceImpl::GetSiteForURL. Note that this map may not
// contain every active SiteInstance, because a race exists where two
// SiteInstances can be assigned to the same site. This is ok in rare cases.
+ // It also does not contain SiteInstances which have not yet been assigned a
+ // site, such as about:blank. See NavigatorImpl::ShouldAssignSiteForURL.
SiteInstanceMap site_instance_map_;
+ // Number of WebContentses currently using this BrowsingInstance.
+ size_t active_contents_count_;
+
DISALLOW_COPY_AND_ASSIGN(BrowsingInstance);
};
« no previous file with comments | « chrome/browser/prerender/prerender_manager.cc ('k') | content/browser/browsing_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698