| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/browsing_instance.h" | 5 #include "chrome/browser/browsing_instance.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/browser/renderer_host/site_instance.h" | 9 #include "chrome/browser/renderer_host/site_instance.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( | 47 BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( |
| 48 Profile* profile, const GURL& url) { | 48 Profile* profile, const GURL& url) { |
| 49 if (!ShouldUseProcessPerSite(url)) { | 49 if (!ShouldUseProcessPerSite(url)) { |
| 50 // Not using process-per-site, so use a map specific to this instance. | 50 // Not using process-per-site, so use a map specific to this instance. |
| 51 return &site_instance_map_; | 51 return &site_instance_map_; |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Otherwise, process-per-site is in use, at least for this URL. Look up the | 54 // Otherwise, process-per-site is in use, at least for this URL. Look up the |
| 55 // global map for this profile, creating an entry if necessary. | 55 // global map for this profile, creating an entry if necessary. |
| 56 return &profile_site_instance_map_[profile]; | 56 ProfileId runtime_id = profile ? profile->GetRuntimeId() |
| 57 : Profile::InvalidProfileId; |
| 58 return &profile_site_instance_map_[runtime_id]; |
| 57 } | 59 } |
| 58 | 60 |
| 59 bool BrowsingInstance::HasSiteInstance(const GURL& url) { | 61 bool BrowsingInstance::HasSiteInstance(const GURL& url) { |
| 60 std::string site = SiteInstance::GetSiteForURL(url).possibly_invalid_spec(); | 62 std::string site = SiteInstance::GetSiteForURL(url).possibly_invalid_spec(); |
| 61 | 63 |
| 62 SiteInstanceMap* map = GetSiteInstanceMap(profile_, url); | 64 SiteInstanceMap* map = GetSiteInstanceMap(profile_, url); |
| 63 SiteInstanceMap::iterator i = map->find(site); | 65 SiteInstanceMap::iterator i = map->find(site); |
| 64 return (i != map->end()); | 66 return (i != map->end()); |
| 65 } | 67 } |
| 66 | 68 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Only unregister the SiteInstance if it is the same one that is registered | 109 // Only unregister the SiteInstance if it is the same one that is registered |
| 108 // for the site. (It might have been an unregistered SiteInstance. See the | 110 // for the site. (It might have been an unregistered SiteInstance. See the |
| 109 // comments in RegisterSiteInstance.) | 111 // comments in RegisterSiteInstance.) |
| 110 SiteInstanceMap* map = GetSiteInstanceMap(profile_, site_instance->site()); | 112 SiteInstanceMap* map = GetSiteInstanceMap(profile_, site_instance->site()); |
| 111 SiteInstanceMap::iterator i = map->find(site); | 113 SiteInstanceMap::iterator i = map->find(site); |
| 112 if (i != map->end() && i->second == site_instance) { | 114 if (i != map->end() && i->second == site_instance) { |
| 113 // Matches, so erase it. | 115 // Matches, so erase it. |
| 114 map->erase(i); | 116 map->erase(i); |
| 115 } | 117 } |
| 116 } | 118 } |
| OLD | NEW |