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 NET_BASE_ADDRESS_TRACKER_LINUX_H_ | 5 #ifndef NET_BASE_ADDRESS_TRACKER_LINUX_H_ |
6 #define NET_BASE_ADDRESS_TRACKER_LINUX_H_ | 6 #define NET_BASE_ADDRESS_TRACKER_LINUX_H_ |
7 | 7 |
8 #include <sys/socket.h> // Needed to include netlink. | 8 #include <sys/socket.h> // Needed to include netlink. |
9 // Mask superfluous definition of |struct net|. This is fixed in Linux 2.6.38. | 9 // Mask superfluous definition of |struct net|. This is fixed in Linux 2.6.38. |
10 #define net net_kernel | 10 #define net net_kernel |
(...skipping 28 matching lines...) Expand all Loading... |
39 AddressTrackerLinux(const base::Closure& address_callback, | 39 AddressTrackerLinux(const base::Closure& address_callback, |
40 const base::Closure& link_callback, | 40 const base::Closure& link_callback, |
41 const base::Closure& tunnel_callback); | 41 const base::Closure& tunnel_callback); |
42 virtual ~AddressTrackerLinux(); | 42 virtual ~AddressTrackerLinux(); |
43 | 43 |
44 // Starts watching system configuration for changes. The current thread must | 44 // Starts watching system configuration for changes. The current thread must |
45 // have a MessageLoopForIO. | 45 // have a MessageLoopForIO. |
46 void Init(); | 46 void Init(); |
47 | 47 |
48 AddressMap GetAddressMap() const; | 48 AddressMap GetAddressMap() const; |
| 49 base::hash_set<int> GetOnlineLinks() const; |
49 | 50 |
50 // Implementation of NetworkChangeNotifierLinux::GetCurrentConnectionType(). | 51 // Implementation of NetworkChangeNotifierLinux::GetCurrentConnectionType(). |
51 // Safe to call from any thread, but will block until Init() has completed. | 52 // Safe to call from any thread, but will block until Init() has completed. |
52 NetworkChangeNotifier::ConnectionType GetCurrentConnectionType(); | 53 NetworkChangeNotifier::ConnectionType GetCurrentConnectionType(); |
53 | 54 |
54 private: | 55 private: |
55 friend class AddressTrackerLinuxTest; | 56 friend class AddressTrackerLinuxTest; |
56 | 57 |
57 // A function that returns the name of an interface given the interface index | 58 // A function that returns the name of an interface given the interface index |
58 // in |interface_index|. | 59 // in |interface_index|. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 base::Closure link_callback_; | 99 base::Closure link_callback_; |
99 base::Closure tunnel_callback_; | 100 base::Closure tunnel_callback_; |
100 | 101 |
101 int netlink_fd_; | 102 int netlink_fd_; |
102 base::MessageLoopForIO::FileDescriptorWatcher watcher_; | 103 base::MessageLoopForIO::FileDescriptorWatcher watcher_; |
103 | 104 |
104 mutable base::Lock address_map_lock_; | 105 mutable base::Lock address_map_lock_; |
105 AddressMap address_map_; | 106 AddressMap address_map_; |
106 | 107 |
107 // Set of interface indices for links that are currently online. | 108 // Set of interface indices for links that are currently online. |
| 109 mutable base::Lock online_links_lock_; |
108 base::hash_set<int> online_links_; | 110 base::hash_set<int> online_links_; |
109 | 111 |
110 base::Lock is_offline_lock_; | 112 base::Lock is_offline_lock_; |
111 bool is_offline_; | 113 bool is_offline_; |
112 bool is_offline_initialized_; | 114 bool is_offline_initialized_; |
113 base::ConditionVariable is_offline_initialized_cv_; | 115 base::ConditionVariable is_offline_initialized_cv_; |
114 }; | 116 }; |
115 | 117 |
116 } // namespace internal | 118 } // namespace internal |
117 } // namespace net | 119 } // namespace net |
118 | 120 |
119 #endif // NET_BASE_ADDRESS_TRACKER_LINUX_H_ | 121 #endif // NET_BASE_ADDRESS_TRACKER_LINUX_H_ |
OLD | NEW |