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 tracing::EnableStartupTracingIfConfigFileExists(); | |
yzshen1
2015/06/16 23:44:58
I haven't looked at the code very closely. In this
Zhen Wang
2015/06/16 23:49:00
Yes. This is expected. So the existing way is to u
| |
90 } | 93 } |
91 | 94 |
92 // We want the shell::Context to outlive the MessageLoop so that pipes are | 95 // 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. | 96 // all gracefully closed / error-out before we try to shut the Context down. |
94 Context shell_context; | 97 Context shell_context; |
95 { | 98 { |
96 base::MessageLoop message_loop; | 99 base::MessageLoop message_loop; |
97 if (!shell_context.Init()) { | 100 if (!shell_context.Init()) { |
98 return 0; | 101 return 0; |
99 } | 102 } |
(...skipping 12 matching lines...) Expand all Loading... | |
112 shell_context.Shutdown(); | 115 shell_context.Shutdown(); |
113 } | 116 } |
114 | 117 |
115 if (g_tracing) | 118 if (g_tracing) |
116 StopTracingAndFlushToDisk(); | 119 StopTracingAndFlushToDisk(); |
117 return 0; | 120 return 0; |
118 } | 121 } |
119 | 122 |
120 } // namespace runner | 123 } // namespace runner |
121 } // namespace mojo | 124 } // namespace mojo |
OLD | NEW |