diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-19 01:35:43 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-19 01:35:43 +0000 |
commit | 40bfaf371302706f8613b5bd8ac4bfd7f4c42477 (patch) | |
tree | 8dc28e74a680f52e9d0847fcbd834bf435083c00 /content/browser/site_instance_impl.cc | |
parent | aa08d608e217139a87779cab5b110bb41d440e8a (diff) | |
download | chromium_src-40bfaf371302706f8613b5bd8ac4bfd7f4c42477.zip chromium_src-40bfaf371302706f8613b5bd8ac4bfd7f4c42477.tar.gz chromium_src-40bfaf371302706f8613b5bd8ac4bfd7f4c42477.tar.bz2 |
Introduce RenderProcessHostObserver, use it in its first client.
BUG=170921
TEST=everything still works
Review URL: https://codereview.chromium.org/72203003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235877 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/site_instance_impl.cc')
-rw-r--r-- | content/browser/site_instance_impl.cc | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/content/browser/site_instance_impl.cc b/content/browser/site_instance_impl.cc index 3682e40..29f5a78 100644 --- a/content/browser/site_instance_impl.cc +++ b/content/browser/site_instance_impl.cc @@ -10,8 +10,6 @@ #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/storage_partition_impl.h" #include "content/public/browser/content_browser_client.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_types.h" #include "content/public/browser/render_process_host_factory.h" #include "content/public/browser/web_ui_controller_factory.h" #include "content/public/common/content_switches.h" @@ -46,14 +44,14 @@ SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) process_(NULL), has_site_(false) { DCHECK(browsing_instance); - - registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_TERMINATED, - NotificationService::AllBrowserContextsAndSources()); } SiteInstanceImpl::~SiteInstanceImpl() { GetContentClient()->browser()->SiteInstanceDeleting(this); + if (process_) + process_->RemoveObserver(this); + // Now that no one is referencing us, we can safely remove ourselves from // the BrowsingInstance. Any future visits to a page from this site // (within the same BrowsingInstance) can safely create a new SiteInstance. @@ -129,6 +127,7 @@ RenderProcessHost* SiteInstanceImpl::GetProcess() { } } CHECK(process_); + process_->AddObserver(this); // If we are using process-per-site, we need to register this process // for the current site so that we can find it again. (If no site is set @@ -326,13 +325,10 @@ GURL SiteInstanceImpl::GetEffectiveURL(BrowserContext* browser_context, GetEffectiveURL(browser_context, url); } -void SiteInstanceImpl::Observe(int type, - const NotificationSource& source, - const NotificationDetails& details) { - DCHECK(type == NOTIFICATION_RENDERER_PROCESS_TERMINATED); - RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); - if (rph == process_) - process_ = NULL; +void SiteInstanceImpl::RenderProcessHostDestroyed(RenderProcessHost* host) { + DCHECK_EQ(process_, host); + process_->RemoveObserver(this); + process_ = NULL; } void SiteInstanceImpl::LockToOrigin() { |