OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/tab_contents/site_instance.h" | 5 #include "chrome/browser/tab_contents/site_instance.h" |
6 | 6 |
7 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 7 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
9 #include "chrome/common/notification_service.h" | 9 #include "chrome/common/notification_service.h" |
10 #include "net/base/registry_controlled_domain.h" | 10 #include "net/base/registry_controlled_domain.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 /*static*/ | 91 /*static*/ |
92 SiteInstance* SiteInstance::CreateSiteInstance(Profile* profile) { | 92 SiteInstance* SiteInstance::CreateSiteInstance(Profile* profile) { |
93 return new SiteInstance(new BrowsingInstance(profile)); | 93 return new SiteInstance(new BrowsingInstance(profile)); |
94 } | 94 } |
95 | 95 |
96 /*static*/ | 96 /*static*/ |
97 SiteInstance* SiteInstance::CreateSiteInstanceForURL(Profile* profile, | 97 SiteInstance* SiteInstance::CreateSiteInstanceForURL(Profile* profile, |
98 const GURL& url) { | 98 const GURL& url) { |
99 return (new BrowsingInstance(profile))->GetSiteInstanceForURL(url); | 99 // This BrowsingInstance may be deleted if it returns an existing |
| 100 // SiteInstance. |
| 101 scoped_refptr<BrowsingInstance> instance(new BrowsingInstance(profile)); |
| 102 return instance->GetSiteInstanceForURL(url); |
100 } | 103 } |
101 | 104 |
102 /*static*/ | 105 /*static*/ |
103 GURL SiteInstance::GetSiteForURL(const GURL& url) { | 106 GURL SiteInstance::GetSiteForURL(const GURL& url) { |
104 // URLs with no host should have an empty site. | 107 // URLs with no host should have an empty site. |
105 GURL site; | 108 GURL site; |
106 | 109 |
107 // TODO(creis): For many protocols, we should just treat the scheme as the | 110 // TODO(creis): For many protocols, we should just treat the scheme as the |
108 // site, since there is no host. e.g., file:, about:, chrome: | 111 // site, since there is no host. e.g., file:, about:, chrome: |
109 | 112 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 172 } |
170 | 173 |
171 void SiteInstance::Observe(NotificationType type, | 174 void SiteInstance::Observe(NotificationType type, |
172 const NotificationSource& source, | 175 const NotificationSource& source, |
173 const NotificationDetails& details) { | 176 const NotificationDetails& details) { |
174 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); | 177 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); |
175 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); | 178 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
176 if (rph == process_) | 179 if (rph == process_) |
177 process_ = NULL; | 180 process_ = NULL; |
178 } | 181 } |
OLD | NEW |