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/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (!begin_process_message_.is_null()) | 119 if (!begin_process_message_.is_null()) |
120 process_times_->AddTime(base::TimeTicks::Now() - begin_process_message_); | 120 process_times_->AddTime(base::TimeTicks::Now() - begin_process_message_); |
121 } | 121 } |
122 | 122 |
123 private: | 123 private: |
124 base::TimeTicks begin_process_message_; | 124 base::TimeTicks begin_process_message_; |
125 base::Histogram* const process_times_; | 125 base::Histogram* const process_times_; |
126 DISALLOW_COPY_AND_ASSIGN(RendererMessageLoopObserver); | 126 DISALLOW_COPY_AND_ASSIGN(RendererMessageLoopObserver); |
127 }; | 127 }; |
128 | 128 |
| 129 #if defined(RENDERER_CLEAN_EXIT) |
| 130 static void SigtermHandler(int signal_number) |
| 131 { |
| 132 base::clean_exit(signal_number); |
| 133 } |
| 134 |
| 135 static void AddSigtermHandler() |
| 136 { |
| 137 struct sigaction term_action; |
| 138 int return_value; |
| 139 memset(&term_action, 0, sizeof(term_action)); |
| 140 term_action.sa_handler = SigtermHandler; |
| 141 sigfillset(&term_action.sa_mask); |
| 142 return_value = sigaction(SIGTERM, &term_action, NULL); |
| 143 CHECK(return_value==0) << "Unable to install SIGTERM handler\n"; |
| 144 } |
| 145 #endif // defined(RENDERER_CLEAN_EXIT) |
| 146 |
129 // mainline routine for running as the Renderer process | 147 // mainline routine for running as the Renderer process |
130 int RendererMain(const content::MainFunctionParams& parameters) { | 148 int RendererMain(const content::MainFunctionParams& parameters) { |
131 TRACE_EVENT_BEGIN_ETW("RendererMain", 0, ""); | 149 TRACE_EVENT_BEGIN_ETW("RendererMain", 0, ""); |
132 | 150 |
133 const CommandLine& parsed_command_line = parameters.command_line; | 151 const CommandLine& parsed_command_line = parameters.command_line; |
134 | 152 |
135 #if defined(OS_MACOSX) | 153 #if defined(OS_MACOSX) |
136 base::mac::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool; | 154 base::mac::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool; |
137 InstallFrameworkHacks(); | 155 InstallFrameworkHacks(); |
138 #endif // OS_MACOSX | 156 #endif // OS_MACOSX |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 } | 243 } |
226 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 244 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
227 RenderProcessImpl render_process; | 245 RenderProcessImpl render_process; |
228 new RenderThreadImpl(); | 246 new RenderThreadImpl(); |
229 #endif | 247 #endif |
230 | 248 |
231 platform.RunSandboxTests(); | 249 platform.RunSandboxTests(); |
232 | 250 |
233 startup_timer.Stop(); // End of Startup Time Measurement. | 251 startup_timer.Stop(); // End of Startup Time Measurement. |
234 | 252 |
| 253 #if defined(RENDERER_CLEAN_EXIT) |
| 254 AddSigtermHandler(); |
| 255 #endif |
| 256 |
235 if (run_loop) { | 257 if (run_loop) { |
236 #if defined(OS_MACOSX) | 258 #if defined(OS_MACOSX) |
237 if (pool) | 259 if (pool) |
238 pool->Recycle(); | 260 pool->Recycle(); |
239 #endif | 261 #endif |
240 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 262 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
241 MessageLoop::current()->Run(); | 263 MessageLoop::current()->Run(); |
242 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 264 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
243 } | 265 } |
244 } | 266 } |
245 platform.PlatformUninitialize(); | 267 platform.PlatformUninitialize(); |
246 TRACE_EVENT_END_ETW("RendererMain", 0, ""); | 268 TRACE_EVENT_END_ETW("RendererMain", 0, ""); |
247 return 0; | 269 return 0; |
248 } | 270 } |
OLD | NEW |