| 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_++), browsing_instance_(browsing_instance) { |
| 28 active_frame_count_(0), | |
| 29 browsing_instance_(browsing_instance), | |
| 30 process_(NULL), | |
| 31 has_site_(false) { | |
| 32 DCHECK(browsing_instance); | 28 DCHECK(browsing_instance); |
| 33 } | 29 } |
| 34 | 30 |
| 35 SiteInstanceImpl::~SiteInstanceImpl() { | 31 SiteInstanceImpl::~SiteInstanceImpl() { |
| 36 GetContentClient()->browser()->SiteInstanceDeleting(this); | 32 GetContentClient()->browser()->SiteInstanceDeleting(this); |
| 37 | 33 |
| 38 if (process_) | 34 if (process_) |
| 39 process_->RemoveObserver(this); | 35 process_->RemoveObserver(this); |
| 40 | 36 |
| 41 // Now that no one is referencing us, we can safely remove ourselves from | 37 // Now that no one is referencing us, we can safely remove ourselves from |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (IsRendererDebugURL(url)) | 200 if (IsRendererDebugURL(url)) |
| 205 return false; | 201 return false; |
| 206 | 202 |
| 207 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the | 203 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the |
| 208 // process is not (or vice versa), make sure we notice and fix it. | 204 // process is not (or vice versa), make sure we notice and fix it. |
| 209 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); | 205 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); |
| 210 return !RenderProcessHostImpl::IsSuitableHost( | 206 return !RenderProcessHostImpl::IsSuitableHost( |
| 211 GetProcess(), browsing_instance_->browser_context(), site_url); | 207 GetProcess(), browsing_instance_->browser_context(), site_url); |
| 212 } | 208 } |
| 213 | 209 |
| 210 SiteInstance* SiteInstanceImpl::GetDefaultSubframeSiteInstance() { |
| 211 return browsing_instance_->GetDefaultSubframeSiteInstance(); |
| 212 } |
| 213 |
| 214 bool SiteInstanceImpl::RequiresDedicatedProcess() { | 214 bool SiteInstanceImpl::RequiresDedicatedProcess() { |
| 215 if (!has_site_) | 215 if (!has_site_) |
| 216 return false; | 216 return false; |
| 217 return SiteInstanceImpl::DoesSiteRequireDedicatedProcess(GetBrowserContext(), | 217 |
| 218 site_); | 218 return DoesSiteRequireDedicatedProcess(GetBrowserContext(), site_); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void SiteInstanceImpl::IncrementActiveFrameCount() { | 221 void SiteInstanceImpl::IncrementActiveFrameCount() { |
| 222 active_frame_count_++; | 222 active_frame_count_++; |
| 223 } | 223 } |
| 224 | 224 |
| 225 void SiteInstanceImpl::DecrementActiveFrameCount() { | 225 void SiteInstanceImpl::DecrementActiveFrameCount() { |
| 226 if (--active_frame_count_ == 0) | 226 if (--active_frame_count_ == 0) |
| 227 FOR_EACH_OBSERVER(Observer, observers_, ActiveFrameCountIsZero(this)); | 227 FOR_EACH_OBSERVER(Observer, observers_, ActiveFrameCountIsZero(this)); |
| 228 } | 228 } |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 browser_context, effective_url)) { | 372 browser_context, effective_url)) { |
| 373 return true; | 373 return true; |
| 374 } | 374 } |
| 375 | 375 |
| 376 return false; | 376 return false; |
| 377 } | 377 } |
| 378 | 378 |
| 379 void SiteInstanceImpl::RenderProcessHostDestroyed(RenderProcessHost* host) { | 379 void SiteInstanceImpl::RenderProcessHostDestroyed(RenderProcessHost* host) { |
| 380 DCHECK_EQ(process_, host); | 380 DCHECK_EQ(process_, host); |
| 381 process_->RemoveObserver(this); | 381 process_->RemoveObserver(this); |
| 382 process_ = NULL; | 382 process_ = nullptr; |
| 383 } | 383 } |
| 384 | 384 |
| 385 void SiteInstanceImpl::RenderProcessWillExit(RenderProcessHost* host) { | 385 void SiteInstanceImpl::RenderProcessWillExit(RenderProcessHost* host) { |
| 386 // TODO(nick): http://crbug.com/575400 - RenderProcessWillExit might not serve | 386 // TODO(nick): http://crbug.com/575400 - RenderProcessWillExit might not serve |
| 387 // any purpose here. | 387 // any purpose here. |
| 388 FOR_EACH_OBSERVER(Observer, observers_, RenderProcessGone(this)); | 388 FOR_EACH_OBSERVER(Observer, observers_, RenderProcessGone(this)); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void SiteInstanceImpl::RenderProcessExited(RenderProcessHost* host, | 391 void SiteInstanceImpl::RenderProcessExited(RenderProcessHost* host, |
| 392 base::TerminationStatus status, | 392 base::TerminationStatus status, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 422 browsing_instance_->browser_context(), site_)) | 422 browsing_instance_->browser_context(), site_)) |
| 423 return; | 423 return; |
| 424 | 424 |
| 425 ChildProcessSecurityPolicyImpl* policy = | 425 ChildProcessSecurityPolicyImpl* policy = |
| 426 ChildProcessSecurityPolicyImpl::GetInstance(); | 426 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 427 policy->LockToOrigin(process_->GetID(), site_); | 427 policy->LockToOrigin(process_->GetID(), site_); |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 | 430 |
| 431 } // namespace content | 431 } // namespace content |
| OLD | NEW |