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

Side by Side Diff: content/browser/browsing_instance.cc

Issue 9221017: Hide BrowsingInstance from all but SiteInstance, as intended by design. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/browsing_instance.h ('k') | content/browser/debugger/devtools_manager_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/browser/browsing_instance.h" 5 #include "content/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 "base/logging.h"
9 #include "content/browser/site_instance.h" 9 #include "content/browser/site_instance.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 // No current SiteInstance for this site, so let's create one. 91 // No current SiteInstance for this site, so let's create one.
92 SiteInstance* instance = new SiteInstance(this); 92 SiteInstance* instance = new SiteInstance(this);
93 93
94 // Set the site of this new SiteInstance, which will register it with us. 94 // Set the site of this new SiteInstance, which will register it with us.
95 instance->SetSite(url); 95 instance->SetSite(url);
96 return instance; 96 return instance;
97 } 97 }
98 98
99 void BrowsingInstance::RegisterSiteInstance(SiteInstance* site_instance) { 99 void BrowsingInstance::RegisterSiteInstance(SiteInstance* site_instance) {
100 DCHECK(site_instance->browsing_instance() == this); 100 DCHECK(site_instance->browsing_instance_ == this);
101 DCHECK(site_instance->has_site()); 101 DCHECK(site_instance->has_site());
102 std::string site = site_instance->site().possibly_invalid_spec(); 102 std::string site = site_instance->site().possibly_invalid_spec();
103 103
104 // Only register if we don't have a SiteInstance for this site already. 104 // Only register if we don't have a SiteInstance for this site already.
105 // It's possible to have two SiteInstances point to the same site if two 105 // It's possible to have two SiteInstances point to the same site if two
106 // tabs are navigated there at the same time. (We don't call SetSite or 106 // tabs are navigated there at the same time. (We don't call SetSite or
107 // register them until DidNavigate.) If there is a previously existing 107 // register them until DidNavigate.) If there is a previously existing
108 // SiteInstance for this site, we just won't register the new one. 108 // SiteInstance for this site, we just won't register the new one.
109 SiteInstanceMap* map = GetSiteInstanceMap(browser_context_, 109 SiteInstanceMap* map = GetSiteInstanceMap(browser_context_,
110 site_instance->site()); 110 site_instance->site());
111 SiteInstanceMap::iterator i = map->find(site); 111 SiteInstanceMap::iterator i = map->find(site);
112 if (i == map->end()) { 112 if (i == map->end()) {
113 // Not previously registered, so register it. 113 // Not previously registered, so register it.
114 (*map)[site] = site_instance; 114 (*map)[site] = site_instance;
115 } 115 }
116 } 116 }
117 117
118 void BrowsingInstance::UnregisterSiteInstance(SiteInstance* site_instance) { 118 void BrowsingInstance::UnregisterSiteInstance(SiteInstance* site_instance) {
119 DCHECK(site_instance->browsing_instance() == this); 119 DCHECK(site_instance->browsing_instance_ == this);
120 DCHECK(site_instance->has_site()); 120 DCHECK(site_instance->has_site());
121 std::string site = site_instance->site().possibly_invalid_spec(); 121 std::string site = site_instance->site().possibly_invalid_spec();
122 122
123 // Only unregister the SiteInstance if it is the same one that is registered 123 // Only unregister the SiteInstance if it is the same one that is registered
124 // for the site. (It might have been an unregistered SiteInstance. See the 124 // for the site. (It might have been an unregistered SiteInstance. See the
125 // comments in RegisterSiteInstance.) 125 // comments in RegisterSiteInstance.)
126 126
127 // We look for the site instance in both the local site_instance_map_ and also 127 // We look for the site instance in both the local site_instance_map_ and also
128 // the static context_site_instance_map_ - this is because the logic in 128 // the static context_site_instance_map_ - this is because the logic in
129 // ShouldUseProcessPerSite() can produce different results over the lifetime 129 // ShouldUseProcessPerSite() can produce different results over the lifetime
(...skipping 19 matching lines...) Expand all
149 return true; 149 return true;
150 } 150 }
151 return false; 151 return false;
152 } 152 }
153 153
154 BrowsingInstance::~BrowsingInstance() { 154 BrowsingInstance::~BrowsingInstance() {
155 // We should only be deleted when all of the SiteInstances that refer to 155 // We should only be deleted when all of the SiteInstances that refer to
156 // us are gone. 156 // us are gone.
157 DCHECK(site_instance_map_.empty()); 157 DCHECK(site_instance_map_.empty());
158 } 158 }
OLDNEW
« no previous file with comments | « content/browser/browsing_instance.h ('k') | content/browser/debugger/devtools_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698