Chromium Code Reviews| 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_SIGTERM_HANDLER) | |
| 130 static void SigtermHandler(int signum) | |
| 131 { | |
|
Evan Martin
2012/03/26 17:17:25
curly should be on same line of function decl (see
| |
| 132 LOG(INFO) << "SIGTERM caught by the renderer process. Calling exit()."; | |
|
Evan Martin
2012/03/26 17:17:25
I think LOG() probably does a bunch of stuff that
| |
| 133 exit(signum); | |
| 134 } | |
| 135 | |
| 136 static void AddSigtermHandler() | |
| 137 { | |
| 138 struct sigaction termAction; | |
|
Evan Martin
2012/03/26 17:17:25
variable names should be like term_action
| |
| 139 termAction.sa_handler = SigtermHandler; | |
| 140 sigfillset(&termAction.sa_mask); | |
| 141 termAction.sa_flags = 0; | |
| 142 LOG(INFO) << "Installing SIGTERM handler to the renderer process."; | |
| 143 sigaction(SIGTERM, &termAction, NULL); | |
| 144 LOG(INFO) << "Added SIGTERM handler to the renderer process."; | |
|
Evan Martin
2012/03/26 17:17:25
Rather than this, perhaps you should just check th
| |
| 145 } | |
| 146 #endif | |
| 147 | |
| 129 // mainline routine for running as the Renderer process | 148 // mainline routine for running as the Renderer process |
| 130 int RendererMain(const content::MainFunctionParams& parameters) { | 149 int RendererMain(const content::MainFunctionParams& parameters) { |
| 131 TRACE_EVENT_BEGIN_ETW("RendererMain", 0, ""); | 150 TRACE_EVENT_BEGIN_ETW("RendererMain", 0, ""); |
| 132 | 151 |
| 133 const CommandLine& parsed_command_line = parameters.command_line; | 152 const CommandLine& parsed_command_line = parameters.command_line; |
| 134 | 153 |
| 135 #if defined(OS_MACOSX) | 154 #if defined(OS_MACOSX) |
| 136 base::mac::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool; | 155 base::mac::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool; |
| 137 InstallFrameworkHacks(); | 156 InstallFrameworkHacks(); |
| 138 #endif // OS_MACOSX | 157 #endif // OS_MACOSX |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 } | 244 } |
| 226 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 245 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 227 RenderProcessImpl render_process; | 246 RenderProcessImpl render_process; |
| 228 new RenderThreadImpl(); | 247 new RenderThreadImpl(); |
| 229 #endif | 248 #endif |
| 230 | 249 |
| 231 platform.RunSandboxTests(); | 250 platform.RunSandboxTests(); |
| 232 | 251 |
| 233 startup_timer.Stop(); // End of Startup Time Measurement. | 252 startup_timer.Stop(); // End of Startup Time Measurement. |
| 234 | 253 |
| 254 #if defined(RENDERER_SIGTERM_HANDLER) | |
| 255 AddSigtermHandler(); | |
| 256 #endif | |
| 257 | |
| 235 if (run_loop) { | 258 if (run_loop) { |
| 236 #if defined(OS_MACOSX) | 259 #if defined(OS_MACOSX) |
| 237 if (pool) | 260 if (pool) |
| 238 pool->Recycle(); | 261 pool->Recycle(); |
| 239 #endif | 262 #endif |
| 240 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 263 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
| 241 MessageLoop::current()->Run(); | 264 MessageLoop::current()->Run(); |
| 242 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 265 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
| 243 } | 266 } |
| 244 } | 267 } |
| 245 platform.PlatformUninitialize(); | 268 platform.PlatformUninitialize(); |
| 246 TRACE_EVENT_END_ETW("RendererMain", 0, ""); | 269 TRACE_EVENT_END_ETW("RendererMain", 0, ""); |
| 247 return 0; | 270 return 0; |
| 248 } | 271 } |
| OLD | NEW |