OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "tools/android/forwarder2/host_controller.h" | 5 #include "tools/android/forwarder2/host_controller.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 forwarder->Start(); | 61 forwarder->Start(); |
62 } | 62 } |
63 | 63 |
64 bool HostController::Connect() { | 64 bool HostController::Connect() { |
65 if (!adb_control_socket_.ConnectTcp("", adb_port_)) { | 65 if (!adb_control_socket_.ConnectTcp("", adb_port_)) { |
66 LOG(ERROR) << "Could not Connect HostController socket on port: " | 66 LOG(ERROR) << "Could not Connect HostController socket on port: " |
67 << adb_port_; | 67 << adb_port_; |
68 return false; | 68 return false; |
69 } | 69 } |
70 // Send the command to the device start listening to the "device_forward_port" | 70 // Send the command to the device start listening to the "device_forward_port" |
71 SendCommand(command::LISTEN, device_port_, &adb_control_socket_); | 71 bool send_command_success = SendCommand( |
| 72 command::LISTEN, device_port_, &adb_control_socket_); |
| 73 CHECK(send_command_success); |
72 int device_port_allocated; | 74 int device_port_allocated; |
73 command::Type command; | 75 command::Type command; |
74 if (!ReadCommand(&adb_control_socket_, &device_port_allocated, &command) || | 76 if (!ReadCommand(&adb_control_socket_, &device_port_allocated, &command) || |
75 command != command::BIND_SUCCESS) { | 77 command != command::BIND_SUCCESS) { |
76 LOG(ERROR) << "Device binding error using port " << device_port_; | 78 LOG(ERROR) << "Device binding error using port " << device_port_; |
77 adb_control_socket_.Close(); | 79 adb_control_socket_.Close(); |
78 return false; | 80 return false; |
79 } | 81 } |
80 // When doing dynamically allocation of port, we get the port from the | 82 // When doing dynamically allocation of port, we get the port from the |
81 // BIND_SUCCESS command we received above. | 83 // BIND_SUCCESS command we received above. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 116 } |
115 SendCommand(command::HOST_SERVER_SUCCESS, | 117 SendCommand(command::HOST_SERVER_SUCCESS, |
116 device_port_, | 118 device_port_, |
117 &adb_control_socket_); | 119 &adb_control_socket_); |
118 StartForwarder(host_server_data_socket.Pass()); | 120 StartForwarder(host_server_data_socket.Pass()); |
119 } | 121 } |
120 adb_control_socket_.Close(); | 122 adb_control_socket_.Close(); |
121 } | 123 } |
122 | 124 |
123 } // namespace forwarder2 | 125 } // namespace forwarder2 |
OLD | NEW |