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 fprintf(stderr, "SIGTERM caught by the renderer process.\n"); | |
133 fprintf(stderr, "Calling clean_exit().\n"); | |
Markus (顧孟勤)
2012/03/28 23:07:56
You cannot call fprintf() from a signal handler.
asharif1
2012/03/29 02:13:11
Done.
| |
134 base::clean_exit(signal_number); | |
135 } | |
136 | |
137 static void AddSigtermHandler() | |
138 { | |
139 struct sigaction term_action; | |
Markus (顧孟勤)
2012/03/28 23:07:56
It is good practice to use memset() to clear out a
asharif1
2012/03/29 02:13:11
Done.
| |
140 int return_value; | |
141 term_action.sa_handler = SigtermHandler; | |
142 sigfillset(&term_action.sa_mask); | |
143 term_action.sa_flags = 0; | |
144 fprintf(stderr, "Installing SIGTERM handler to the renderer process.\n"); | |
Markus (顧孟勤)
2012/03/28 23:07:56
Why do you need to print this message? We typicall
asharif1
2012/03/29 02:13:11
Done.
| |
145 return_value = sigaction(SIGTERM, &term_action, NULL); | |
Markus (顧孟勤)
2012/03/28 23:07:56
If sigaction() failed, you should trigger a CHECK(
asharif1
2012/03/29 02:13:11
Done.
| |
146 if (!return_value) | |
147 fprintf(stderr, "Installed SIGTERM handler to the renderer process.\n"); | |
148 else | |
149 fprintf(stderr, | |
150 "Couldn't install SIGTERM handler to the renderer process.\n"); | |
151 } | |
152 #endif // defined(RENDERER_CLEAN_EXIT) | |
153 | |
129 // mainline routine for running as the Renderer process | 154 // mainline routine for running as the Renderer process |
130 int RendererMain(const content::MainFunctionParams& parameters) { | 155 int RendererMain(const content::MainFunctionParams& parameters) { |
131 TRACE_EVENT_BEGIN_ETW("RendererMain", 0, ""); | 156 TRACE_EVENT_BEGIN_ETW("RendererMain", 0, ""); |
132 | 157 |
133 const CommandLine& parsed_command_line = parameters.command_line; | 158 const CommandLine& parsed_command_line = parameters.command_line; |
134 | 159 |
135 #if defined(OS_MACOSX) | 160 #if defined(OS_MACOSX) |
136 base::mac::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool; | 161 base::mac::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool; |
137 InstallFrameworkHacks(); | 162 InstallFrameworkHacks(); |
138 #endif // OS_MACOSX | 163 #endif // OS_MACOSX |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 } | 250 } |
226 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 251 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
227 RenderProcessImpl render_process; | 252 RenderProcessImpl render_process; |
228 new RenderThreadImpl(); | 253 new RenderThreadImpl(); |
229 #endif | 254 #endif |
230 | 255 |
231 platform.RunSandboxTests(); | 256 platform.RunSandboxTests(); |
232 | 257 |
233 startup_timer.Stop(); // End of Startup Time Measurement. | 258 startup_timer.Stop(); // End of Startup Time Measurement. |
234 | 259 |
260 #if defined(RENDERER_CLEAN_EXIT) | |
261 AddSigtermHandler(); | |
Markus (顧孟勤)
2012/03/28 23:07:56
Can you say a little more about the rationale for
asharif1
2012/03/29 02:13:11
Read the CL description.
My goal is to run exit h
| |
262 #endif | |
263 | |
235 if (run_loop) { | 264 if (run_loop) { |
236 #if defined(OS_MACOSX) | 265 #if defined(OS_MACOSX) |
237 if (pool) | 266 if (pool) |
238 pool->Recycle(); | 267 pool->Recycle(); |
239 #endif | 268 #endif |
240 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 269 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
241 MessageLoop::current()->Run(); | 270 MessageLoop::current()->Run(); |
242 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 271 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
243 } | 272 } |
244 } | 273 } |
245 platform.PlatformUninitialize(); | 274 platform.PlatformUninitialize(); |
246 TRACE_EVENT_END_ETW("RendererMain", 0, ""); | 275 TRACE_EVENT_END_ETW("RendererMain", 0, ""); |
247 return 0; | 276 return 0; |
248 } | 277 } |
OLD | NEW |