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

Side by Side Diff: content/browser/site_instance.cc

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/site_instance.h ('k') | content/browser/site_instance_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "content/browser/site_instance.h"
6 6
7 #include "content/browser/browsing_instance.h" 7 #include "content/browser/browsing_instance.h"
8 #include "content/browser/renderer_host/browser_render_process_host.h" 8 #include "content/browser/renderer_host/render_process_host_impl.h"
9 #include "content/browser/webui/web_ui_factory.h" 9 #include "content/browser/webui/web_ui_factory.h"
10 #include "content/public/browser/content_browser_client.h" 10 #include "content/public/browser/content_browser_client.h"
11 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
12 #include "content/public/browser/notification_types.h" 12 #include "content/public/browser/notification_types.h"
13 #include "content/public/browser/render_process_host_factory.h"
13 #include "content/public/common/url_constants.h" 14 #include "content/public/common/url_constants.h"
14 #include "net/base/registry_controlled_domain.h" 15 #include "net/base/registry_controlled_domain.h"
15 16
16 static bool IsURLSameAsAnySiteInstance(const GURL& url) { 17 static bool IsURLSameAsAnySiteInstance(const GURL& url) {
17 if (!url.is_valid()) 18 if (!url.is_valid())
18 return false; 19 return false;
19 20
20 // We treat javascript: as the same site as any URL since it is actually 21 // We treat javascript: as the same site as any URL since it is actually
21 // a modifier on existing pages. 22 // a modifier on existing pages.
22 if (url.SchemeIs(chrome::kJavaScriptScheme)) 23 if (url.SchemeIs(chrome::kJavaScriptScheme))
(...skipping 25 matching lines...) Expand all
48 // the BrowsingInstance. Any future visits to a page from this site 49 // the BrowsingInstance. Any future visits to a page from this site
49 // (within the same BrowsingInstance) can safely create a new SiteInstance. 50 // (within the same BrowsingInstance) can safely create a new SiteInstance.
50 if (has_site_) 51 if (has_site_)
51 browsing_instance_->UnregisterSiteInstance(this); 52 browsing_instance_->UnregisterSiteInstance(this);
52 } 53 }
53 54
54 bool SiteInstance::HasProcess() const { 55 bool SiteInstance::HasProcess() const {
55 return (process_ != NULL); 56 return (process_ != NULL);
56 } 57 }
57 58
58 RenderProcessHost* SiteInstance::GetProcess() { 59 content::RenderProcessHost* SiteInstance::GetProcess() {
59 // TODO(erikkay) It would be nice to ensure that the renderer type had been 60 // TODO(erikkay) It would be nice to ensure that the renderer type had been
60 // properly set before we get here. The default tab creation case winds up 61 // properly set before we get here. The default tab creation case winds up
61 // with no site set at this point, so it will default to TYPE_NORMAL. This 62 // with no site set at this point, so it will default to TYPE_NORMAL. This
62 // may not be correct, so we'll wind up potentially creating a process that 63 // may not be correct, so we'll wind up potentially creating a process that
63 // we then throw away, or worse sharing a process with the wrong process type. 64 // we then throw away, or worse sharing a process with the wrong process type.
64 // See crbug.com/43448. 65 // See crbug.com/43448.
65 66
66 // Create a new process if ours went away or was reused. 67 // Create a new process if ours went away or was reused.
67 if (!process_) { 68 if (!process_) {
68 // See if we should reuse an old process 69 // See if we should reuse an old process
69 if (RenderProcessHost::ShouldTryToUseExistingProcessHost()) 70 if (content::RenderProcessHost::ShouldTryToUseExistingProcessHost())
70 process_ = RenderProcessHost::GetExistingProcessHost( 71 process_ = content::RenderProcessHost::GetExistingProcessHost(
71 browsing_instance_->browser_context(), site_); 72 browsing_instance_->browser_context(), site_);
72 73
73 // Otherwise (or if that fails), create a new one. 74 // Otherwise (or if that fails), create a new one.
74 if (!process_) { 75 if (!process_) {
75 if (render_process_host_factory_) { 76 if (render_process_host_factory_) {
76 process_ = render_process_host_factory_->CreateRenderProcessHost( 77 process_ = render_process_host_factory_->CreateRenderProcessHost(
77 browsing_instance_->browser_context()); 78 browsing_instance_->browser_context());
78 } else { 79 } else {
79 process_ = 80 process_ =
80 new BrowserRenderProcessHost(browsing_instance_->browser_context()); 81 new RenderProcessHostImpl(browsing_instance_->browser_context());
81 } 82 }
82 } 83 }
83 84
84 content::GetContentClient()->browser()->SiteInstanceGotProcess(this); 85 content::GetContentClient()->browser()->SiteInstanceGotProcess(this);
85 86
86 // Make sure the process starts at the right max_page_id, and ensure that 87 // Make sure the process starts at the right max_page_id, and ensure that
87 // we send an update to the renderer process. 88 // we send an update to the renderer process.
88 process_->UpdateAndSendMaxPageID(max_page_id_); 89 process_->UpdateAndSendMaxPageID(max_page_id_);
89 } 90 }
90 DCHECK(process_); 91 DCHECK(process_);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 GURL SiteInstance::GetEffectiveURL(content::BrowserContext* browser_context, 218 GURL SiteInstance::GetEffectiveURL(content::BrowserContext* browser_context,
218 const GURL& url) { 219 const GURL& url) {
219 return content::GetContentClient()->browser()-> 220 return content::GetContentClient()->browser()->
220 GetEffectiveURL(browser_context, url); 221 GetEffectiveURL(browser_context, url);
221 } 222 }
222 223
223 void SiteInstance::Observe(int type, 224 void SiteInstance::Observe(int type,
224 const content::NotificationSource& source, 225 const content::NotificationSource& source,
225 const content::NotificationDetails& details) { 226 const content::NotificationDetails& details) {
226 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); 227 DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED);
227 RenderProcessHost* rph = content::Source<RenderProcessHost>(source).ptr(); 228 content::RenderProcessHost* rph =
229 content::Source<content::RenderProcessHost>(source).ptr();
228 if (rph == process_) 230 if (rph == process_)
229 process_ = NULL; 231 process_ = NULL;
230 } 232 }
OLDNEW
« no previous file with comments | « content/browser/site_instance.h ('k') | content/browser/site_instance_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698