Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 "\n" | 67 "\n" |
| 68 "Switches: \n" | 68 "Switches: \n" |
| 69 " --battor-path=<path> Uses the specified BattOr path.\n" | 69 " --battor-path=<path> Uses the specified BattOr path.\n" |
| 70 "\n" | 70 "\n" |
| 71 "Once in the shell, you can issue the following commands:\n" | 71 "Once in the shell, you can issue the following commands:\n" |
| 72 "\n" | 72 "\n" |
| 73 " StartTracing\n" | 73 " StartTracing\n" |
| 74 " StopTracing <optional file path>\n" | 74 " StopTracing <optional file path>\n" |
| 75 " SupportsExplicitClockSync\n" | 75 " SupportsExplicitClockSync\n" |
| 76 " RecordClockSyncMarker <marker>\n" | 76 " RecordClockSyncMarker <marker>\n" |
| 77 " Version\n" | |
|
rnephew (Reviews Here)
2016/10/18 22:55:24
Since its a git hash and not version, should I cha
charliea (OOO until 10-5)
2016/10/18 23:46:29
I think "GetFirmwareGitHash" might be better, actu
rnephew (Reviews Here)
2016/10/19 18:23:47
Done.
| |
| 77 " Exit\n" | 78 " Exit\n" |
| 78 " Help\n" | 79 " Help\n" |
| 79 "\n"; | 80 "\n"; |
| 80 | 81 |
| 81 void PrintSupportsExplicitClockSync() { | 82 void PrintSupportsExplicitClockSync() { |
| 82 std::cout << BattOrAgent::SupportsExplicitClockSync() << endl; | 83 std::cout << BattOrAgent::SupportsExplicitClockSync() << endl; |
| 83 } | 84 } |
| 84 | 85 |
| 85 // Logs the error and exits with an error code. | 86 // Logs the error and exits with an error code. |
| 86 void HandleError(battor::BattOrError error) { | 87 void HandleError(battor::BattOrError error) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 } else if (cmd.find("RecordClockSyncMarker") != std::string::npos) { | 194 } else if (cmd.find("RecordClockSyncMarker") != std::string::npos) { |
| 194 std::vector<std::string> tokens = TokenizeString(cmd); | 195 std::vector<std::string> tokens = TokenizeString(cmd); |
| 195 if (tokens.size() != 2 || tokens[0] != "RecordClockSyncMarker") { | 196 if (tokens.size() != 2 || tokens[0] != "RecordClockSyncMarker") { |
| 196 std::cout << "Invalid RecordClockSyncMarker command." << endl; | 197 std::cout << "Invalid RecordClockSyncMarker command." << endl; |
| 197 std::cout << kUsage << endl; | 198 std::cout << kUsage << endl; |
| 198 PostRunNextCommand(); | 199 PostRunNextCommand(); |
| 199 return; | 200 return; |
| 200 } | 201 } |
| 201 | 202 |
| 202 RecordClockSyncMarker(tokens[1]); | 203 RecordClockSyncMarker(tokens[1]); |
| 204 } else if (cmd == "Version") { | |
| 205 GetVersion(); | |
| 206 PostRunNextCommand(); | |
| 203 } else if (cmd == "Exit" || std::cin.eof()) { | 207 } else if (cmd == "Exit" || std::cin.eof()) { |
| 204 ui_thread_message_loop_.task_runner()->PostTask( | 208 ui_thread_message_loop_.task_runner()->PostTask( |
| 205 FROM_HERE, ui_thread_run_loop_.QuitClosure()); | 209 FROM_HERE, ui_thread_run_loop_.QuitClosure()); |
| 206 } else { | 210 } else { |
| 207 std::cout << kUsage << endl; | 211 std::cout << kUsage << endl; |
| 208 PostRunNextCommand(); | 212 PostRunNextCommand(); |
| 209 } | 213 } |
| 210 } | 214 } |
| 211 | 215 |
| 212 void PostRunNextCommand() { | 216 void PostRunNextCommand() { |
| 213 ui_thread_message_loop_.task_runner()->PostTask( | 217 ui_thread_message_loop_.task_runner()->PostTask( |
| 214 FROM_HERE, | 218 FROM_HERE, |
| 215 base::Bind(&BattOrAgentBin::RunNextCommand, base::Unretained(this))); | 219 base::Bind(&BattOrAgentBin::RunNextCommand, base::Unretained(this))); |
| 216 } | 220 } |
| 217 | 221 |
| 222 void GetVersion() { | |
| 223 io_thread_.task_runner()->PostTask( | |
| 224 FROM_HERE, | |
| 225 base::Bind(&BattOrAgent::GetVersion, base::Unretained(agent_.get()))); | |
| 226 } | |
| 227 | |
| 228 void OnGetVersionComplete(const int version, BattOrError error) override { | |
| 229 if (error == BATTOR_ERROR_NONE) | |
| 230 std::cout << version << endl; | |
| 231 else | |
| 232 HandleError(error); | |
| 233 | |
| 234 PostRunNextCommand(); | |
| 235 } | |
| 236 | |
| 218 void StartTracing() { | 237 void StartTracing() { |
| 219 io_thread_.task_runner()->PostTask( | 238 io_thread_.task_runner()->PostTask( |
| 220 FROM_HERE, | 239 FROM_HERE, |
| 221 base::Bind(&BattOrAgent::StartTracing, base::Unretained(agent_.get()))); | 240 base::Bind(&BattOrAgent::StartTracing, base::Unretained(agent_.get()))); |
| 222 } | 241 } |
| 223 | 242 |
| 224 void OnStartTracingComplete(BattOrError error) override { | 243 void OnStartTracingComplete(BattOrError error) override { |
| 225 if (error == BATTOR_ERROR_NONE) | 244 if (error == BATTOR_ERROR_NONE) |
| 226 std::cout << "Done." << endl; | 245 std::cout << "Done." << endl; |
| 227 else | 246 else |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 }; | 336 }; |
| 318 | 337 |
| 319 } // namespace battor | 338 } // namespace battor |
| 320 | 339 |
| 321 int main(int argc, char* argv[]) { | 340 int main(int argc, char* argv[]) { |
| 322 base::AtExitManager exit_manager; | 341 base::AtExitManager exit_manager; |
| 323 base::CommandLine::Init(argc, argv); | 342 base::CommandLine::Init(argc, argv); |
| 324 battor::BattOrAgentBin bin; | 343 battor::BattOrAgentBin bin; |
| 325 return bin.Run(argc, argv); | 344 return bin.Run(argc, argv); |
| 326 } | 345 } |
| OLD | NEW |