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

Side by Side Diff: tools/battor_agent/battor_agent_bin.cc

Issue 2390893002: [BattOr] Make BattOr able to return firmware version. (Closed)
Patch Set: [BattOr] Make BattOr able to return firmware version. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file provides a thin binary wrapper around the BattOr Agent 5 // This file provides a thin binary wrapper around the BattOr Agent
6 // library. This binary wrapper provides a means for non-C++ tracing 6 // library. This binary wrapper provides a means for non-C++ tracing
7 // controllers, such as Telemetry and Android Systrace, to issue high-level 7 // controllers, such as Telemetry and Android Systrace, to issue high-level
8 // tracing commands to the BattOr through an interactive shell. 8 // tracing commands to the BattOr through an interactive shell.
9 // 9 //
10 // Example usage of how an external trace controller might use this binary: 10 // Example usage of how an external trace controller might use this binary:
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } else if (cmd.find("RecordClockSyncMarker") != std::string::npos) { 193 } else if (cmd.find("RecordClockSyncMarker") != std::string::npos) {
194 std::vector<std::string> tokens = TokenizeString(cmd); 194 std::vector<std::string> tokens = TokenizeString(cmd);
195 if (tokens.size() != 2 || tokens[0] != "RecordClockSyncMarker") { 195 if (tokens.size() != 2 || tokens[0] != "RecordClockSyncMarker") {
196 std::cout << "Invalid RecordClockSyncMarker command." << endl; 196 std::cout << "Invalid RecordClockSyncMarker command." << endl;
197 std::cout << kUsage << endl; 197 std::cout << kUsage << endl;
198 PostRunNextCommand(); 198 PostRunNextCommand();
199 return; 199 return;
200 } 200 }
201 201
202 RecordClockSyncMarker(tokens[1]); 202 RecordClockSyncMarker(tokens[1]);
203 } else if (cmd == "Version") {
204 GetVersion();
205 PostRunNextCommand();
203 } else if (cmd == "Exit" || std::cin.eof()) { 206 } else if (cmd == "Exit" || std::cin.eof()) {
204 ui_thread_message_loop_.task_runner()->PostTask( 207 ui_thread_message_loop_.task_runner()->PostTask(
205 FROM_HERE, ui_thread_run_loop_.QuitClosure()); 208 FROM_HERE, ui_thread_run_loop_.QuitClosure());
206 } else { 209 } else {
207 std::cout << kUsage << endl; 210 std::cout << kUsage << endl;
208 PostRunNextCommand(); 211 PostRunNextCommand();
209 } 212 }
210 } 213 }
211 214
212 void PostRunNextCommand() { 215 void PostRunNextCommand() {
213 ui_thread_message_loop_.task_runner()->PostTask( 216 ui_thread_message_loop_.task_runner()->PostTask(
214 FROM_HERE, 217 FROM_HERE,
215 base::Bind(&BattOrAgentBin::RunNextCommand, base::Unretained(this))); 218 base::Bind(&BattOrAgentBin::RunNextCommand, base::Unretained(this)));
216 } 219 }
217 220
221 void GetVersion() {
222 io_thread_.task_runner()->PostTask(
223 FROM_HERE,
224 base::Bind(&BattOrAgent::GetVersion, base::Unretained(agent_.get())));
225 }
226
227 void OnGetVersionComplete(const int version, BattOrError error) override {
228 if (error == BATTOR_ERROR_NONE)
229 std::cout << version << endl;
230 else
231 HandleError(error);
232 PostRunNextCommand();
233 }
234
218 void StartTracing() { 235 void StartTracing() {
219 io_thread_.task_runner()->PostTask( 236 io_thread_.task_runner()->PostTask(
220 FROM_HERE, 237 FROM_HERE,
221 base::Bind(&BattOrAgent::StartTracing, base::Unretained(agent_.get()))); 238 base::Bind(&BattOrAgent::StartTracing, base::Unretained(agent_.get())));
222 } 239 }
223 240
224 void OnStartTracingComplete(BattOrError error) override { 241 void OnStartTracingComplete(BattOrError error) override {
225 if (error == BATTOR_ERROR_NONE) 242 if (error == BATTOR_ERROR_NONE)
226 std::cout << "Done." << endl; 243 std::cout << "Done." << endl;
227 else 244 else
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 }; 334 };
318 335
319 } // namespace battor 336 } // namespace battor
320 337
321 int main(int argc, char* argv[]) { 338 int main(int argc, char* argv[]) {
322 base::AtExitManager exit_manager; 339 base::AtExitManager exit_manager;
323 base::CommandLine::Init(argc, argv); 340 base::CommandLine::Init(argc, argv);
324 battor::BattOrAgentBin bin; 341 battor::BattOrAgentBin bin;
325 return bin.Run(argc, argv); 342 return bin.Run(argc, argv);
326 } 343 }
OLDNEW
« tools/battor_agent/battor_agent.cc ('K') | « tools/battor_agent/battor_agent.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698