| 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 #ifndef TOOLS_ANDROID_FORWARDER2_HOST_CONTROLLER_H_ | 5 #ifndef TOOLS_ANDROID_FORWARDER2_HOST_CONTROLLER_H_ |
| 6 #define TOOLS_ANDROID_FORWARDER2_HOST_CONTROLLER_H_ | 6 #define TOOLS_ANDROID_FORWARDER2_HOST_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 void Start(); | 51 void Start(); |
| 52 | 52 |
| 53 int adb_port() const { return adb_port_; } | 53 int adb_port() const { return adb_port_; } |
| 54 | 54 |
| 55 int device_port() const { return device_port_; } | 55 int device_port() const { return device_port_; } |
| 56 | 56 |
| 57 private: | 57 private: |
| 58 HostController(int device_port, | 58 HostController(int device_port, |
| 59 int host_port, | 59 int host_port, |
| 60 int adb_port, | 60 int adb_port, |
| 61 int exit_notifier_fd, | |
| 62 const ErrorCallback& error_callback, | 61 const ErrorCallback& error_callback, |
| 63 std::unique_ptr<Socket> adb_control_socket, | 62 std::unique_ptr<Socket> adb_control_socket, |
| 64 std::unique_ptr<PipeNotifier> delete_controller_notifier); | 63 std::unique_ptr<PipeNotifier> delete_controller_notifier); |
| 65 | 64 |
| 66 void ReadNextCommandSoon(); | 65 void ReadNextCommandSoon(); |
| 67 void ReadCommandOnInternalThread(); | 66 void ReadCommandOnInternalThread(); |
| 68 | 67 |
| 69 void StartForwarder(std::unique_ptr<Socket> host_server_data_socket); | 68 void StartForwarder(std::unique_ptr<Socket> host_server_data_socket); |
| 70 | 69 |
| 71 // Note that this gets also called when ~HostController() is invoked. | 70 // Note that this gets also called when ~HostController() is invoked. |
| 72 void OnInternalThreadError(); | 71 void OnInternalThreadError(); |
| 73 | 72 |
| 74 void UnmapPortOnDevice(); | 73 void UnmapPortOnDevice(); |
| 75 | 74 |
| 76 SelfDeleterHelper<HostController> self_deleter_helper_; | 75 SelfDeleterHelper<HostController> self_deleter_helper_; |
| 77 const int device_port_; | 76 const int device_port_; |
| 78 const int host_port_; | 77 const int host_port_; |
| 79 const int adb_port_; | 78 const int adb_port_; |
| 80 // Used to notify the controller when the process is killed. | |
| 81 const int global_exit_notifier_fd_; | |
| 82 std::unique_ptr<Socket> adb_control_socket_; | 79 std::unique_ptr<Socket> adb_control_socket_; |
| 83 // Used to cancel the pending blocking IO operations when the host controller | 80 // Used to cancel the pending blocking IO operations when the host controller |
| 84 // instance is deleted. | 81 // instance is deleted. |
| 85 std::unique_ptr<PipeNotifier> delete_controller_notifier_; | 82 std::unique_ptr<PipeNotifier> delete_controller_notifier_; |
| 86 // Task runner used for deletion set at deletion time (i.e. the object is | 83 // Task runner used for deletion set at deletion time (i.e. the object is |
| 87 // deleted on the same thread it is created on). | 84 // deleted on the same thread it is created on). |
| 88 const scoped_refptr<base::SingleThreadTaskRunner> deletion_task_runner_; | 85 const scoped_refptr<base::SingleThreadTaskRunner> deletion_task_runner_; |
| 89 base::Thread thread_; | 86 base::Thread thread_; |
| 90 ForwardersManager forwarders_manager_; | 87 ForwardersManager forwarders_manager_; |
| 91 | 88 |
| 92 DISALLOW_COPY_AND_ASSIGN(HostController); | 89 DISALLOW_COPY_AND_ASSIGN(HostController); |
| 93 }; | 90 }; |
| 94 | 91 |
| 95 } // namespace forwarder2 | 92 } // namespace forwarder2 |
| 96 | 93 |
| 97 #endif // TOOLS_ANDROID_FORWARDER2_HOST_CONTROLLER_H_ | 94 #endif // TOOLS_ANDROID_FORWARDER2_HOST_CONTROLLER_H_ |
| OLD | NEW |