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/leak_annotations.h" | 8 #include "base/debug/leak_annotations.h" |
9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/timer/hi_res_timer_manager.h" | 21 #include "base/timer/hi_res_timer_manager.h" |
22 #include "base/trace_event/trace_event.h" | 22 #include "base/trace_event/trace_event.h" |
23 #include "content/child/child_process.h" | 23 #include "content/child/child_process.h" |
24 #include "content/common/content_constants_internal.h" | 24 #include "content/common/content_constants_internal.h" |
25 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
26 #include "content/public/common/main_function_params.h" | 26 #include "content/public/common/main_function_params.h" |
27 #include "content/public/renderer/content_renderer_client.h" | 27 #include "content/public/renderer/content_renderer_client.h" |
28 #include "content/renderer/render_process_impl.h" | 28 #include "content/renderer/render_process_impl.h" |
29 #include "content/renderer/render_thread_impl.h" | 29 #include "content/renderer/render_thread_impl.h" |
30 #include "content/renderer/renderer_main_platform_delegate.h" | 30 #include "content/renderer/renderer_main_platform_delegate.h" |
| 31 #include "content/renderer/scheduler/renderer_scheduler.h" |
31 #include "ui/base/ui_base_switches.h" | 32 #include "ui/base/ui_base_switches.h" |
32 | 33 |
33 #if defined(OS_ANDROID) | 34 #if defined(OS_ANDROID) |
34 #include "base/android/library_loader/library_loader_hooks.h" | 35 #include "base/android/library_loader/library_loader_hooks.h" |
35 #include "third_party/skia/include/core/SkGraphics.h" | 36 #include "third_party/skia/include/core/SkGraphics.h" |
36 #endif // OS_ANDROID | 37 #endif // OS_ANDROID |
37 | 38 |
38 #if defined(OS_MACOSX) | 39 #if defined(OS_MACOSX) |
39 #include <Carbon/Carbon.h> | 40 #include <Carbon/Carbon.h> |
40 #include <signal.h> | 41 #include <signal.h> |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 scoped_ptr<base::MessagePump> pump(new base::MessagePumpNSRunLoop()); | 141 scoped_ptr<base::MessagePump> pump(new base::MessagePumpNSRunLoop()); |
141 scoped_ptr<base::MessageLoop> main_message_loop( | 142 scoped_ptr<base::MessageLoop> main_message_loop( |
142 new base::MessageLoop(pump.Pass())); | 143 new base::MessageLoop(pump.Pass())); |
143 #else | 144 #else |
144 // The main message loop of the renderer services doesn't have IO or UI tasks. | 145 // The main message loop of the renderer services doesn't have IO or UI tasks. |
145 scoped_ptr<base::MessageLoop> main_message_loop(new base::MessageLoop()); | 146 scoped_ptr<base::MessageLoop> main_message_loop(new base::MessageLoop()); |
146 #endif | 147 #endif |
147 main_message_loop->AddTaskObserver(&task_observer); | 148 main_message_loop->AddTaskObserver(&task_observer); |
148 | 149 |
149 base::PlatformThread::SetName("CrRendererMain"); | 150 base::PlatformThread::SetName("CrRendererMain"); |
| 151 scoped_ptr<RendererScheduler> renderer_scheduler = |
| 152 RendererScheduler::Create(); |
150 | 153 |
151 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); | 154 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); |
152 | 155 |
153 // Initialize histogram statistics gathering system. | 156 // Initialize histogram statistics gathering system. |
154 base::StatisticsRecorder::Initialize(); | 157 base::StatisticsRecorder::Initialize(); |
155 | 158 |
156 #if defined(OS_ANDROID) | 159 #if defined(OS_ANDROID) |
157 // If we have a pending chromium android linker histogram, record it. | 160 // If we have a pending chromium android linker histogram, record it. |
158 base::android::RecordChromiumAndroidLinkerRendererHistogram(); | 161 base::android::RecordChromiumAndroidLinkerRendererHistogram(); |
159 #endif | 162 #endif |
(...skipping 24 matching lines...) Expand all Loading... |
184 // zygote_main_linux.cc. However, calling multiple times from the same thread | 187 // zygote_main_linux.cc. However, calling multiple times from the same thread |
185 // is OK. | 188 // is OK. |
186 InitializeWebRtcModule(); | 189 InitializeWebRtcModule(); |
187 #endif | 190 #endif |
188 | 191 |
189 { | 192 { |
190 #if defined(OS_WIN) || defined(OS_MACOSX) | 193 #if defined(OS_WIN) || defined(OS_MACOSX) |
191 // TODO(markus): Check if it is OK to unconditionally move this | 194 // TODO(markus): Check if it is OK to unconditionally move this |
192 // instruction down. | 195 // instruction down. |
193 RenderProcessImpl render_process; | 196 RenderProcessImpl render_process; |
194 new RenderThreadImpl(main_message_loop.Pass()); | 197 new RenderThreadImpl(main_message_loop.Pass(), renderer_scheduler.Pass()); |
195 #endif | 198 #endif |
196 bool run_loop = true; | 199 bool run_loop = true; |
197 if (!no_sandbox) { | 200 if (!no_sandbox) { |
198 run_loop = platform.EnableSandbox(); | 201 run_loop = platform.EnableSandbox(); |
199 } else { | 202 } else { |
200 LOG(ERROR) << "Running without renderer sandbox"; | 203 LOG(ERROR) << "Running without renderer sandbox"; |
201 #ifndef NDEBUG | 204 #ifndef NDEBUG |
202 // For convenience, we print the stack traces for crashes. When sandbox | 205 // For convenience, we print the stack traces for crashes. When sandbox |
203 // is enabled, the in-process stack dumping is enabled as part of the | 206 // is enabled, the in-process stack dumping is enabled as part of the |
204 // EnableSandbox() call. | 207 // EnableSandbox() call. |
205 base::debug::EnableInProcessStackDumping(); | 208 base::debug::EnableInProcessStackDumping(); |
206 #endif | 209 #endif |
207 } | 210 } |
208 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 211 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
209 RenderProcessImpl render_process; | 212 RenderProcessImpl render_process; |
210 new RenderThreadImpl(main_message_loop.Pass()); | 213 new RenderThreadImpl(main_message_loop.Pass(), renderer_scheduler.Pass()); |
211 #endif | 214 #endif |
212 base::HighResolutionTimerManager hi_res_timer_manager; | 215 base::HighResolutionTimerManager hi_res_timer_manager; |
213 | 216 |
214 if (run_loop) { | 217 if (run_loop) { |
215 #if defined(OS_MACOSX) | 218 #if defined(OS_MACOSX) |
216 if (pool) | 219 if (pool) |
217 pool->Recycle(); | 220 pool->Recycle(); |
218 #endif | 221 #endif |
219 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 222 TRACE_EVENT_BEGIN_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
220 base::MessageLoop::current()->Run(); | 223 base::MessageLoop::current()->Run(); |
221 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); | 224 TRACE_EVENT_END_ETW("RendererMain.START_MSG_LOOP", 0, 0); |
222 } | 225 } |
223 #if defined(LEAK_SANITIZER) | 226 #if defined(LEAK_SANITIZER) |
224 // Run leak detection before RenderProcessImpl goes out of scope. This helps | 227 // Run leak detection before RenderProcessImpl goes out of scope. This helps |
225 // ignore shutdown-only leaks. | 228 // ignore shutdown-only leaks. |
226 __lsan_do_leak_check(); | 229 __lsan_do_leak_check(); |
227 #endif | 230 #endif |
228 } | 231 } |
229 platform.PlatformUninitialize(); | 232 platform.PlatformUninitialize(); |
230 TRACE_EVENT_END_ETW("RendererMain", 0, ""); | 233 TRACE_EVENT_END_ETW("RendererMain", 0, ""); |
231 return 0; | 234 return 0; |
232 } | 235 } |
233 | 236 |
234 } // namespace content | 237 } // namespace content |
OLD | NEW |