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

Side by Side Diff: content/browser/renderer_host/render_process_host.cc

Issue 7888024: Move handle dumpage to the renderer process (so that it works correctly) and factor out redundant... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
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/renderer_host/render_process_host.h" 5 #include "content/browser/renderer_host/render_process_host.h"
6 6
7 #include "base/command_line.h"
7 #include "base/rand_util.h" 8 #include "base/rand_util.h"
8 #include "base/sys_info.h" 9 #include "base/sys_info.h"
9 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
10 #include "content/browser/child_process_security_policy.h" 11 #include "content/browser/child_process_security_policy.h"
11 #include "content/common/child_process_info.h" 12 #include "content/common/child_process_info.h"
12 #include "content/common/content_constants.h" 13 #include "content/common/content_constants.h"
14 #include "content/common/content_switches.h"
13 #include "content/common/notification_service.h" 15 #include "content/common/notification_service.h"
14 16
15 namespace { 17 namespace {
16 18
17 size_t max_renderer_count_override = 0; 19 size_t max_renderer_count_override = 0;
18 20
19 size_t GetMaxRendererProcessCount() { 21 size_t GetMaxRendererProcessCount() {
20 if (max_renderer_count_override) 22 if (max_renderer_count_override)
21 return max_renderer_count_override; 23 return max_renderer_count_override;
22 24
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 listeners_.AddWithID(listener, routing_id); 123 listeners_.AddWithID(listener, routing_id);
122 } 124 }
123 125
124 void RenderProcessHost::Release(int listener_id) { 126 void RenderProcessHost::Release(int listener_id) {
125 DCHECK(listeners_.Lookup(listener_id) != NULL); 127 DCHECK(listeners_.Lookup(listener_id) != NULL);
126 listeners_.Remove(listener_id); 128 listeners_.Remove(listener_id);
127 129
128 // Make sure that all associated resource requests are stopped. 130 // Make sure that all associated resource requests are stopped.
129 CancelResourceRequests(listener_id); 131 CancelResourceRequests(listener_id);
130 132
133 #if defined(OS_WIN)
134 // Dump the handle table if handle auditing is enabled.
135 const CommandLine& browser_command_line =
136 *CommandLine::ForCurrentProcess();
137 if (browser_command_line.HasSwitch(switches::kAuditHandles) ||
138 browser_command_line.HasSwitch(switches::kAuditAllHandles)) {
139 DumpHandles();
140
141 // We wait to close the channels until the child process has finished
142 // dumping handles and sends us ChildProcessHostMsg_DumpHandlesDone.
143 return;
144 }
145 #endif
146 Cleanup();
147 }
148
149 void RenderProcessHost::Cleanup() {
131 // When no other owners of this object, we can delete ourselves 150 // When no other owners of this object, we can delete ourselves
132 if (listeners_.IsEmpty()) { 151 if (listeners_.IsEmpty()) {
133 NotificationService::current()->Notify( 152 NotificationService::current()->Notify(
134 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, 153 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
135 Source<RenderProcessHost>(this), NotificationService::NoDetails()); 154 Source<RenderProcessHost>(this), NotificationService::NoDetails());
136 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 155 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
137 deleting_soon_ = true; 156 deleting_soon_ = true;
138 // It's important not to wait for the DeleteTask to delete the channel 157 // It's important not to wait for the DeleteTask to delete the channel
139 // proxy. Kill it off now. That way, in case the profile is going away, the 158 // proxy. Kill it off now. That way, in case the profile is going away, the
140 // rest of the objects attached to this RenderProcessHost start going 159 // rest of the objects attached to this RenderProcessHost start going
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 235
217 // Now pick a random suitable renderer, if we have any. 236 // Now pick a random suitable renderer, if we have any.
218 if (!suitable_renderers.empty()) { 237 if (!suitable_renderers.empty()) {
219 int suitable_count = static_cast<int>(suitable_renderers.size()); 238 int suitable_count = static_cast<int>(suitable_renderers.size());
220 int random_index = base::RandInt(0, suitable_count - 1); 239 int random_index = base::RandInt(0, suitable_count - 1);
221 return suitable_renderers[random_index]; 240 return suitable_renderers[random_index];
222 } 241 }
223 242
224 return NULL; 243 return NULL;
225 } 244 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698