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

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

Issue 701953006: PlzNavigate: Speculatively spawns a renderer process for navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed creis comments. Created 6 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/site_instance_impl.h" 5 #include "content/browser/site_instance_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/browsing_instance.h" 8 #include "content/browser/browsing_instance.h"
9 #include "content/browser/child_process_security_policy_impl.h" 9 #include "content/browser/child_process_security_policy_impl.h"
10 #include "content/browser/frame_host/debug_urls.h" 10 #include "content/browser/frame_host/debug_urls.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 void SiteInstanceImpl::SetSite(const GURL& url) { 135 void SiteInstanceImpl::SetSite(const GURL& url) {
136 TRACE_EVENT2("navigation", "SiteInstanceImpl::SetSite", 136 TRACE_EVENT2("navigation", "SiteInstanceImpl::SetSite",
137 "site id", id_, "url", url.possibly_invalid_spec()); 137 "site id", id_, "url", url.possibly_invalid_spec());
138 // A SiteInstance's site should not change. 138 // A SiteInstance's site should not change.
139 // TODO(creis): When following links or script navigations, we can currently 139 // TODO(creis): When following links or script navigations, we can currently
140 // render pages from other sites in this SiteInstance. This will eventually 140 // render pages from other sites in this SiteInstance. This will eventually
141 // be fixed, but until then, we should still not set the site of a 141 // be fixed, but until then, we should still not set the site of a
142 // SiteInstance more than once. 142 // SiteInstance more than once.
143 DCHECK(!has_site_); 143 DCHECK(!has_site_);
144 DCHECK(!browsing_instance_->HasSiteInstance(url));
144 145
145 // Remember that this SiteInstance has been used to load a URL, even if the 146 // Remember that this SiteInstance has been used to load a URL, even if the
146 // URL is invalid. 147 // URL is invalid.
147 has_site_ = true; 148 has_site_ = true;
148 BrowserContext* browser_context = browsing_instance_->browser_context(); 149 BrowserContext* browser_context = browsing_instance_->browser_context();
149 site_ = GetSiteForURL(browser_context, url); 150 site_ = GetSiteForURL(browser_context, url);
150 151
151 // Now that we have a site, register it with the BrowsingInstance. This 152 // Now that we have a site, register it with the BrowsingInstance. This
152 // ensures that we won't create another SiteInstance for this site within 153 // ensures that we won't create another SiteInstance for this site within
153 // the same BrowsingInstance, because all same-site pages within a 154 // the same BrowsingInstance, because all same-site pages within a
(...skipping 20 matching lines...) Expand all
174 } 175 }
175 176
176 bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) { 177 bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) {
177 return browsing_instance_->HasSiteInstance(url); 178 return browsing_instance_->HasSiteInstance(url);
178 } 179 }
179 180
180 SiteInstance* SiteInstanceImpl::GetRelatedSiteInstance(const GURL& url) { 181 SiteInstance* SiteInstanceImpl::GetRelatedSiteInstance(const GURL& url) {
181 return browsing_instance_->GetSiteInstanceForURL(url); 182 return browsing_instance_->GetSiteInstanceForURL(url);
182 } 183 }
183 184
185 SiteInstance* SiteInstanceImpl::GetRelatedEmptySiteInstance() {
186 return new SiteInstanceImpl(browsing_instance_.get());
187 }
188
184 bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) { 189 bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) {
185 return browsing_instance_.get() == static_cast<const SiteInstanceImpl*>( 190 return browsing_instance_.get() == static_cast<const SiteInstanceImpl*>(
186 instance)->browsing_instance_.get(); 191 instance)->browsing_instance_.get();
187 } 192 }
188 193
189 size_t SiteInstanceImpl::GetRelatedActiveContentsCount() { 194 size_t SiteInstanceImpl::GetRelatedActiveContentsCount() {
190 return browsing_instance_->active_contents_count(); 195 return browsing_instance_->active_contents_count();
191 } 196 }
192 197
193 bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) { 198 bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 *base::CommandLine::ForCurrentProcess(); 350 *base::CommandLine::ForCurrentProcess();
346 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || 351 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) ||
347 command_line.HasSwitch(switches::kSitePerProcess)) { 352 command_line.HasSwitch(switches::kSitePerProcess)) {
348 ChildProcessSecurityPolicyImpl* policy = 353 ChildProcessSecurityPolicyImpl* policy =
349 ChildProcessSecurityPolicyImpl::GetInstance(); 354 ChildProcessSecurityPolicyImpl::GetInstance();
350 policy->LockToOrigin(process_->GetID(), site_); 355 policy->LockToOrigin(process_->GetID(), site_);
351 } 356 }
352 } 357 }
353 358
354 } // namespace content 359 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698