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