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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "tools/android/forwarder2/pipe_notifier.h" |
13 #include "tools/android/forwarder2/socket.h" | 14 #include "tools/android/forwarder2/socket.h" |
14 #include "tools/android/forwarder2/thread.h" | 15 #include "tools/android/forwarder2/thread.h" |
15 | 16 |
16 namespace forwarder2 { | 17 namespace forwarder2 { |
17 | 18 |
18 class HostProxy; | 19 class HostProxy; |
19 | 20 |
20 class HostController : public Thread { | 21 class HostController : public Thread { |
21 public: | 22 public: |
22 // If |device_port| is zero, it dynamically allocates a port. | 23 // If |device_port| is zero, it dynamically allocates a port. |
(...skipping 13 matching lines...) Expand all Loading... |
36 // Gets the current device allocated port. Must be called after Connect(). | 37 // Gets the current device allocated port. Must be called after Connect(). |
37 int device_port() const { return device_port_; } | 38 int device_port() const { return device_port_; } |
38 | 39 |
39 protected: | 40 protected: |
40 // Thread: | 41 // Thread: |
41 virtual void Run() OVERRIDE; | 42 virtual void Run() OVERRIDE; |
42 | 43 |
43 private: | 44 private: |
44 void StartForwarder(scoped_ptr<Socket> host_server_data_socket_ptr); | 45 void StartForwarder(scoped_ptr<Socket> host_server_data_socket_ptr); |
45 | 46 |
| 47 // Helper method that creates a socket and adds the appropriate event file |
| 48 // descriptors. |
| 49 scoped_ptr<Socket> CreateSocket(); |
| 50 |
46 Socket adb_control_socket_; | 51 Socket adb_control_socket_; |
47 int device_port_; | 52 int device_port_; |
48 const std::string forward_to_host_; | 53 const std::string forward_to_host_; |
49 const int forward_to_host_port_; | 54 const int forward_to_host_port_; |
50 const int adb_port_; | 55 const int adb_port_; |
51 | 56 |
52 // Used to notify the controller to exit. | 57 // Used to notify the controller when the process is killed. |
53 const int exit_notifier_fd_; | 58 const int global_exit_notifier_fd_; |
| 59 // Used to cancel the pending blocking IO operations when the host controller |
| 60 // instance is deleted. |
| 61 PipeNotifier delete_controller_notifier_; |
54 | 62 |
55 bool ready_; | 63 bool ready_; |
56 | 64 |
57 DISALLOW_COPY_AND_ASSIGN(HostController); | 65 DISALLOW_COPY_AND_ASSIGN(HostController); |
58 }; | 66 }; |
59 | 67 |
60 } // namespace forwarder2 | 68 } // namespace forwarder2 |
61 | 69 |
62 #endif // TOOLS_ANDROID_FORWARDER2_HOST_CONTROLLER_H_ | 70 #endif // TOOLS_ANDROID_FORWARDER2_HOST_CONTROLLER_H_ |
OLD | NEW |