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_DEVICE_CONTROLLER_H_ | 5 #ifndef TOOLS_ANDROID_FORWARDER2_DEVICE_CONTROLLER_H_ |
6 #define TOOLS_ANDROID_FORWARDER2_DEVICE_CONTROLLER_H_ | 6 #define TOOLS_ANDROID_FORWARDER2_DEVICE_CONTROLLER_H_ |
7 | 7 |
8 #include <hash_map> | 8 #include <hash_map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/ref_counted.h" | |
14 #include "tools/android/forwarder2/socket.h" | 15 #include "tools/android/forwarder2/socket.h" |
15 | 16 |
17 namespace base { | |
18 class SingleThreadTaskRunner; | |
19 } // namespace base | |
20 | |
16 namespace forwarder2 { | 21 namespace forwarder2 { |
17 | 22 |
18 class DeviceListener; | 23 class DeviceListener; |
19 | 24 |
digit1
2013/07/18 20:08:39
Can I ask you to add a comment describing the purp
Philippe
2013/07/22 15:16:14
Sure, thanks :)
| |
20 class DeviceController { | 25 class DeviceController { |
21 public: | 26 public: |
22 explicit DeviceController(int exit_notifier_fd); | 27 explicit DeviceController(int exit_notifier_fd); |
23 ~DeviceController(); | 28 ~DeviceController(); |
24 | 29 |
25 bool Init(const std::string& adb_unix_socket); | 30 bool Init(const std::string& adb_unix_socket); |
Philippe
2013/07/22 15:16:14
FYI, I also removed this method in favor of a stat
| |
26 | 31 |
27 void Start(); | 32 void Start(); |
28 | 33 |
29 private: | 34 private: |
30 void KillAllListeners(); | 35 void AcceptClientSoon(); |
31 void CleanUpDeadListeners(); | 36 void AcceptClientInternal(); |
37 | |
38 void DeleteListener(int listener_port); | |
39 void DeleteListenerOnTaskRunner(int listener_port); | |
32 | 40 |
33 // Map from Port to DeviceListener objects (owns the pointer). | 41 // Map from Port to DeviceListener objects (owns the pointer). |
34 typedef IDMap<DeviceListener, IDMapOwnPointer> ListenersMap; | 42 typedef IDMap<DeviceListener, IDMapOwnPointer> ListenersMap; |
Philippe
2013/07/22 15:16:14
FYI, I also switched from base::IDMap<> to std::ha
| |
35 | 43 |
44 // Lets delete DeviceListener instances on the thread they were created on | |
45 // (which is DeviceController's construction thread). | |
46 scoped_refptr<base::SingleThreadTaskRunner> listeners_deletion_thread_; | |
47 | |
36 ListenersMap listeners_; | 48 ListenersMap listeners_; |
37 Socket kickstart_adb_socket_; | 49 Socket kickstart_adb_socket_; |
38 | 50 |
39 // Used to notify the controller to exit. | 51 // Used to notify the controller to exit. |
40 const int exit_notifier_fd_; | 52 const int exit_notifier_fd_; |
41 | 53 |
42 DISALLOW_COPY_AND_ASSIGN(DeviceController); | 54 DISALLOW_COPY_AND_ASSIGN(DeviceController); |
43 }; | 55 }; |
44 | 56 |
45 } // namespace forwarder | 57 } // namespace forwarder |
46 | 58 |
47 #endif // TOOLS_ANDROID_FORWARDER2_DEVICE_CONTROLLER_H_ | 59 #endif // TOOLS_ANDROID_FORWARDER2_DEVICE_CONTROLLER_H_ |
OLD | NEW |