| 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/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 const ErrorCallback& error_callback, | 72 const ErrorCallback& error_callback, |
| 73 scoped_ptr<Socket> adb_control_socket, | 73 scoped_ptr<Socket> adb_control_socket, |
| 74 scoped_ptr<PipeNotifier> delete_controller_notifier) | 74 scoped_ptr<PipeNotifier> delete_controller_notifier) |
| 75 : self_deleter_helper_(this, error_callback), | 75 : self_deleter_helper_(this, error_callback), |
| 76 device_port_(device_port), | 76 device_port_(device_port), |
| 77 host_port_(host_port), | 77 host_port_(host_port), |
| 78 adb_port_(adb_port), | 78 adb_port_(adb_port), |
| 79 global_exit_notifier_fd_(exit_notifier_fd), | 79 global_exit_notifier_fd_(exit_notifier_fd), |
| 80 adb_control_socket_(adb_control_socket.Pass()), | 80 adb_control_socket_(adb_control_socket.Pass()), |
| 81 delete_controller_notifier_(delete_controller_notifier.Pass()), | 81 delete_controller_notifier_(delete_controller_notifier.Pass()), |
| 82 deletion_task_runner_(base::MessageLoopProxy::current()), | 82 deletion_task_runner_(base::MessageLoop::current()->task_runner()), |
| 83 thread_("HostControllerThread") { | 83 thread_("HostControllerThread") {} |
| 84 } | |
| 85 | 84 |
| 86 void HostController::ReadNextCommandSoon() { | 85 void HostController::ReadNextCommandSoon() { |
| 87 thread_.message_loop_proxy()->PostTask( | 86 thread_.task_runner()->PostTask( |
| 88 FROM_HERE, | 87 FROM_HERE, base::Bind(&HostController::ReadCommandOnInternalThread, |
| 89 base::Bind(&HostController::ReadCommandOnInternalThread, | 88 base::Unretained(this))); |
| 90 base::Unretained(this))); | |
| 91 } | 89 } |
| 92 | 90 |
| 93 void HostController::ReadCommandOnInternalThread() { | 91 void HostController::ReadCommandOnInternalThread() { |
| 94 if (!ReceivedCommand(command::ACCEPT_SUCCESS, adb_control_socket_.get())) { | 92 if (!ReceivedCommand(command::ACCEPT_SUCCESS, adb_control_socket_.get())) { |
| 95 LOG(ERROR) << "Did not receive ACCEPT_SUCCESS for port: " | 93 LOG(ERROR) << "Did not receive ACCEPT_SUCCESS for port: " |
| 96 << host_port_; | 94 << host_port_; |
| 97 OnInternalThreadError(); | 95 OnInternalThreadError(); |
| 98 return; | 96 return; |
| 99 } | 97 } |
| 100 // Try to connect to host server. | 98 // Try to connect to host server. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 LOG(ERROR) << "Could not send unmap command for port " << device_port_; | 159 LOG(ERROR) << "Could not send unmap command for port " << device_port_; |
| 162 return; | 160 return; |
| 163 } | 161 } |
| 164 if (!ReceivedCommand(command::UNLISTEN_SUCCESS, &socket)) { | 162 if (!ReceivedCommand(command::UNLISTEN_SUCCESS, &socket)) { |
| 165 LOG(ERROR) << "Unamp command failed for port " << device_port_; | 163 LOG(ERROR) << "Unamp command failed for port " << device_port_; |
| 166 return; | 164 return; |
| 167 } | 165 } |
| 168 } | 166 } |
| 169 | 167 |
| 170 } // namespace forwarder2 | 168 } // namespace forwarder2 |
| OLD | NEW |