Chromium Code Reviews| Index: tools/android/forwarder2/host_forwarder_main.cc |
| diff --git a/tools/android/forwarder2/host_forwarder_main.cc b/tools/android/forwarder2/host_forwarder_main.cc |
| index b335bfc6b8a7aa25fa10e934993d655ebe8ad277..10abe29cc07461a139156ca56168699eee1e543a 100644 |
| --- a/tools/android/forwarder2/host_forwarder_main.cc |
| +++ b/tools/android/forwarder2/host_forwarder_main.cc |
| @@ -319,27 +319,28 @@ class HostControllersManager { |
| adb_path.c_str(), |
| serial_part.c_str(), |
| port); |
| - const base::CommandLine command_line(base::SplitString( |
| - command, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)); |
| - int ret; |
| + const std::vector<std::string> split_command = base::SplitString( |
|
Ted C
2017/03/08 04:55:05
maybe a comment here about the need for it to be o
jbudorick
2017/03/08 05:37:40
Done.
|
| + command, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| std::string output; |
| - base::GetAppOutputWithExitCode(command_line, &output, &ret); |
| - LOG(INFO) << command << " ret: " << ret << " output: " << output; |
| + if (!base::GetAppOutputAndError(split_command, &output)) { |
| + LOG(ERROR) << command << " failed. output: " << output; |
| + } else { |
| + LOG(INFO) << command; |
| + } |
| // Wait for the socket to be fully unmapped. |
| const std::string port_mapped_cmd = base::StringPrintf( |
| "lsof -nPi:%d", |
| port); |
| - const base::CommandLine port_mapped_cmd_line( |
| - base::SplitString(port_mapped_cmd, " ", base::TRIM_WHITESPACE, |
| - base::SPLIT_WANT_NONEMPTY)); |
| + const std::vector<std::string> port_mapped_split_cmd = base::SplitString( |
| + port_mapped_cmd, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| const int poll_interval_us = 500 * 1000; |
| int retries = 3; |
| while (retries) { |
| - int port_unmapped; |
| - base::GetAppOutputWithExitCode(port_mapped_cmd_line, &output, |
| - &port_unmapped); |
| - LOG(INFO) << "Device " << device_serial << " port " << port << " unmap " |
| - << port_unmapped; |
| + // lsof failure means the port was successfully unmapped. |
| + bool port_unmapped = |
| + !base::GetAppOutputAndError(port_mapped_split_cmd, &output); |
| + LOG(INFO) << "Device " << device_serial << " port " << port |
| + << (port_unmapped ? "" : " not") << " unmapped"; |
| if (port_unmapped) |
| break; |
| --retries; |
| @@ -364,14 +365,15 @@ class HostControllersManager { |
| adb_path.c_str(), |
| serial_part.c_str(), |
| port); |
| - const base::CommandLine command_line(base::SplitString( |
| - command, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)); |
| - int ret; |
| + const std::vector<std::string> split_command = base::SplitString( |
| + command, " ", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| std::string output; |
| - base::GetAppOutputWithExitCode(command_line, &output, &ret); |
| - LOG(INFO) << command << " ret: " << ret << " output: " << output; |
| - if (ret < 0 || !WIFEXITED(ret) || WEXITSTATUS(ret) != 0) |
| + bool success = base::GetAppOutputAndError(split_command, &output); |
| + if (!success) { |
| + LOG(ERROR) << command << " failed. output: " << output; |
| return -1; |
| + } |
| + LOG(INFO) << command; |
| device_serial_to_adb_port_map_[device_serial] = port; |
| return port; |
| } |