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/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 base::StatsCounterTimer stats_counter_timer("Content.RendererInit"); | 143 base::StatsCounterTimer stats_counter_timer("Content.RendererInit"); |
144 base::StatsScope<base::StatsCounterTimer> startup_timer(stats_counter_timer); | 144 base::StatsScope<base::StatsCounterTimer> startup_timer(stats_counter_timer); |
145 | 145 |
146 RendererMessageLoopObserver task_observer; | 146 RendererMessageLoopObserver task_observer; |
147 #if defined(OS_MACOSX) | 147 #if defined(OS_MACOSX) |
148 // As long as scrollbars on Mac are painted with Cocoa, the message pump | 148 // As long as scrollbars on Mac are painted with Cocoa, the message pump |
149 // needs to be backed by a Foundation-level loop to process NSTimers. See | 149 // needs to be backed by a Foundation-level loop to process NSTimers. See |
150 // http://crbug.com/306348#c24 for details. | 150 // http://crbug.com/306348#c24 for details. |
151 scoped_ptr<base::MessagePump> pump(new base::MessagePumpNSRunLoop()); | 151 scoped_ptr<base::MessagePump> pump(new base::MessagePumpNSRunLoop()); |
152 base::MessageLoop main_message_loop(pump.Pass()); | 152 scoped_ptr<base::MessageLoop> main_message_loop( |
| 153 new base::MessageLoop(pump.Pass())); |
153 #else | 154 #else |
154 // The main message loop of the renderer services doesn't have IO or UI tasks. | 155 // The main message loop of the renderer services doesn't have IO or UI tasks. |
155 base::MessageLoop main_message_loop; | 156 scoped_ptr<base::MessageLoop> main_message_loop(new base::MessageLoop()); |
156 #endif | 157 #endif |
157 main_message_loop.AddTaskObserver(&task_observer); | 158 main_message_loop->AddTaskObserver(&task_observer); |
158 | 159 |
159 base::PlatformThread::SetName("CrRendererMain"); | 160 base::PlatformThread::SetName("CrRendererMain"); |
160 | 161 |
161 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); | 162 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); |
162 | 163 |
163 // Initialize histogram statistics gathering system. | 164 // Initialize histogram statistics gathering system. |
164 base::StatisticsRecorder::Initialize(); | 165 base::StatisticsRecorder::Initialize(); |
165 | 166 |
166 // Initialize statistical testing infrastructure. We set the entropy provider | 167 // Initialize statistical testing infrastructure. We set the entropy provider |
167 // to NULL to disallow the renderer process from creating its own one-time | 168 // to NULL to disallow the renderer process from creating its own one-time |
(...skipping 23 matching lines...) Expand all Loading... |
191 // zygote_main_linux.cc. However, calling multiple times from the same thread | 192 // zygote_main_linux.cc. However, calling multiple times from the same thread |
192 // is OK. | 193 // is OK. |
193 InitializeWebRtcModule(); | 194 InitializeWebRtcModule(); |
194 #endif | 195 #endif |
195 | 196 |
196 { | 197 { |
197 #if defined(OS_WIN) || defined(OS_MACOSX) | 198 #if defined(OS_WIN) || defined(OS_MACOSX) |
198 // TODO(markus): Check if it is OK to unconditionally move this | 199 // TODO(markus): Check if it is OK to unconditionally move this |
199 // instruction down. | 200 // instruction down. |
200 RenderProcessImpl render_process; | 201 RenderProcessImpl render_process; |
201 new RenderThreadImpl(); | 202 new RenderThreadImpl(main_message_loop.Pass()); |
202 #endif | 203 #endif |
203 bool run_loop = true; | 204 bool run_loop = true; |
204 if (!no_sandbox) { | 205 if (!no_sandbox) { |
205 run_loop = platform.EnableSandbox(); | 206 run_loop = platform.EnableSandbox(); |
206 } else { | 207 } else { |
207 LOG(ERROR) << "Running without renderer sandbox"; | 208 LOG(ERROR) << "Running without renderer sandbox"; |
208 #ifndef NDEBUG | 209 #ifndef NDEBUG |
209 // For convenience, we print the stack traces for crashes. When sandbox | 210 // For convenience, we print the stack traces for crashes. When sandbox |
210 // is enabled, the in-process stack dumping is enabled as part of the | 211 // is enabled, the in-process stack dumping is enabled as part of the |
211 // EnableSandbox() call. | 212 // EnableSandbox() call. |
212 base::debug::EnableInProcessStackDumping(); | 213 base::debug::EnableInProcessStackDumping(); |
213 #endif | 214 #endif |
214 } | 215 } |
215 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 216 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
216 RenderProcessImpl render_process; | 217 RenderProcessImpl render_process; |
217 new RenderThreadImpl(); | 218 new RenderThreadImpl(main_message_loop.Pass()); |
218 #endif | 219 #endif |
219 | 220 |
220 base::HighResolutionTimerManager hi_res_timer_manager; | 221 base::HighResolutionTimerManager hi_res_timer_manager; |
221 | 222 |
222 startup_timer.Stop(); // End of Startup Time Measurement. | 223 startup_timer.Stop(); // End of Startup Time Measurement. |
223 | 224 |
224 if (run_loop) { | 225 if (run_loop) { |
225 #if defined(OS_MACOSX) | 226 #if defined(OS_MACOSX) |
226 if (pool) | 227 if (pool) |
227 pool->Recycle(); | 228 pool->Recycle(); |
228 #endif | 229 #endif |
229 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 230 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
230 base::MessageLoop::current()->Run(); | 231 base::MessageLoop::current()->Run(); |
231 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 232 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
232 } | 233 } |
233 } | 234 } |
234 platform.PlatformUninitialize(); | 235 platform.PlatformUninitialize(); |
235 TRACE_EVENT_END_ETW("RendererMain", 0, ""); | 236 TRACE_EVENT_END_ETW("RendererMain", 0, ""); |
236 return 0; | 237 return 0; |
237 } | 238 } |
238 | 239 |
239 } // namespace content | 240 } // namespace content |
OLD | NEW |