| 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/trace_config_file.h" | 18 #include "components/tracing/startup_tracing.h" |
| 19 #include "components/tracing/tracing_switches.h" | 19 #include "components/tracing/tracing_switches.h" |
| 20 #include "mandoline/app/core_services_initialization.h" | 20 #include "mandoline/app/core_services_initialization.h" |
| 21 #include "mandoline/app/desktop/launcher_process.h" | 21 #include "mandoline/app/desktop/launcher_process.h" |
| 22 #include "mojo/runner/context.h" | 22 #include "mojo/runner/context.h" |
| 23 #include "mojo/runner/switches.h" | 23 #include "mojo/runner/switches.h" |
| 24 | 24 |
| 25 namespace mandoline { | 25 namespace mandoline { |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Whether we're currently tracing. | 28 // Whether we're currently tracing. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 int LauncherProcessMain(int argc, char** argv) { | 83 int LauncherProcessMain(int argc, char** argv) { |
| 84 const base::CommandLine& command_line = | 84 const base::CommandLine& command_line = |
| 85 *base::CommandLine::ForCurrentProcess(); | 85 *base::CommandLine::ForCurrentProcess(); |
| 86 if (command_line.HasSwitch(switches::kTraceStartup)) { | 86 if (command_line.HasSwitch(switches::kTraceStartup)) { |
| 87 g_tracing = true; | 87 g_tracing = true; |
| 88 base::trace_event::TraceConfig trace_config( | 88 base::trace_event::TraceConfig trace_config( |
| 89 command_line.GetSwitchValueASCII(switches::kTraceStartup), | 89 command_line.GetSwitchValueASCII(switches::kTraceStartup), |
| 90 base::trace_event::RECORD_UNTIL_FULL); | 90 base::trace_event::RECORD_UNTIL_FULL); |
| 91 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 91 base::trace_event::TraceLog::GetInstance()->SetEnabled( |
| 92 trace_config, base::trace_event::TraceLog::RECORDING_MODE); | 92 trace_config, base::trace_event::TraceLog::RECORDING_MODE); |
| 93 } else if (tracing::TraceConfigFile::GetInstance()->IsEnabled()) { | 93 } else { |
| 94 g_tracing = true; | 94 // |g_tracing| is not touched in this case and Telemetry will stop tracing |
| 95 base::trace_event::TraceLog::GetInstance()->SetEnabled( | 95 // on demand later. |
| 96 tracing::TraceConfigFile::GetInstance()->GetTraceConfig(), | 96 tracing::EnableStartupTracingIfConfigFileExists(); |
| 97 base::trace_event::TraceLog::RECORDING_MODE); | |
| 98 } | 97 } |
| 99 | 98 |
| 100 // We want the runner::Context to outlive the MessageLoop so that pipes are | 99 // We want the runner::Context to outlive the MessageLoop so that pipes are |
| 101 // all gracefully closed / error-out before we try to shut the Context down. | 100 // all gracefully closed / error-out before we try to shut the Context down. |
| 102 mojo::runner::Context shell_context; | 101 mojo::runner::Context shell_context; |
| 103 InitCoreServicesForContext(&shell_context); | 102 InitCoreServicesForContext(&shell_context); |
| 104 { | 103 { |
| 105 base::MessageLoop message_loop; | 104 base::MessageLoop message_loop; |
| 106 if (!shell_context.Init()) { | 105 if (!shell_context.Init()) { |
| 107 return 0; | 106 return 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 121 // Must be called before |message_loop| is destroyed. | 120 // Must be called before |message_loop| is destroyed. |
| 122 shell_context.Shutdown(); | 121 shell_context.Shutdown(); |
| 123 } | 122 } |
| 124 | 123 |
| 125 if (g_tracing) | 124 if (g_tracing) |
| 126 StopTracingAndFlushToDisk(); | 125 StopTracingAndFlushToDisk(); |
| 127 return 0; | 126 return 0; |
| 128 } | 127 } |
| 129 | 128 |
| 130 } // namespace mandoline | 129 } // namespace mandoline |
| OLD | NEW |