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 "base/logging.h" |
8 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
9 #include "chrome/browser/renderer_host/site_instance.h" | 10 #include "chrome/browser/renderer_host/site_instance.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
12 | 13 |
13 /*static*/ | 14 /*static*/ |
14 BrowsingInstance::ProfileSiteInstanceMap | 15 BrowsingInstance::ProfileSiteInstanceMap |
15 BrowsingInstance::profile_site_instance_map_; | 16 BrowsingInstance::profile_site_instance_map_; |
16 | 17 |
| 18 BrowsingInstance::BrowsingInstance(Profile* profile) |
| 19 : profile_(profile) { |
| 20 } |
| 21 |
17 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { | 22 bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { |
18 // Returns true if we should use the process-per-site model. This will be | 23 // Returns true if we should use the process-per-site model. This will be |
19 // the case if the --process-per-site switch is specified, or in | 24 // the case if the --process-per-site switch is specified, or in |
20 // process-per-site-instance for particular sites (e.g., the new tab page). | 25 // process-per-site-instance for particular sites (e.g., the new tab page). |
21 | 26 |
22 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 27 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
23 if (command_line.HasSwitch(switches::kProcessPerSite)) | 28 if (command_line.HasSwitch(switches::kProcessPerSite)) |
24 return true; | 29 return true; |
25 | 30 |
26 if (url.SchemeIs(chrome::kExtensionScheme)) { | 31 if (url.SchemeIs(chrome::kExtensionScheme)) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // Only unregister the SiteInstance if it is the same one that is registered | 121 // Only unregister the SiteInstance if it is the same one that is registered |
117 // for the site. (It might have been an unregistered SiteInstance. See the | 122 // for the site. (It might have been an unregistered SiteInstance. See the |
118 // comments in RegisterSiteInstance.) | 123 // comments in RegisterSiteInstance.) |
119 SiteInstanceMap* map = GetSiteInstanceMap(profile_, site_instance->site()); | 124 SiteInstanceMap* map = GetSiteInstanceMap(profile_, site_instance->site()); |
120 SiteInstanceMap::iterator i = map->find(site); | 125 SiteInstanceMap::iterator i = map->find(site); |
121 if (i != map->end() && i->second == site_instance) { | 126 if (i != map->end() && i->second == site_instance) { |
122 // Matches, so erase it. | 127 // Matches, so erase it. |
123 map->erase(i); | 128 map->erase(i); |
124 } | 129 } |
125 } | 130 } |
| 131 |
| 132 BrowsingInstance::~BrowsingInstance() { |
| 133 // We should only be deleted when all of the SiteInstances that refer to |
| 134 // us are gone. |
| 135 DCHECK(site_instance_map_.empty()); |
| 136 } |
OLD | NEW |