| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 std::cout << "WOOP WOOP"; |
| 223 // io_thread_.task_runner()->PostTask( |
| 224 // FROM_HERE, |
| 225 // base::Bind(&BattOrAgent::Version, 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 PostRunNextCommand(); |
| 234 } |
| 235 |
| 218 void StartTracing() { | 236 void StartTracing() { |
| 219 io_thread_.task_runner()->PostTask( | 237 io_thread_.task_runner()->PostTask( |
| 220 FROM_HERE, | 238 FROM_HERE, |
| 221 base::Bind(&BattOrAgent::StartTracing, base::Unretained(agent_.get()))); | 239 base::Bind(&BattOrAgent::StartTracing, base::Unretained(agent_.get()))); |
| 222 } | 240 } |
| 223 | 241 |
| 224 void OnStartTracingComplete(BattOrError error) override { | 242 void OnStartTracingComplete(BattOrError error) override { |
| 225 if (error == BATTOR_ERROR_NONE) | 243 if (error == BATTOR_ERROR_NONE) |
| 226 std::cout << "Done." << endl; | 244 std::cout << "Done." << endl; |
| 227 else | 245 else |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 }; | 335 }; |
| 318 | 336 |
| 319 } // namespace battor | 337 } // namespace battor |
| 320 | 338 |
| 321 int main(int argc, char* argv[]) { | 339 int main(int argc, char* argv[]) { |
| 322 base::AtExitManager exit_manager; | 340 base::AtExitManager exit_manager; |
| 323 base::CommandLine::Init(argc, argv); | 341 base::CommandLine::Init(argc, argv); |
| 324 battor::BattOrAgentBin bin; | 342 battor::BattOrAgentBin bin; |
| 325 return bin.Run(argc, argv); | 343 return bin.Run(argc, argv); |
| 326 } | 344 } |
| OLD | NEW |