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/feature_list.h" | 9 #include "base/feature_list.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/metrics/statistics_recorder.h" | 14 #include "base/metrics/statistics_recorder.h" |
15 #include "base/pending_task.h" | 15 #include "base/pending_task.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
19 #include "base/time/time.h" | |
19 #include "base/timer/hi_res_timer_manager.h" | 20 #include "base/timer/hi_res_timer_manager.h" |
20 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
21 #include "components/scheduler/renderer/renderer_scheduler.h" | 22 #include "components/scheduler/renderer/renderer_scheduler.h" |
23 #include "components/startup_metric_utils/common/startup_metric_messages.h" | |
22 #include "content/child/child_process.h" | 24 #include "content/child/child_process.h" |
23 #include "content/common/content_constants_internal.h" | 25 #include "content/common/content_constants_internal.h" |
24 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
25 #include "content/public/common/main_function_params.h" | 27 #include "content/public/common/main_function_params.h" |
26 #include "content/public/renderer/content_renderer_client.h" | 28 #include "content/public/renderer/content_renderer_client.h" |
27 #include "content/renderer/render_process_impl.h" | 29 #include "content/renderer/render_process_impl.h" |
28 #include "content/renderer/render_thread_impl.h" | 30 #include "content/renderer/render_thread_impl.h" |
29 #include "content/renderer/renderer_main_platform_delegate.h" | 31 #include "content/renderer/renderer_main_platform_delegate.h" |
30 #include "third_party/skia/include/core/SkGraphics.h" | 32 #include "third_party/skia/include/core/SkGraphics.h" |
31 #include "ui/base/ui_base_switches.h" | 33 #include "ui/base/ui_base_switches.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 #endif | 77 #endif |
76 | 78 |
77 } // namespace | 79 } // namespace |
78 | 80 |
79 // mainline routine for running as the Renderer process | 81 // mainline routine for running as the Renderer process |
80 int RendererMain(const MainFunctionParams& parameters) { | 82 int RendererMain(const MainFunctionParams& parameters) { |
81 // Don't use the TRACE_EVENT0 macro because the tracing infrastructure doesn't | 83 // Don't use the TRACE_EVENT0 macro because the tracing infrastructure doesn't |
82 // expect synchronous events around the main loop of a thread. | 84 // expect synchronous events around the main loop of a thread. |
83 TRACE_EVENT_ASYNC_BEGIN0("startup", "RendererMain", 0); | 85 TRACE_EVENT_ASYNC_BEGIN0("startup", "RendererMain", 0); |
84 | 86 |
87 base::Time renderer_main_entry_time = base::Time::Now(); | |
88 | |
85 base::trace_event::TraceLog::GetInstance()->SetProcessName("Renderer"); | 89 base::trace_event::TraceLog::GetInstance()->SetProcessName("Renderer"); |
86 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( | 90 base::trace_event::TraceLog::GetInstance()->SetProcessSortIndex( |
87 kTraceEventRendererProcessSortIndex); | 91 kTraceEventRendererProcessSortIndex); |
88 | 92 |
89 const base::CommandLine& parsed_command_line = parameters.command_line; | 93 const base::CommandLine& parsed_command_line = parameters.command_line; |
90 | 94 |
91 #if defined(OS_MACOSX) | 95 #if defined(OS_MACOSX) |
92 base::mac::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool; | 96 base::mac::ScopedNSAutoreleasePool* pool = parameters.autorelease_pool; |
93 #endif // OS_MACOSX | 97 #endif // OS_MACOSX |
94 | 98 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 renderer_scheduler.Pass()); | 197 renderer_scheduler.Pass()); |
194 #endif | 198 #endif |
195 bool run_loop = true; | 199 bool run_loop = true; |
196 if (!no_sandbox) | 200 if (!no_sandbox) |
197 run_loop = platform.EnableSandbox(); | 201 run_loop = platform.EnableSandbox(); |
198 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 202 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
199 RenderProcessImpl render_process; | 203 RenderProcessImpl render_process; |
200 RenderThreadImpl::Create(main_message_loop.Pass(), | 204 RenderThreadImpl::Create(main_message_loop.Pass(), |
201 renderer_scheduler.Pass()); | 205 renderer_scheduler.Pass()); |
202 #endif | 206 #endif |
207 RenderThreadImpl::current()->Send( | |
208 new StartupMetricHostMsg_RecordRendererMainEntryTime( | |
209 renderer_main_entry_time.ToInternalValue())); | |
gab
2015/11/06 18:05:17
I would think the IPC layer already knows how to s
fdoray
2015/11/09 15:53:56
Done.
| |
210 | |
203 base::HighResolutionTimerManager hi_res_timer_manager; | 211 base::HighResolutionTimerManager hi_res_timer_manager; |
204 | 212 |
205 if (run_loop) { | 213 if (run_loop) { |
206 #if defined(OS_MACOSX) | 214 #if defined(OS_MACOSX) |
207 if (pool) | 215 if (pool) |
208 pool->Recycle(); | 216 pool->Recycle(); |
209 #endif | 217 #endif |
210 TRACE_EVENT_ASYNC_BEGIN0("toplevel", "RendererMain.START_MSG_LOOP", 0); | 218 TRACE_EVENT_ASYNC_BEGIN0("toplevel", "RendererMain.START_MSG_LOOP", 0); |
211 base::MessageLoop::current()->Run(); | 219 base::MessageLoop::current()->Run(); |
212 TRACE_EVENT_ASYNC_END0("toplevel", "RendererMain.START_MSG_LOOP", 0); | 220 TRACE_EVENT_ASYNC_END0("toplevel", "RendererMain.START_MSG_LOOP", 0); |
213 } | 221 } |
214 #if defined(LEAK_SANITIZER) | 222 #if defined(LEAK_SANITIZER) |
215 // Run leak detection before RenderProcessImpl goes out of scope. This helps | 223 // Run leak detection before RenderProcessImpl goes out of scope. This helps |
216 // ignore shutdown-only leaks. | 224 // ignore shutdown-only leaks. |
217 __lsan_do_leak_check(); | 225 __lsan_do_leak_check(); |
218 #endif | 226 #endif |
219 } | 227 } |
220 platform.PlatformUninitialize(); | 228 platform.PlatformUninitialize(); |
221 TRACE_EVENT_ASYNC_END0("startup", "RendererMain", 0); | 229 TRACE_EVENT_ASYNC_END0("startup", "RendererMain", 0); |
222 return 0; | 230 return 0; |
223 } | 231 } |
224 | 232 |
225 } // namespace content | 233 } // namespace content |
OLD | NEW |