diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 20:58:20 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 20:58:20 +0000 |
commit | 489768a06749567cee515269ab5a60f6069d1fc2 (patch) | |
tree | 798c9ea4127007692f205052c702fb4cfab37e38 | |
parent | 4875dd23b3b870a1261bdc85a00b3e56ca0a7b94 (diff) | |
download | chromium_src-489768a06749567cee515269ab5a60f6069d1fc2.zip chromium_src-489768a06749567cee515269ab5a60f6069d1fc2.tar.gz chromium_src-489768a06749567cee515269ab5a60f6069d1fc2.tar.bz2 |
Fixed UnregisterSiteInstance() to look in both maps.
BrowsingInstance::UnregisterSiteInstance() now removes the SiteInstance
from both the local instance SiteInstanceMap and the static per-profile map.
BUG=58342
TEST=none
Review URL: http://codereview.chromium.org/3781007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62646 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browsing_instance.cc | 22 | ||||
-rw-r--r-- | chrome/browser/browsing_instance.h | 5 |
2 files changed, 26 insertions, 1 deletions
diff --git a/chrome/browser/browsing_instance.cc b/chrome/browser/browsing_instance.cc index ec433b7..e3d436bfa 100644 --- a/chrome/browser/browsing_instance.cc +++ b/chrome/browser/browsing_instance.cc @@ -121,12 +121,32 @@ void BrowsingInstance::UnregisterSiteInstance(SiteInstance* site_instance) { // Only unregister the SiteInstance if it is the same one that is registered // for the site. (It might have been an unregistered SiteInstance. See the // comments in RegisterSiteInstance.) - SiteInstanceMap* map = GetSiteInstanceMap(profile_, site_instance->site()); + + // We look for the site instance in both the local site_instance_map_ and also + // the static profile_site_instance_map_ - this is because the logic in + // ShouldUseProcessPerSite() can produce different results over the lifetime + // of Chrome (e.g. installation of apps with web extents can change our + // process-per-site policy for a given domain), so we don't know which map + // the site was put into when it was originally registered. + if (!RemoveSiteInstanceFromMap(&site_instance_map_, site, site_instance)) { + // Wasn't in our local map, so look in the static per-profile map. + ProfileId runtime_id = profile_ ? profile_->GetRuntimeId() + : Profile::InvalidProfileId; + RemoveSiteInstanceFromMap( + &profile_site_instance_map_[runtime_id], site, site_instance); + } +} + +bool BrowsingInstance::RemoveSiteInstanceFromMap(SiteInstanceMap* map, + const std::string& site, + SiteInstance* site_instance) { SiteInstanceMap::iterator i = map->find(site); if (i != map->end() && i->second == site_instance) { // Matches, so erase it. map->erase(i); + return true; } + return false; } BrowsingInstance::~BrowsingInstance() { diff --git a/chrome/browser/browsing_instance.h b/chrome/browser/browsing_instance.h index fa4ce49..58b7846 100644 --- a/chrome/browser/browsing_instance.h +++ b/chrome/browser/browsing_instance.h @@ -109,6 +109,11 @@ class BrowsingInstance : public base::RefCounted<BrowsingInstance> { // SiteInstanceMap. SiteInstanceMap* GetSiteInstanceMap(Profile* profile, const GURL& url); + // Utility routine which removes the passed SiteInstance from the passed + // SiteInstanceMap. + bool RemoveSiteInstanceFromMap(SiteInstanceMap* map, const std::string& site, + SiteInstance* site_instance); + // Common profile to which all SiteInstances in this BrowsingInstance // must belong. Profile* const profile_; |