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

Side by Side Diff: content/renderer/renderer_main.cc

Issue 10032023: Reland r131429 (Moved SuicideOnChannelErrorFilter to content.). Install it in renderer_main.cc so t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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
« no previous file with comments | « chrome/renderer/chrome_render_process_observer.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/base_switches.h" 5 #include "base/base_switches.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/debug/debugger.h" 7 #include "base/debug/debugger.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // override there. 62 // override there.
63 mach_error_t err = mach_override_ptr( 63 mach_error_t err = mach_override_ptr(
64 (void*)&TISCreateInputSourceList, 64 (void*)&TISCreateInputSourceList,
65 (void*)&ChromeTISCreateInputSourceList, 65 (void*)&ChromeTISCreateInputSourceList,
66 NULL); 66 NULL);
67 CHECK_EQ(err_none, err); 67 CHECK_EQ(err_none, err);
68 } 68 }
69 } 69 }
70 70
71 } // namespace 71 } // namespace
72
73 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter {
74 void OnChannelError() {
75 // On POSIX, at least, one can install an unload handler which loops
76 // forever and leave behind a renderer process which eats 100% CPU forever.
77 //
78 // This is because the terminate signals (ViewMsg_ShouldClose and the error
79 // from the IPC channel) are routed to the main message loop but never
80 // processed (because that message loop is stuck in V8).
81 //
82 // One could make the browser SIGKILL the renderers, but that leaves open a
83 // large window where a browser failure (or a user, manually terminating
84 // the browser because "it's stuck") will leave behind a process eating all
85 // the CPU.
86 //
87 // So, we install a filter on the channel so that we can process this event
88 // here and kill the process.
89
90 _exit(0);
91 }
92 };
93
72 #endif // OS_MACOSX 94 #endif // OS_MACOSX
73 95
74 // This function provides some ways to test crash and assertion handling 96 // This function provides some ways to test crash and assertion handling
75 // behavior of the renderer. 97 // behavior of the renderer.
76 static void HandleRendererErrorTestParameters(const CommandLine& command_line) { 98 static void HandleRendererErrorTestParameters(const CommandLine& command_line) {
77 // This parameter causes an assertion. 99 // This parameter causes an assertion.
78 if (command_line.HasSwitch(switches::kRendererAssertTest)) { 100 if (command_line.HasSwitch(switches::kRendererAssertTest)) {
79 DCHECK(false); 101 DCHECK(false);
80 } 102 }
81 103
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if (!no_sandbox) { 243 if (!no_sandbox) {
222 run_loop = platform.EnableSandbox(); 244 run_loop = platform.EnableSandbox();
223 } else { 245 } else {
224 LOG(ERROR) << "Running without renderer sandbox"; 246 LOG(ERROR) << "Running without renderer sandbox";
225 } 247 }
226 #if defined(OS_POSIX) && !defined(OS_MACOSX) 248 #if defined(OS_POSIX) && !defined(OS_MACOSX)
227 RenderProcessImpl render_process; 249 RenderProcessImpl render_process;
228 new RenderThreadImpl(); 250 new RenderThreadImpl();
229 #endif 251 #endif
230 252
253 #if defined(OS_POSIX)
254 RenderThreadImpl::current()->AddFilter(new SuicideOnChannelErrorFilter());
255 #endif
256
231 platform.RunSandboxTests(); 257 platform.RunSandboxTests();
232 258
233 startup_timer.Stop(); // End of Startup Time Measurement. 259 startup_timer.Stop(); // End of Startup Time Measurement.
234 260
235 if (run_loop) { 261 if (run_loop) {
236 #if defined(OS_MACOSX) 262 #if defined(OS_MACOSX)
237 if (pool) 263 if (pool)
238 pool->Recycle(); 264 pool->Recycle();
239 #endif 265 #endif
240 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); 266 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0);
241 MessageLoop::current()->Run(); 267 MessageLoop::current()->Run();
242 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); 268 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0);
243 } 269 }
244 } 270 }
245 platform.PlatformUninitialize(); 271 platform.PlatformUninitialize();
246 TRACE_EVENT_END_ETW("RendererMain", 0, ""); 272 TRACE_EVENT_END_ETW("RendererMain", 0, "");
247 return 0; 273 return 0;
248 } 274 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_process_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698