OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdio.h> | 5 #include <stdio.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <iostream> | 9 #include <iostream> |
10 | 10 |
11 #include "base/base_switches.h" | 11 #include "base/base_switches.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "components/tracing/startup_tracing.h" | |
18 #include "mandoline/app/core_services_initialization.h" | 19 #include "mandoline/app/core_services_initialization.h" |
19 #include "mandoline/app/desktop/launcher_process.h" | 20 #include "mandoline/app/desktop/launcher_process.h" |
20 #include "mojo/runner/context.h" | 21 #include "mojo/runner/context.h" |
21 #include "mojo/runner/switches.h" | 22 #include "mojo/runner/switches.h" |
22 | 23 |
23 namespace mandoline { | 24 namespace mandoline { |
24 namespace { | 25 namespace { |
25 | 26 |
26 // Whether we're currently tracing. | 27 // Whether we're currently tracing. |
27 bool g_tracing = false; | 28 bool g_tracing = false; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 int LauncherProcessMain(int argc, char** argv) { | 82 int LauncherProcessMain(int argc, char** argv) { |
82 const base::CommandLine& command_line = | 83 const base::CommandLine& command_line = |
83 *base::CommandLine::ForCurrentProcess(); | 84 *base::CommandLine::ForCurrentProcess(); |
84 if (command_line.HasSwitch(switches::kTraceStartup)) { | 85 if (command_line.HasSwitch(switches::kTraceStartup)) { |
85 g_tracing = true; | 86 g_tracing = true; |
86 base::trace_event::TraceConfig trace_config( | 87 base::trace_event::TraceConfig trace_config( |
87 command_line.GetSwitchValueASCII(switches::kTraceStartup), | 88 command_line.GetSwitchValueASCII(switches::kTraceStartup), |
88 base::trace_event::RECORD_UNTIL_FULL); | 89 base::trace_event::RECORD_UNTIL_FULL); |
89 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 90 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
90 trace_config, base::trace_event::TraceLog::RECORDING_MODE); | 91 trace_config, base::trace_event::TraceLog::RECORDING_MODE); |
92 } else { | |
93 // |g_tracing| is not touched in this case and Telemetry will stop tracing | |
94 // on demand later. | |
95 tracing::EnableStartupTracingIfConfigFileExists(); | |
sky
2015/06/18 22:18:16
Don't you need to update BUILD.gn for the new dep?
| |
91 } | 96 } |
92 | 97 |
93 // We want the runner::Context to outlive the MessageLoop so that pipes are | 98 // We want the runner::Context to outlive the MessageLoop so that pipes are |
94 // all gracefully closed / error-out before we try to shut the Context down. | 99 // all gracefully closed / error-out before we try to shut the Context down. |
95 mojo::runner::Context shell_context; | 100 mojo::runner::Context shell_context; |
96 InitCoreServicesForContext(&shell_context); | 101 InitCoreServicesForContext(&shell_context); |
97 { | 102 { |
98 base::MessageLoop message_loop; | 103 base::MessageLoop message_loop; |
99 if (!shell_context.Init()) { | 104 if (!shell_context.Init()) { |
100 return 0; | 105 return 0; |
(...skipping 13 matching lines...) Expand all Loading... | |
114 // Must be called before |message_loop| is destroyed. | 119 // Must be called before |message_loop| is destroyed. |
115 shell_context.Shutdown(); | 120 shell_context.Shutdown(); |
116 } | 121 } |
117 | 122 |
118 if (g_tracing) | 123 if (g_tracing) |
119 StopTracingAndFlushToDisk(); | 124 StopTracingAndFlushToDisk(); |
120 return 0; | 125 return 0; |
121 } | 126 } |
122 | 127 |
123 } // namespace mandoline | 128 } // namespace mandoline |
OLD | NEW |