OLD | NEW |
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/hi_res_timer_manager.h" | 9 #include "base/hi_res_timer_manager.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 #endif // OS_MACOSX | 71 #endif // OS_MACOSX |
72 | 72 |
73 #if defined(OS_POSIX) | |
74 | |
75 class SuicideOnChannelErrorFilter : public IPC::ChannelProxy::MessageFilter { | |
76 public: | |
77 // IPC::ChannelProxy::MessageFilter | |
78 virtual void OnChannelError() OVERRIDE { | |
79 // On POSIX, at least, one can install an unload handler which loops | |
80 // forever and leave behind a renderer process which eats 100% CPU forever. | |
81 // | |
82 // This is because the terminate signals (ViewMsg_ShouldClose and the error | |
83 // from the IPC channel) are routed to the main message loop but never | |
84 // processed (because that message loop is stuck in V8). | |
85 // | |
86 // One could make the browser SIGKILL the renderers, but that leaves open a | |
87 // large window where a browser failure (or a user, manually terminating | |
88 // the browser because "it's stuck") will leave behind a process eating all | |
89 // the CPU. | |
90 // | |
91 // So, we install a filter on the channel so that we can process this event | |
92 // here and kill the process. | |
93 // | |
94 // We want to kill this process after giving it 30 seconds to run the exit | |
95 // handlers. SIGALRM has a default disposition of terminating the | |
96 // application. | |
97 #if defined(OS_POSIX) | |
98 if (CommandLine::ForCurrentProcess()-> | |
99 HasSwitch(switches::kRendererCleanExit)) | |
100 alarm(30); | |
101 else | |
102 #endif | |
103 _exit(0); | |
104 } | |
105 | |
106 protected: | |
107 virtual ~SuicideOnChannelErrorFilter() {} | |
108 }; | |
109 | |
110 #endif // OS(POSIX) | |
111 | |
112 } // namespace | 73 } // namespace |
113 | 74 |
114 // This function provides some ways to test crash and assertion handling | 75 // This function provides some ways to test crash and assertion handling |
115 // behavior of the renderer. | 76 // behavior of the renderer. |
116 static void HandleRendererErrorTestParameters(const CommandLine& command_line) { | 77 static void HandleRendererErrorTestParameters(const CommandLine& command_line) { |
117 if (command_line.HasSwitch(switches::kWaitForDebugger)) | 78 if (command_line.HasSwitch(switches::kWaitForDebugger)) |
118 base::debug::WaitForDebugger(60, true); | 79 base::debug::WaitForDebugger(60, true); |
119 | 80 |
120 if (command_line.HasSwitch(switches::kRendererStartupDialog)) | 81 if (command_line.HasSwitch(switches::kRendererStartupDialog)) |
121 ChildProcess::WaitForDebugger("Renderer"); | 82 ChildProcess::WaitForDebugger("Renderer"); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 if (!no_sandbox) { | 200 if (!no_sandbox) { |
240 run_loop = platform.EnableSandbox(); | 201 run_loop = platform.EnableSandbox(); |
241 } else { | 202 } else { |
242 LOG(ERROR) << "Running without renderer sandbox"; | 203 LOG(ERROR) << "Running without renderer sandbox"; |
243 } | 204 } |
244 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 205 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
245 RenderProcessImpl render_process; | 206 RenderProcessImpl render_process; |
246 new RenderThreadImpl(); | 207 new RenderThreadImpl(); |
247 #endif | 208 #endif |
248 | 209 |
249 #if defined(OS_POSIX) | |
250 RenderThreadImpl::current()->AddFilter(new SuicideOnChannelErrorFilter()); | |
251 #endif | |
252 | |
253 platform.RunSandboxTests(); | 210 platform.RunSandboxTests(); |
254 | 211 |
255 startup_timer.Stop(); // End of Startup Time Measurement. | 212 startup_timer.Stop(); // End of Startup Time Measurement. |
256 | 213 |
257 if (run_loop) { | 214 if (run_loop) { |
258 #if defined(OS_MACOSX) | 215 #if defined(OS_MACOSX) |
259 if (pool) | 216 if (pool) |
260 pool->Recycle(); | 217 pool->Recycle(); |
261 #endif | 218 #endif |
262 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 219 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
263 MessageLoop::current()->Run(); | 220 MessageLoop::current()->Run(); |
264 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 221 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
265 } | 222 } |
266 } | 223 } |
267 platform.PlatformUninitialize(); | 224 platform.PlatformUninitialize(); |
268 TRACE_EVENT_END_ETW("RendererMain", 0, ""); | 225 TRACE_EVENT_END_ETW("RendererMain", 0, ""); |
269 return 0; | 226 return 0; |
270 } | 227 } |
OLD | NEW |