| 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/renderer_host/render_process_host_impl.h" | 10 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 11 #include "content/browser/storage_partition_impl.h" | 11 #include "content/browser/storage_partition_impl.h" |
| 12 #include "content/common/site_isolation_policy.h" | 12 #include "content/common/site_isolation_policy.h" |
| 13 #include "content/public/browser/content_browser_client.h" | 13 #include "content/public/browser/content_browser_client.h" |
| 14 #include "content/public/browser/render_process_host_factory.h" | 14 #include "content/public/browser/render_process_host_factory.h" |
| 15 #include "content/public/browser/web_ui_controller_factory.h" | 15 #include "content/public/browser/web_ui_controller_factory.h" |
| 16 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
| 17 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 17 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 const RenderProcessHostFactory* | 21 const RenderProcessHostFactory* |
| 22 SiteInstanceImpl::g_render_process_host_factory_ = NULL; | 22 SiteInstanceImpl::g_render_process_host_factory_ = NULL; |
| 23 int32 SiteInstanceImpl::next_site_instance_id_ = 1; | 23 int32_t SiteInstanceImpl::next_site_instance_id_ = 1; |
| 24 | 24 |
| 25 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) | 25 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) |
| 26 : id_(next_site_instance_id_++), | 26 : id_(next_site_instance_id_++), |
| 27 active_frame_count_(0), | 27 active_frame_count_(0), |
| 28 browsing_instance_(browsing_instance), | 28 browsing_instance_(browsing_instance), |
| 29 process_(NULL), | 29 process_(NULL), |
| 30 has_site_(false) { | 30 has_site_(false) { |
| 31 DCHECK(browsing_instance); | 31 DCHECK(browsing_instance); |
| 32 } | 32 } |
| 33 | 33 |
| 34 SiteInstanceImpl::~SiteInstanceImpl() { | 34 SiteInstanceImpl::~SiteInstanceImpl() { |
| 35 GetContentClient()->browser()->SiteInstanceDeleting(this); | 35 GetContentClient()->browser()->SiteInstanceDeleting(this); |
| 36 | 36 |
| 37 if (process_) | 37 if (process_) |
| 38 process_->RemoveObserver(this); | 38 process_->RemoveObserver(this); |
| 39 | 39 |
| 40 // Now that no one is referencing us, we can safely remove ourselves from | 40 // Now that no one is referencing us, we can safely remove ourselves from |
| 41 // the BrowsingInstance. Any future visits to a page from this site | 41 // the BrowsingInstance. Any future visits to a page from this site |
| 42 // (within the same BrowsingInstance) can safely create a new SiteInstance. | 42 // (within the same BrowsingInstance) can safely create a new SiteInstance. |
| 43 if (has_site_) | 43 if (has_site_) |
| 44 browsing_instance_->UnregisterSiteInstance( | 44 browsing_instance_->UnregisterSiteInstance( |
| 45 static_cast<SiteInstance*>(this)); | 45 static_cast<SiteInstance*>(this)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 int32 SiteInstanceImpl::GetId() { | 48 int32_t SiteInstanceImpl::GetId() { |
| 49 return id_; | 49 return id_; |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool SiteInstanceImpl::HasProcess() const { | 52 bool SiteInstanceImpl::HasProcess() const { |
| 53 if (process_ != NULL) | 53 if (process_ != NULL) |
| 54 return true; | 54 return true; |
| 55 | 55 |
| 56 // If we would use process-per-site for this site, also check if there is an | 56 // If we would use process-per-site for this site, also check if there is an |
| 57 // existing process that we would use if GetProcess() were called. | 57 // existing process that we would use if GetProcess() were called. |
| 58 BrowserContext* browser_context = | 58 BrowserContext* browser_context = |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 browsing_instance_->browser_context(), site_)) | 392 browsing_instance_->browser_context(), site_)) |
| 393 return; | 393 return; |
| 394 | 394 |
| 395 ChildProcessSecurityPolicyImpl* policy = | 395 ChildProcessSecurityPolicyImpl* policy = |
| 396 ChildProcessSecurityPolicyImpl::GetInstance(); | 396 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 397 policy->LockToOrigin(process_->GetID(), site_); | 397 policy->LockToOrigin(process_->GetID(), site_); |
| 398 } | 398 } |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace content | 401 } // namespace content |
| OLD | NEW |