| OLD | NEW |
| 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 "content/browser/browsing_instance.h" | 7 #include "content/browser/browsing_instance.h" |
| 8 #include "content/browser/child_process_security_policy_impl.h" | 8 #include "content/browser/child_process_security_policy_impl.h" |
| 9 #include "content/browser/frame_host/debug_urls.h" | 9 #include "content/browser/frame_host/debug_urls.h" |
| 10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
| 11 #include "content/browser/renderer_host/render_process_host_impl.h" | 11 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 12 #include "content/browser/storage_partition_impl.h" | 12 #include "content/browser/storage_partition_impl.h" |
| 13 #include "content/common/site_isolation_policy.h" | 13 #include "content/common/site_isolation_policy.h" |
| 14 #include "content/public/browser/content_browser_client.h" | 14 #include "content/public/browser/content_browser_client.h" |
| 15 #include "content/public/browser/render_process_host_factory.h" | 15 #include "content/public/browser/render_process_host_factory.h" |
| 16 #include "content/public/browser/web_ui_controller_factory.h" | 16 #include "content/public/browser/web_ui_controller_factory.h" |
| 17 #include "content/public/common/url_constants.h" | 17 #include "content/public/common/url_constants.h" |
| 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 18 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 const RenderProcessHostFactory* | 22 const RenderProcessHostFactory* |
| 23 SiteInstanceImpl::g_render_process_host_factory_ = NULL; | 23 SiteInstanceImpl::g_render_process_host_factory_ = NULL; |
| 24 int32_t SiteInstanceImpl::next_site_instance_id_ = 1; | 24 int32_t SiteInstanceImpl::next_site_instance_id_ = 1; |
| 25 | 25 |
| 26 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) | 26 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) |
| 27 : id_(next_site_instance_id_++), | 27 : id_(next_site_instance_id_++), |
| 28 active_frame_count_(0), | 28 active_frame_count_(0), |
| 29 browsing_instance_(browsing_instance), | 29 browsing_instance_(browsing_instance), |
| 30 process_(NULL), | 30 process_(nullptr), |
| 31 has_site_(false) { | 31 has_site_(false), |
| 32 is_default_subframe_site_instance_(false) { |
| 32 DCHECK(browsing_instance); | 33 DCHECK(browsing_instance); |
| 33 } | 34 } |
| 34 | 35 |
| 35 SiteInstanceImpl::~SiteInstanceImpl() { | 36 SiteInstanceImpl::~SiteInstanceImpl() { |
| 36 GetContentClient()->browser()->SiteInstanceDeleting(this); | 37 GetContentClient()->browser()->SiteInstanceDeleting(this); |
| 37 | 38 |
| 38 if (process_) | 39 if (process_) |
| 39 process_->RemoveObserver(this); | 40 process_->RemoveObserver(this); |
| 40 | 41 |
| 41 // Now that no one is referencing us, we can safely remove ourselves from | 42 // Now that no one is referencing us, we can safely remove ourselves from |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 if (IsRendererDebugURL(url)) | 220 if (IsRendererDebugURL(url)) |
| 220 return false; | 221 return false; |
| 221 | 222 |
| 222 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the | 223 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the |
| 223 // process is not (or vice versa), make sure we notice and fix it. | 224 // process is not (or vice versa), make sure we notice and fix it. |
| 224 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); | 225 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); |
| 225 return !RenderProcessHostImpl::IsSuitableHost( | 226 return !RenderProcessHostImpl::IsSuitableHost( |
| 226 GetProcess(), browsing_instance_->browser_context(), site_url); | 227 GetProcess(), browsing_instance_->browser_context(), site_url); |
| 227 } | 228 } |
| 228 | 229 |
| 230 scoped_refptr<SiteInstanceImpl> |
| 231 SiteInstanceImpl::GetDefaultSubframeSiteInstance() { |
| 232 return browsing_instance_->GetDefaultSubframeSiteInstance(); |
| 233 } |
| 234 |
| 229 bool SiteInstanceImpl::RequiresDedicatedProcess() { | 235 bool SiteInstanceImpl::RequiresDedicatedProcess() { |
| 230 if (!has_site_) | 236 if (!has_site_) |
| 231 return false; | 237 return false; |
| 232 return SiteInstanceImpl::DoesSiteRequireDedicatedProcess(GetBrowserContext(), | 238 |
| 233 site_); | 239 return DoesSiteRequireDedicatedProcess(GetBrowserContext(), site_); |
| 234 } | 240 } |
| 235 | 241 |
| 236 void SiteInstanceImpl::IncrementActiveFrameCount() { | 242 void SiteInstanceImpl::IncrementActiveFrameCount() { |
| 237 active_frame_count_++; | 243 active_frame_count_++; |
| 238 } | 244 } |
| 239 | 245 |
| 240 void SiteInstanceImpl::DecrementActiveFrameCount() { | 246 void SiteInstanceImpl::DecrementActiveFrameCount() { |
| 241 if (--active_frame_count_ == 0) | 247 if (--active_frame_count_ == 0) |
| 242 FOR_EACH_OBSERVER(Observer, observers_, ActiveFrameCountIsZero(this)); | 248 FOR_EACH_OBSERVER(Observer, observers_, ActiveFrameCountIsZero(this)); |
| 243 } | 249 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 browser_context, effective_url)) { | 392 browser_context, effective_url)) { |
| 387 return true; | 393 return true; |
| 388 } | 394 } |
| 389 | 395 |
| 390 return false; | 396 return false; |
| 391 } | 397 } |
| 392 | 398 |
| 393 void SiteInstanceImpl::RenderProcessHostDestroyed(RenderProcessHost* host) { | 399 void SiteInstanceImpl::RenderProcessHostDestroyed(RenderProcessHost* host) { |
| 394 DCHECK_EQ(process_, host); | 400 DCHECK_EQ(process_, host); |
| 395 process_->RemoveObserver(this); | 401 process_->RemoveObserver(this); |
| 396 process_ = NULL; | 402 process_ = nullptr; |
| 397 } | 403 } |
| 398 | 404 |
| 399 void SiteInstanceImpl::RenderProcessWillExit(RenderProcessHost* host) { | 405 void SiteInstanceImpl::RenderProcessWillExit(RenderProcessHost* host) { |
| 400 // TODO(nick): http://crbug.com/575400 - RenderProcessWillExit might not serve | 406 // TODO(nick): http://crbug.com/575400 - RenderProcessWillExit might not serve |
| 401 // any purpose here. | 407 // any purpose here. |
| 402 FOR_EACH_OBSERVER(Observer, observers_, RenderProcessGone(this)); | 408 FOR_EACH_OBSERVER(Observer, observers_, RenderProcessGone(this)); |
| 403 } | 409 } |
| 404 | 410 |
| 405 void SiteInstanceImpl::RenderProcessExited(RenderProcessHost* host, | 411 void SiteInstanceImpl::RenderProcessExited(RenderProcessHost* host, |
| 406 base::TerminationStatus status, | 412 base::TerminationStatus status, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 436 browsing_instance_->browser_context(), site_)) | 442 browsing_instance_->browser_context(), site_)) |
| 437 return; | 443 return; |
| 438 | 444 |
| 439 ChildProcessSecurityPolicyImpl* policy = | 445 ChildProcessSecurityPolicyImpl* policy = |
| 440 ChildProcessSecurityPolicyImpl::GetInstance(); | 446 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 441 policy->LockToOrigin(process_->GetID(), site_); | 447 policy->LockToOrigin(process_->GetID(), site_); |
| 442 } | 448 } |
| 443 } | 449 } |
| 444 | 450 |
| 445 } // namespace content | 451 } // namespace content |
| OLD | NEW |