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

Unified Diff: chrome/browser/renderer_host/browser_render_process_host.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
Index: chrome/browser/renderer_host/browser_render_process_host.cc
===================================================================
--- chrome/browser/renderer_host/browser_render_process_host.cc (revision 11493)
+++ chrome/browser/renderer_host/browser_render_process_host.cc (working copy)
@@ -128,13 +128,8 @@
ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_(
base::TimeDelta::FromSeconds(5),
this, &BrowserRenderProcessHost::ClearTransportDIBCache)) {
- DCHECK(host_id() >= 0); // We use a negative host_id_ in destruction.
- widget_helper_ = new RenderWidgetHelper(
- host_id(), g_browser_process->resource_dispatcher_host());
+ widget_helper_ = new RenderWidgetHelper();
- CacheManagerHost::GetInstance()->Add(host_id());
- RendererSecurityPolicy::GetInstance()->Add(host_id());
-
PrefService* prefs = profile->GetPrefs();
prefs->AddPrefObserver(prefs::kBlockPopups, this);
widget_helper_->set_block_popups(
@@ -151,9 +146,10 @@
}
BrowserRenderProcessHost::~BrowserRenderProcessHost() {
- // Some tests hold BrowserRenderProcessHost in a scoped_ptr, so we must call
- // Unregister here as well as in response to Release().
- Unregister();
+ if (pid() >= 0) {
+ CacheManagerHost::GetInstance()->Remove(pid());
+ RendererSecurityPolicy::GetInstance()->Remove(pid());
+ }
// We may have some unsent messages at this point, but that's OK.
channel_.reset();
@@ -192,7 +188,6 @@
audio_renderer_host_.get(),
PluginService::GetInstance(),
g_browser_process->print_job_manager(),
- host_id(),
profile(),
widget_helper_,
profile()->GetSpellChecker());
@@ -306,6 +301,7 @@
cmd_line.AppendSwitchWithValue(switches::kUserDataDir,
profile_path);
+ int process_id;
bool run_in_process = run_renderer_in_process();
if (run_in_process) {
// Crank up a thread and run the initialization there. With the way that
@@ -323,6 +319,14 @@
base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
in_process_renderer_->StartWithOptions(options);
+
+ // We need a "renderer pid", but we don't have one when there's no renderer
+ // process. So pick a value that won't clash with other child process pids.
+ // Linux has PID_MAX_LIMIT which is 2^22. Windows always uses pids that are
+ // divisible by 4. So...
+ static int next_pid = 4 * 1024 * 1024;
+ next_pid += 3;
+ process_id = next_pid;
} else {
#if defined(OS_WIN)
if (in_sandbox) {
@@ -405,8 +409,15 @@
return false;
process_.set_handle(process);
}
+
+ process_id = process_.pid();
}
+ SetProcessID(process_id);
+ resource_message_filter->Init(pid());
+ CacheManagerHost::GetInstance()->Add(pid());
+ RendererSecurityPolicy::GetInstance()->Add(pid());
+
// Now that the process is created, set it's backgrounding accordingly.
SetBackgrounded(backgrounded_);
@@ -771,17 +782,6 @@
// TODO(darin): clean this up
}
-void BrowserRenderProcessHost::Unregister() {
- // RenderProcessHost::Unregister will clean up the host_id_, so we must
- // do our cleanup that uses that variable before we call it.
- if (host_id() >= 0) {
- CacheManagerHost::GetInstance()->Remove(host_id());
- RendererSecurityPolicy::GetInstance()->Remove(host_id());
- }
-
- RenderProcessHost::Unregister();
-}
-
void BrowserRenderProcessHost::OnPageContents(const GURL& url,
int32 page_id,
const std::wstring& contents) {
@@ -796,7 +796,7 @@
void BrowserRenderProcessHost::OnUpdatedCacheStats(
const CacheManager::UsageStats& stats) {
- CacheManagerHost::GetInstance()->ObserveStats(host_id(), stats);
+ CacheManagerHost::GetInstance()->ObserveStats(pid(), stats);
}
void BrowserRenderProcessHost::SetBackgrounded(bool backgrounded) {
« no previous file with comments | « chrome/browser/renderer_host/browser_render_process_host.h ('k') | chrome/browser/renderer_host/render_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698