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

Unified Diff: tools/android/forwarder2/host_controller.cc

Issue 2385143003: [android] Don't attempt to read a command on failure to start the forwarder. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/android/forwarder2/host_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/forwarder2/host_controller.cc
diff --git a/tools/android/forwarder2/host_controller.cc b/tools/android/forwarder2/host_controller.cc
index 56a9f935a05ef043f3be78084ee73d7676b4eea0..eb49ee99a15f182fe7b5e90d3541b0040a319c9b 100644
--- a/tools/android/forwarder2/host_controller.cc
+++ b/tools/android/forwarder2/host_controller.cc
@@ -123,19 +123,21 @@ void HostController::ReadCommandOnInternalThread() {
<< host_port_;
SendCommand(
command::HOST_SERVER_SUCCESS, device_port_, adb_control_socket_.get());
- StartForwarder(std::move(host_server_data_socket));
+ if (!StartForwarder(std::move(host_server_data_socket))) {
+ OnInternalThreadError();
+ return;
+ }
ReadNextCommandSoon();
}
-void HostController::StartForwarder(
+bool HostController::StartForwarder(
std::unique_ptr<Socket> host_server_data_socket) {
std::unique_ptr<Socket> adb_data_socket(new Socket());
if (!adb_data_socket->ConnectTcp("", adb_port_)) {
LOG(ERROR) << device_serial_
<< ": Could not connect AdbDataSocket on port: "
<< adb_port_;
- OnInternalThreadError();
- return;
+ return false;
}
// Open the Adb data connection, and send a command with the
// |device_forward_port| as a way for the device to identify the connection.
@@ -148,11 +150,11 @@ void HostController::StartForwarder(
adb_control_socket_.get())) {
LOG(ERROR) << device_serial_
<< ": Device could not handle the new Adb Data Connection.";
- OnInternalThreadError();
- return;
+ return false;
}
forwarders_manager_.CreateAndStartNewForwarder(
std::move(host_server_data_socket), std::move(adb_data_socket));
+ return true;
}
void HostController::OnInternalThreadError() {
« no previous file with comments | « tools/android/forwarder2/host_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698