Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(905)

Unified Diff: chrome/browser/chromeos/trace/sys_trace_agent.cc

Issue 2400163003: arc: enable Android tracing in verified-boot mode (Closed)
Patch Set: Use struct instead of pair to save category data and fix lints Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b14a9b3db5f78700da8de26a5c5ed1f033fe3bea
--- /dev/null
+++ b/chrome/browser/chromeos/trace/sys_trace_agent.cc
@@ -0,0 +1,85 @@
+// 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>
Yusuke Sato 2016/10/12 05:58:12 you can remove this (see my comment below)
shunhsingou 2016/12/22 04:04:34 Done.
+#include <utility>
+
+#include "base/logging.h"
+#include "base/memory/singleton.h"
+#include "base/trace_event/trace_event.h"
Yusuke Sato 2016/10/12 05:58:12 same
shunhsingou 2016/12/22 04:04:34 Done.
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/debug_daemon_client.h"
+#include "components/arc/trace/arc_trace_bridge.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace chromeos {
+
+namespace {
+
+constexpr char kCrosTracingAgentName[] = "cros";
+constexpr 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) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ // 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 =
Yusuke Sato 2016/10/12 05:58:12 chromeos:: seems unnecessary (here and elsewhere)
shunhsingou 2016/12/22 04:04:34 Done.
+ chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
+ // Starts kernel tracing via debugd.
+ if (!debug_daemon)
+ return;
+ debug_daemon->StartAgentTracing(trace_config, callback);
+ // Starts Android framework tracing via ArcTraceBridge.
+ auto* arc_trace_bridge = arc::ArcTraceBridge::Get();
+ if (!arc_trace_bridge)
+ return;
Yusuke Sato 2016/10/12 05:58:12 This path is taken if the user who hasn't opted in
shunhsingou 2016/12/22 04:04:34 Done.
+ arc_trace_bridge->StartTracing(trace_config);
+}
+
+void SysTraceAgent::StopAgentTracing(const StopAgentTracingCallback& callback) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ chromeos::DebugDaemonClient* debug_daemon =
+ chromeos::DBusThreadManager::Get()->GetDebugDaemonClient();
+ debug_daemon->StopAgentTracing(callback);
+
+ auto* arc_trace_bridge = arc::ArcTraceBridge::Get();
+ if (!arc_trace_bridge)
+ return
+ 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() = default;
+SysTraceAgent::~SysTraceAgent() = default;
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698