OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/chromeos/trace/sys_trace_agent.h" | |
6 | |
7 #include <string> | |
8 #include <utility> | |
9 | |
10 #include "base/logging.h" | |
11 #include "base/memory/singleton.h" | |
12 #include "base/trace_event/trace_event.h" | |
13 #include "chromeos/dbus/dbus_thread_manager.h" | |
14 #include "chromeos/dbus/debug_daemon_client.h" | |
15 #include "components/arc/trace/arc_trace_bridge.h" | |
16 | |
17 namespace chromeos { | |
18 | |
19 namespace { | |
20 | |
21 const char kCrosTracingAgentName[] = "cros"; | |
Luis Héctor Chávez
2016/10/11 03:38:49
nit: constexpr.
shunhsingou
2016/10/11 07:22:04
Done.
| |
22 const char kCrosTraceLabel[] = "systemTraceEvents"; | |
23 | |
24 } // namespace | |
25 | |
26 std::string SysTraceAgent::GetTracingAgentName() { | |
27 return kCrosTracingAgentName; | |
28 } | |
29 | |
30 std::string SysTraceAgent::GetTraceEventLabel() { | |
31 return kCrosTraceLabel; | |
32 } | |
33 | |
34 void SysTraceAgent::StartAgentTracing( | |
35 const base::trace_event::TraceConfig& trace_config, | |
36 const StartAgentTracingCallback& callback) { | |
37 // Starts the system tracing on Chrome OS. | |
38 // The kernel level tracing is started by debugd via dbus, and the Android | |
39 // framework level tracing is started via mojo interface (ArcTraceBridge). | |
40 // | |
41 // Note that we bind mount /sys/kernel/debug/tracing/trace_marker into the | |
42 // container during initialization. Therefore, both tracing results will be | |
43 // collected by debugd from sysfs. | |
44 chromeos::DebugDaemonClient* debug_daemon = | |
45 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); | |
46 if (debug_daemon) { | |
Luis Héctor Chávez
2016/10/11 03:38:48
nit:
if (!debug_daemon)
return;
shunhsingou
2016/10/11 07:22:05
Done.
| |
47 // Starts kernel tracing via debugd. | |
48 debug_daemon->StartAgentTracing(trace_config, callback); | |
49 LOG(WARNING) << "Tracing ARC Start!!!"; | |
Luis Héctor Chávez
2016/10/11 03:38:48
This does not qualify as a warning. At most it's i
shunhsingou
2016/10/11 07:22:05
Done. It's just for local debugging. Removed.
| |
50 // Starts Android framework tracing via ArcTraceBridge. | |
51 auto* arc_trace_bridge = arc::ArcTraceBridge::Get(); | |
52 if (arc_trace_bridge) arc_trace_bridge->StartTracing(trace_config); | |
Luis Héctor Chávez
2016/10/11 03:38:49
nit:
if (!arc_trace_bridge)
return;
shunhsingou
2016/10/11 07:22:04
Done.
| |
53 } | |
54 } | |
55 | |
56 void SysTraceAgent::StopAgentTracing( | |
Luis Héctor Chávez
2016/10/11 03:38:49
What thread does this run as? This and the rest of
shunhsingou
2016/10/11 07:22:05
Done.
| |
57 const StopAgentTracingCallback& callback) { | |
58 chromeos::DebugDaemonClient* debug_daemon = | |
59 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); | |
60 debug_daemon->StopAgentTracing(callback); | |
61 | |
62 LOG(WARNING) << "Tracing ARC Stop!!!"; | |
63 auto* arc_trace_bridge = arc::ArcTraceBridge::Get(); | |
64 if (arc_trace_bridge) arc_trace_bridge->StopTracing(); | |
65 } | |
66 | |
67 void SysTraceAgent::SetStopAgentTracingTaskRunner( | |
68 scoped_refptr<base::TaskRunner> task_runner) { | |
69 chromeos::DebugDaemonClient* debug_daemon = | |
70 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); | |
71 debug_daemon->SetStopAgentTracingTaskRunner(task_runner); | |
72 } | |
73 | |
74 SysTraceAgent* SysTraceAgent::GetInstance() { | |
75 return base::Singleton<SysTraceAgent>::get(); | |
76 } | |
77 | |
78 SysTraceAgent::SysTraceAgent() {} | |
Luis Héctor Chávez
2016/10/11 03:38:48
nit: = default; same below.
shunhsingou
2016/10/11 07:22:05
Done.
| |
79 SysTraceAgent::~SysTraceAgent() {} | |
80 | |
81 } // namespace chromeos | |
OLD | NEW |