| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "mojo/runner/context.h" | 19 #include "mojo/runner/context.h" |
| 19 #include "mojo/runner/switches.h" | 20 #include "mojo/runner/switches.h" |
| 20 | 21 |
| 21 namespace mojo { | 22 namespace mojo { |
| 22 namespace runner { | 23 namespace runner { |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Whether we're currently tracing. | 26 // Whether we're currently tracing. |
| 26 bool g_tracing = false; | 27 bool g_tracing = false; |
| 27 | 28 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 int LauncherProcessMain(int argc, char** argv) { | 81 int LauncherProcessMain(int argc, char** argv) { |
| 81 const base::CommandLine& command_line = | 82 const base::CommandLine& command_line = |
| 82 *base::CommandLine::ForCurrentProcess(); | 83 *base::CommandLine::ForCurrentProcess(); |
| 83 if (command_line.HasSwitch(switches::kTraceStartup)) { | 84 if (command_line.HasSwitch(switches::kTraceStartup)) { |
| 84 g_tracing = true; | 85 g_tracing = true; |
| 85 base::trace_event::TraceConfig trace_config( | 86 base::trace_event::TraceConfig trace_config( |
| 86 command_line.GetSwitchValueASCII(switches::kTraceStartup), | 87 command_line.GetSwitchValueASCII(switches::kTraceStartup), |
| 87 base::trace_event::RECORD_UNTIL_FULL); | 88 base::trace_event::RECORD_UNTIL_FULL); |
| 88 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 89 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 89 trace_config, base::trace_event::TraceLog::RECORDING_MODE); | 90 trace_config, base::trace_event::TraceLog::RECORDING_MODE); |
| 91 } else { |
| 92 // |g_tracing| is not touched in this case and Telemetry will stop tracing |
| 93 // on demand later. |
| 94 tracing::EnableStartupTracingIfConfigFileExists(); |
| 90 } | 95 } |
| 91 | 96 |
| 92 // We want the shell::Context to outlive the MessageLoop so that pipes are | 97 // We want the shell::Context to outlive the MessageLoop so that pipes are |
| 93 // all gracefully closed / error-out before we try to shut the Context down. | 98 // all gracefully closed / error-out before we try to shut the Context down. |
| 94 Context shell_context; | 99 Context shell_context; |
| 95 { | 100 { |
| 96 base::MessageLoop message_loop; | 101 base::MessageLoop message_loop; |
| 97 if (!shell_context.Init()) { | 102 if (!shell_context.Init()) { |
| 98 return 0; | 103 return 0; |
| 99 } | 104 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 112 shell_context.Shutdown(); | 117 shell_context.Shutdown(); |
| 113 } | 118 } |
| 114 | 119 |
| 115 if (g_tracing) | 120 if (g_tracing) |
| 116 StopTracingAndFlushToDisk(); | 121 StopTracingAndFlushToDisk(); |
| 117 return 0; | 122 return 0; |
| 118 } | 123 } |
| 119 | 124 |
| 120 } // namespace runner | 125 } // namespace runner |
| 121 } // namespace mojo | 126 } // namespace mojo |
| OLD | NEW |