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

Unified Diff: chrome/browser/tab_contents/site_instance.cc

Issue 42054: Stop using renderer specific host ids in ResourceDispatcher. This allows it ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tab_contents/site_instance.h ('k') | chrome/browser/tab_contents/web_contents.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/site_instance.cc
===================================================================
--- chrome/browser/tab_contents/site_instance.cc (revision 11493)
+++ chrome/browser/tab_contents/site_instance.cc (working copy)
@@ -6,48 +6,58 @@
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/common/url_constants.h"
+#include "chrome/common/notification_service.h"
#include "net/base/registry_controlled_domain.h"
+SiteInstance::SiteInstance(BrowsingInstance* browsing_instance)
+ : browsing_instance_(browsing_instance),
+ render_process_host_factory_(NULL),
+ process_(NULL),
+ max_page_id_(-1),
+ has_site_(false) {
+ DCHECK(browsing_instance);
+
+ NotificationService::current()->AddObserver(this,
+ NotificationType::RENDERER_PROCESS_TERMINATED,
+ NotificationService::AllSources());
+}
+
SiteInstance::~SiteInstance() {
// 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.
if (has_site_)
browsing_instance_->UnregisterSiteInstance(this);
+
+ NotificationService::current()->RemoveObserver(this,
+ NotificationType::RENDERER_PROCESS_TERMINATED,
+ NotificationService::AllSources());
}
RenderProcessHost* SiteInstance::GetProcess() {
- RenderProcessHost* process = NULL;
- if (process_host_id_ != -1)
- process = RenderProcessHost::FromID(process_host_id_);
-
// Create a new process if ours went away or was reused.
- if (!process) {
+ if (!process_) {
// See if we should reuse an old process
if (RenderProcessHost::ShouldTryToUseExistingProcessHost())
- process = RenderProcessHost::GetExistingProcessHost(
+ process_ = RenderProcessHost::GetExistingProcessHost(
browsing_instance_->profile());
// Otherwise (or if that fails), create a new one.
- if (!process) {
+ if (!process_) {
if (render_process_host_factory_) {
- process = render_process_host_factory_->CreateRenderProcessHost(
+ process_ = render_process_host_factory_->CreateRenderProcessHost(
browsing_instance_->profile());
} else {
- process = new BrowserRenderProcessHost(browsing_instance_->profile());
+ process_ = new BrowserRenderProcessHost(browsing_instance_->profile());
}
}
- // Update our host ID, so all pages in this SiteInstance will use
- // the correct process.
- process_host_id_ = process->host_id();
-
// Make sure the process starts at the right max_page_id
- process->UpdateMaxPageID(max_page_id_);
+ process_->UpdateMaxPageID(max_page_id_);
}
- DCHECK(process);
+ DCHECK(process_);
- return process;
+ return process_;
}
void SiteInstance::SetSite(const GURL& url) {
@@ -151,3 +161,12 @@
return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2);
}
+
+void SiteInstance::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED);
+ RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr();
+ if (rph == process_)
+ process_ = NULL;
+}
« no previous file with comments | « chrome/browser/tab_contents/site_instance.h ('k') | chrome/browser/tab_contents/web_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698