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 <stddef.h> | 5 #include <stddef.h> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
11 #include "base/debug/leak_annotations.h" | 11 #include "base/debug/leak_annotations.h" |
12 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/metrics/statistics_recorder.h" | 17 #include "base/metrics/statistics_recorder.h" |
18 #include "base/pending_task.h" | 18 #include "base/pending_task.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
21 #include "base/threading/platform_thread.h" | 21 #include "base/threading/platform_thread.h" |
22 #include "base/time/time.h" | |
23 #include "base/timer/hi_res_timer_manager.h" | 22 #include "base/timer/hi_res_timer_manager.h" |
24 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
25 #include "build/build_config.h" | 24 #include "build/build_config.h" |
26 #include "components/scheduler/renderer/renderer_scheduler.h" | 25 #include "components/scheduler/renderer/renderer_scheduler.h" |
27 #include "components/startup_metric_utils/common/startup_metric_messages.h" | |
28 #include "content/child/child_process.h" | 26 #include "content/child/child_process.h" |
29 #include "content/common/content_constants_internal.h" | 27 #include "content/common/content_constants_internal.h" |
30 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
31 #include "content/public/common/main_function_params.h" | 29 #include "content/public/common/main_function_params.h" |
32 #include "content/public/renderer/content_renderer_client.h" | 30 #include "content/public/renderer/content_renderer_client.h" |
33 #include "content/renderer/render_process_impl.h" | 31 #include "content/renderer/render_process_impl.h" |
34 #include "content/renderer/render_thread_impl.h" | 32 #include "content/renderer/render_thread_impl.h" |
35 #include "content/renderer/renderer_main_platform_delegate.h" | 33 #include "content/renderer/renderer_main_platform_delegate.h" |
36 #include "third_party/skia/include/core/SkGraphics.h" | 34 #include "third_party/skia/include/core/SkGraphics.h" |
37 #include "ui/base/ui_base_switches.h" | 35 #include "ui/base/ui_base_switches.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 #endif | 83 #endif |
86 | 84 |
87 } // namespace | 85 } // namespace |
88 | 86 |
89 // mainline routine for running as the Renderer process | 87 // mainline routine for running as the Renderer process |
90 int RendererMain(const MainFunctionParams& parameters) { | 88 int RendererMain(const MainFunctionParams& parameters) { |
91 // Don't use the TRACE_EVENT0 macro because the tracing infrastructure doesn't | 89 // Don't use the TRACE_EVENT0 macro because the tracing infrastructure doesn't |
92 // expect synchronous events around the main loop of a thread. | 90 // expect synchronous events around the main loop of a thread. |
93 TRACE_EVENT_ASYNC_BEGIN0("startup", "RendererMain", 0); | 91 TRACE_EVENT_ASYNC_BEGIN0("startup", "RendererMain", 0); |
94 | 92 |
95 const base::TimeTicks renderer_main_entry_time = base::TimeTicks::Now(); | 93 GetContentClient()->renderer()->RendererMainEntered(); |
96 | 94 |
97 base::trace_event::TraceLog::GetInstance()->SetProcessName("Renderer"); | 95 base::trace_event::TraceLog::GetInstance()->SetProcessName("Renderer"); |
98 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( | 96 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( |
99 kTraceEventRendererProcessSortIndex); | 97 kTraceEventRendererProcessSortIndex); |
100 | 98 |
101 const base::CommandLine& parsed_command_line = parameters.command_line; | 99 const base::CommandLine& parsed_command_line = parameters.command_line; |
102 | 100 |
103 #if defined(MOJO_SHELL_CLIENT) | 101 #if defined(MOJO_SHELL_CLIENT) |
104 if (parsed_command_line.HasSwitch(switches::kEnableMojoShellConnection)) | 102 if (parsed_command_line.HasSwitch(switches::kEnableMojoShellConnection)) |
105 MojoShellConnectionImpl::Create(); | 103 MojoShellConnectionImpl::Create(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 std::move(renderer_scheduler)); | 209 std::move(renderer_scheduler)); |
212 #endif | 210 #endif |
213 bool run_loop = true; | 211 bool run_loop = true; |
214 if (!no_sandbox) | 212 if (!no_sandbox) |
215 run_loop = platform.EnableSandbox(); | 213 run_loop = platform.EnableSandbox(); |
216 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 214 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
217 RenderProcessImpl render_process; | 215 RenderProcessImpl render_process; |
218 RenderThreadImpl::Create(std::move(main_message_loop), | 216 RenderThreadImpl::Create(std::move(main_message_loop), |
219 std::move(renderer_scheduler)); | 217 std::move(renderer_scheduler)); |
220 #endif | 218 #endif |
221 RenderThreadImpl::current()->Send( | |
222 new StartupMetricHostMsg_RecordRendererMainEntryTime( | |
223 renderer_main_entry_time)); | |
224 | 219 |
225 base::HighResolutionTimerManager hi_res_timer_manager; | 220 base::HighResolutionTimerManager hi_res_timer_manager; |
226 | 221 |
227 if (run_loop) { | 222 if (run_loop) { |
228 #if defined(OS_MACOSX) | 223 #if defined(OS_MACOSX) |
229 if (pool) | 224 if (pool) |
230 pool->Recycle(); | 225 pool->Recycle(); |
231 #endif | 226 #endif |
232 TRACE_EVENT_ASYNC_BEGIN0("toplevel", "RendererMain.START_MSG_LOOP", 0); | 227 TRACE_EVENT_ASYNC_BEGIN0("toplevel", "RendererMain.START_MSG_LOOP", 0); |
233 base::MessageLoop::current()->Run(); | 228 base::MessageLoop::current()->Run(); |
234 TRACE_EVENT_ASYNC_END0("toplevel", "RendererMain.START_MSG_LOOP", 0); | 229 TRACE_EVENT_ASYNC_END0("toplevel", "RendererMain.START_MSG_LOOP", 0); |
235 } | 230 } |
236 #if defined(LEAK_SANITIZER) | 231 #if defined(LEAK_SANITIZER) |
237 // Run leak detection before RenderProcessImpl goes out of scope. This helps | 232 // Run leak detection before RenderProcessImpl goes out of scope. This helps |
238 // ignore shutdown-only leaks. | 233 // ignore shutdown-only leaks. |
239 __lsan_do_leak_check(); | 234 __lsan_do_leak_check(); |
240 #endif | 235 #endif |
241 } | 236 } |
242 platform.PlatformUninitialize(); | 237 platform.PlatformUninitialize(); |
243 TRACE_EVENT_ASYNC_END0("startup", "RendererMain", 0); | 238 TRACE_EVENT_ASYNC_END0("startup", "RendererMain", 0); |
244 return 0; | 239 return 0; |
245 } | 240 } |
246 | 241 |
247 } // namespace content | 242 } // namespace content |
OLD | NEW |