Commit 5c7acf2d authored by Charlie Andrews's avatar Charlie Andrews Committed by Commit Bot

Remove the BattOr power_tracing agent from Chrome tracing

As decided in https://goo.gl/g5Srzn, we're no longer doing BattOr power
measurement on the waterfall and consequently can't justify maintaining
the significant C++ code required to do interactive BattOr tracing.

This is the first Chrome-side CL to delete that code.

(For additional context, see https://goo.gl/P9AR84 (google internal)
or ping me to chat.)

TBR=avi for BUILD.gn

Bug: 859514
Change-Id: I4b6c0c6ac40abe9c593ce24e1bb0d68a4eeacd42
Reviewed-on: https://chromium-review.googlesource.com/1122489
Commit-Queue: Charlie Andrews <charliea@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avataroysteine <oysteine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579055}
parent 6f9db5e7
......@@ -1889,13 +1889,6 @@ jumbo_source_set("browser") {
"//content/browser/tracing:resources",
]
}
if ((use_udev && is_posix) || is_mac || is_win) {
deps += [ "//tools/battor_agent:battor_agent_lib" ]
sources += [
"tracing/power_tracing_agent.cc",
"tracing/power_tracing_agent.h",
]
}
# Desktop/Window/WebContents screen capture implementations, conditionally
# built depending on the available implementations for each platform.
......
// Copyright 2015 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 "content/browser/tracing/power_tracing_agent.h"
#include <utility>
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/memory/singleton.h"
#include "base/task_scheduler/post_task.h"
#include "base/task_scheduler/task_traits.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "base/trace_event/trace_config.h"
#include "base/trace_event/trace_event_impl.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/tracing/public/mojom/constants.mojom.h"
#include "tools/battor_agent/battor_finder.h"
namespace content {
namespace {
const char kPowerTraceLabel[] = "powerTraceAsString";
} // namespace
// static
PowerTracingAgent* PowerTracingAgent::GetInstance() {
return base::Singleton<PowerTracingAgent>::get();
}
PowerTracingAgent::PowerTracingAgent(service_manager::Connector* connector)
: binding_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Connect to the agent registry interface.
tracing::mojom::AgentRegistryPtr agent_registry;
connector->BindInterface(tracing::mojom::kServiceName, &agent_registry);
// Register this agent.
tracing::mojom::AgentPtr agent;
binding_.Bind(mojo::MakeRequest(&agent));
agent_registry->RegisterAgent(
std::move(agent), kPowerTraceLabel, tracing::mojom::TraceDataType::STRING,
true /* supports_explicit_clock_sync */, base::kNullProcessId);
}
PowerTracingAgent::PowerTracingAgent() : binding_(this) {}
PowerTracingAgent::~PowerTracingAgent() = default;
void PowerTracingAgent::StartTracing(const std::string& config,
base::TimeTicks coordinator_time,
Agent::StartTracingCallback callback) {
base::trace_event::TraceConfig trace_config(config);
if (!trace_config.IsSystraceEnabled()) {
std::move(callback).Run(false /* success */);
return;
}
base::PostTaskWithTraits(
FROM_HERE, {base::TaskPriority::BEST_EFFORT, base::MayBlock()},
base::BindOnce(&PowerTracingAgent::FindBattOrOnBackgroundThread,
base::Unretained(this), std::move(callback)));
}
void PowerTracingAgent::FindBattOrOnBackgroundThread(
Agent::StartTracingCallback callback) {
std::string path = battor::BattOrFinder::FindBattOr();
if (path.empty()) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback), false /* success */));
return;
}
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&PowerTracingAgent::StartTracingOnIOThread,
base::Unretained(this), path, std::move(callback)));
}
void PowerTracingAgent::StartTracingOnIOThread(
const std::string& path,
Agent::StartTracingCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
battor_agent_.reset(new battor::BattOrAgent(
path, this, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)));
start_tracing_callback_ = std::move(callback);
battor_agent_->StartTracing();
}
void PowerTracingAgent::OnStartTracingComplete(battor::BattOrError error) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
bool success = (error == battor::BATTOR_ERROR_NONE);
if (!success)
battor_agent_.reset();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(start_tracing_callback_), success));
}
void PowerTracingAgent::StopAndFlush(tracing::mojom::RecorderPtr recorder) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&PowerTracingAgent::StopAndFlushOnIOThread,
base::Unretained(this), std::move(recorder)));
}
void PowerTracingAgent::StopAndFlushOnIOThread(
tracing::mojom::RecorderPtr recorder) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
// This makes sense only when the battor agent exists.
if (battor_agent_) {
recorder_ = std::move(recorder);
battor_agent_->StopTracing();
}
}
void PowerTracingAgent::OnStopTracingComplete(
const battor::BattOrResults& results,
battor::BattOrError error) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (error == battor::BATTOR_ERROR_NONE)
recorder_->AddChunk(results.ToString());
recorder_.reset();
battor_agent_.reset();
}
void PowerTracingAgent::RequestClockSyncMarker(
const std::string& sync_id,
Agent::RequestClockSyncMarkerCallback callback) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&PowerTracingAgent::RequestClockSyncMarkerOnIOThread,
base::Unretained(this), sync_id, std::move(callback)));
}
void PowerTracingAgent::RequestClockSyncMarkerOnIOThread(
const std::string& sync_id,
Agent::RequestClockSyncMarkerCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
// This makes sense only when the battor agent exists.
if (!battor_agent_) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback), base::TimeTicks(),
base::TimeTicks()));
return;
}
request_clock_sync_marker_callback_ = std::move(callback);
request_clock_sync_marker_start_time_ = TRACE_TIME_TICKS_NOW();
battor_agent_->RecordClockSyncMarker(sync_id);
}
void PowerTracingAgent::OnRecordClockSyncMarkerComplete(
battor::BattOrError error) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
base::TimeTicks issue_start_ts = request_clock_sync_marker_start_time_;
base::TimeTicks issue_end_ts = TRACE_TIME_TICKS_NOW();
if (error != battor::BATTOR_ERROR_NONE)
issue_start_ts = issue_end_ts = base::TimeTicks();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(request_clock_sync_marker_callback_),
issue_start_ts, issue_end_ts));
request_clock_sync_marker_start_time_ = base::TimeTicks();
}
void PowerTracingAgent::OnGetFirmwareGitHashComplete(
const std::string& version, battor::BattOrError error) {
return;
}
void PowerTracingAgent::GetCategories(Agent::GetCategoriesCallback callback) {
std::move(callback).Run("");
}
void PowerTracingAgent::RequestBufferStatus(
Agent::RequestBufferStatusCallback callback) {
std::move(callback).Run(0, 0);
}
} // namespace content
// Copyright 2015 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.
#ifndef CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_
#define CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_
#include <memory>
#include <string>
#include "base/macros.h"
#include "base/memory/ref_counted_memory.h"
#include "base/threading/thread.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/tracing/public/mojom/tracing.mojom.h"
#include "tools/battor_agent/battor_agent.h"
#include "tools/battor_agent/battor_error.h"
namespace base {
template <typename Type>
struct DefaultSingletonTraits;
} // namespace base
namespace service_manager {
class Connector;
} // namespace service_manager
namespace content {
using tracing::mojom::Agent;
class PowerTracingAgent : public Agent, public battor::BattOrAgent::Listener {
public:
// Retrieve the singleton instance.
static PowerTracingAgent* GetInstance();
explicit PowerTracingAgent(service_manager::Connector* connector);
// BattOrAgent::Listener implementation.
void OnStartTracingComplete(battor::BattOrError error) override;
void OnStopTracingComplete(const battor::BattOrResults& results,
battor::BattOrError error) override;
void OnRecordClockSyncMarkerComplete(battor::BattOrError error) override;
void OnGetFirmwareGitHashComplete(const std::string& version,
battor::BattOrError error) override;
private:
// This allows constructor and destructor to be private and usable only
// by the Singleton class.
friend struct base::DefaultSingletonTraits<PowerTracingAgent>;
friend std::default_delete<PowerTracingAgent>;
PowerTracingAgent();
~PowerTracingAgent() override;
// tracing::mojom::Agent. Called by Mojo internals on the UI thread.
void StartTracing(const std::string& config,
base::TimeTicks coordinator_time,
Agent::StartTracingCallback callback) override;
void StopAndFlush(tracing::mojom::RecorderPtr recorder) override;
void RequestClockSyncMarker(
const std::string& sync_id,
Agent::RequestClockSyncMarkerCallback callback) override;
void GetCategories(Agent::GetCategoriesCallback callback) override;
void RequestBufferStatus(
Agent::RequestBufferStatusCallback callback) override;
void FindBattOrOnBackgroundThread(Agent::StartTracingCallback callback);
void StartTracingOnIOThread(const std::string& path,
Agent::StartTracingCallback callback);
void StopAndFlushOnIOThread(tracing::mojom::RecorderPtr recorder);
void RequestClockSyncMarkerOnIOThread(
const std::string& sync_id,
Agent::RequestClockSyncMarkerCallback callback);
// Returns the path of a BattOr (e.g. /dev/ttyUSB0), or an empty string if
// none are found.
std::string GetBattOrPath();
// All interactions with the BattOrAgent (after construction) must happen on
// the IO thread.
std::unique_ptr<battor::BattOrAgent, BrowserThread::DeleteOnIOThread>
battor_agent_;
Agent::StartTracingCallback start_tracing_callback_;
tracing::mojom::RecorderPtr recorder_;
base::TimeTicks request_clock_sync_marker_start_time_;
Agent::RequestClockSyncMarkerCallback request_clock_sync_marker_callback_;
mojo::Binding<tracing::mojom::Agent> binding_;
DISALLOW_COPY_AND_ASSIGN(PowerTracingAgent);
};
} // namespace content
#endif // CONTENT_BROWSER_TRACING_POWER_TRACING_AGENT_H_
......@@ -38,15 +38,6 @@
#include "services/tracing/public/mojom/constants.mojom.h"
#include "v8/include/v8-version-string.h"
#if (defined(OS_POSIX) && defined(USE_UDEV)) || defined(OS_WIN) || \
defined(OS_MACOSX)
#define ENABLE_POWER_TRACING
#endif
#if defined(ENABLE_POWER_TRACING)
#include "content/browser/tracing/power_tracing_agent.h"
#endif
#if defined(OS_CHROMEOS)
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/debug_daemon_client.h"
......@@ -140,11 +131,6 @@ void TracingControllerImpl::AddAgents() {
content::ServiceManagerConnection::GetForProcess()->GetConnector();
connector->BindInterface(tracing::mojom::kServiceName, &coordinator_);
// Register tracing agents.
#if defined(ENABLE_POWER_TRACING)
agents_.push_back(std::make_unique<PowerTracingAgent>(connector));
#endif
#if defined(OS_CHROMEOS)
agents_.push_back(std::make_unique<CrOSTracingAgent>(connector));
#elif defined(CAST_TRACING_AGENT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment