Index: chrome/browser/chromeos/trace/sys_trace_agent.cc |
diff --git a/chrome/browser/chromeos/trace/sys_trace_agent.cc b/chrome/browser/chromeos/trace/sys_trace_agent.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8aa1ec51a5a219a0657f992191984561be793e67 |
--- /dev/null |
+++ b/chrome/browser/chromeos/trace/sys_trace_agent.cc |
@@ -0,0 +1,81 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/chromeos/trace/sys_trace_agent.h" |
+ |
+#include <string> |
+#include <utility> |
+ |
+#include "base/logging.h" |
+#include "base/memory/singleton.h" |
+#include "base/trace_event/trace_event.h" |
+#include "chromeos/dbus/dbus_thread_manager.h" |
+#include "chromeos/dbus/debug_daemon_client.h" |
+#include "components/arc/trace/arc_trace_bridge.h" |
+ |
+namespace chromeos { |
+ |
+namespace { |
+ |
+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.
|
+const char kCrosTraceLabel[] = "systemTraceEvents"; |
+ |
+} // namespace |
+ |
+std::string SysTraceAgent::GetTracingAgentName() { |
+ return kCrosTracingAgentName; |
+} |
+ |
+std::string SysTraceAgent::GetTraceEventLabel() { |
+ return kCrosTraceLabel; |
+} |
+ |
+void SysTraceAgent::StartAgentTracing( |
+ const base::trace_event::TraceConfig& trace_config, |
+ const StartAgentTracingCallback& callback) { |
+ // Starts the system tracing on Chrome OS. |
+ // The kernel level tracing is started by debugd via dbus, and the Android |
+ // framework level tracing is started via mojo interface (ArcTraceBridge). |
+ // |
+ // Note that we bind mount /sys/kernel/debug/tracing/trace_marker into the |
+ // container during initialization. Therefore, both tracing results will be |
+ // collected by debugd from sysfs. |
+ chromeos::DebugDaemonClient* debug_daemon = |
+ chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); |
+ 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.
|
+ // Starts kernel tracing via debugd. |
+ debug_daemon->StartAgentTracing(trace_config, callback); |
+ 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.
|
+ // Starts Android framework tracing via ArcTraceBridge. |
+ auto* arc_trace_bridge = arc::ArcTraceBridge::Get(); |
+ 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.
|
+ } |
+} |
+ |
+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.
|
+ const StopAgentTracingCallback& callback) { |
+ chromeos::DebugDaemonClient* debug_daemon = |
+ chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); |
+ debug_daemon->StopAgentTracing(callback); |
+ |
+ LOG(WARNING) << "Tracing ARC Stop!!!"; |
+ auto* arc_trace_bridge = arc::ArcTraceBridge::Get(); |
+ if (arc_trace_bridge) arc_trace_bridge->StopTracing(); |
+} |
+ |
+void SysTraceAgent::SetStopAgentTracingTaskRunner( |
+ scoped_refptr<base::TaskRunner> task_runner) { |
+ chromeos::DebugDaemonClient* debug_daemon = |
+ chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); |
+ debug_daemon->SetStopAgentTracingTaskRunner(task_runner); |
+} |
+ |
+SysTraceAgent* SysTraceAgent::GetInstance() { |
+ return base::Singleton<SysTraceAgent>::get(); |
+} |
+ |
+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.
|
+SysTraceAgent::~SysTraceAgent() {} |
+ |
+} // namespace chromeos |