| Index: tools/battor_agent/battor_agent_bin.cc
|
| diff --git a/tools/battor_agent/battor_agent_bin.cc b/tools/battor_agent/battor_agent_bin.cc
|
| index 5980403dbb8dd93321bf0fb2b8ae10e671aed9e4..9caa3bd32c86285440dfc6bd9c192199e61e50e9 100644
|
| --- a/tools/battor_agent/battor_agent_bin.cc
|
| +++ b/tools/battor_agent/battor_agent_bin.cc
|
| @@ -2,8 +2,16 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +// This file provides a thin binary wrapper around the BattOr Agent
|
| +// library. This binary wrapper provides a means for non-C++ tracing
|
| +// controllers, such as Telemetry and Android Systrace, to issue high-level
|
| +// tracing commands to the BattOr..
|
| +
|
| #include <iostream>
|
|
|
| +#include "base/bind.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/synchronization/waitable_event.h"
|
| #include "tools/battor_agent/battor_agent.h"
|
|
|
| using std::cout;
|
| @@ -12,12 +20,16 @@ using std::string;
|
|
|
| namespace {
|
|
|
| +// An event used to signal that the BattOr Agent has finished executing its
|
| +// command.
|
| +base::WaitableEvent g_stop_tracing_complete_event(false, false);
|
| +
|
| void PrintUsage() {
|
| cout << "Usage: battor_agent <command> <arguments>" << endl << endl
|
| << "Commands:" << endl << endl
|
| << " StartTracing <path>" << endl
|
| << " StopTracing <path>" << endl
|
| - << " SupportsExplicitClockSync <path>" << endl
|
| + << " SupportsExplicitClockSync" << endl
|
| << " RecordClockSyncMarker <path> <marker>" << endl
|
| << " IssueClockSyncMarker <path>" << endl
|
| << " Help" << endl;
|
| @@ -36,6 +48,10 @@ bool GetArg(int argnum, int argc, char* argv[], string* value) {
|
| return true;
|
| }
|
|
|
| +void OnCommandComplete() {
|
| + g_stop_tracing_complete_event.Signal();
|
| +}
|
| +
|
| } // namespace
|
|
|
| int main(int argc, char* argv[]) {
|
| @@ -55,10 +71,12 @@ int main(int argc, char* argv[]) {
|
| if (!GetArg(2, argc, argv, &path))
|
| return 1;
|
|
|
| - string out_trace;
|
| cout << "Calling StopTracing()" << endl;
|
| - battor::BattOrAgent(path).StopTracing(&out_trace);
|
| - cout << out_trace << endl;
|
| + std::string trace_output;
|
| + battor::BattOrAgent(path)
|
| + .StopTracing(&trace_output, base::Bind(&OnCommandComplete));
|
| + g_stop_tracing_complete_event.Wait();
|
| + cout << trace_output << endl;
|
| } else if (cmd == "SupportsExplicitClockSync") {
|
| cout << "Calling SupportsExplicitClockSync" << endl;
|
| cout << battor::BattOrAgent::SupportsExplicitClockSync() << endl;
|
| @@ -69,7 +87,11 @@ int main(int argc, char* argv[]) {
|
|
|
| cout << "Marker: " << marker << endl;
|
| cout << "Calling RecordClockSyncMarker()" << endl;
|
| - battor::BattOrAgent(path).RecordClockSyncMarker(marker);
|
| + // TODO(charliea): Write the time to STDOUT
|
| + battor::BattOrAgent(path)
|
| + .RecordClockSyncMarker(marker, base::Bind(&OnCommandComplete));
|
| + g_stop_tracing_complete_event.Wait();
|
| + // TODO(charliea): Write the time to STDOUT
|
| } else if (cmd == "IssueClockSyncMarker") {
|
| string path;
|
| if (!GetArg(2, argc, argv, &path))
|
|
|