Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: net/base/address_tracker_linux.h

Issue 571743002: Adding non-tracking mode support to AddressTracker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add track option in AddressTrackerLinux::Init Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/base/address_tracker_linux.cc » ('j') | net/base/address_tracker_linux.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 typedef std::map<IPAddressNumber, struct ifaddrmsg> AddressMap; 34 typedef std::map<IPAddressNumber, struct ifaddrmsg> AddressMap;
35 35
36 // Will run |address_callback| when the AddressMap changes, |link_callback| 36 // Will run |address_callback| when the AddressMap changes, |link_callback|
37 // when the list of online links changes, and |tunnel_callback| when the list 37 // when the list of online links changes, and |tunnel_callback| when the list
38 // of online tunnels changes. 38 // of online tunnels changes.
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 // When |track| is true, it starts watching system configuration for
45 // have a MessageLoopForIO. 45 // changes. The current thread must have a
46 void Init(); 46 // MessageLoopForIO. Otherwise, the |AddressMap| and |online_links_|
47 // will be a one time snapshot of current system configuration.
48 void Init(bool track);
47 49
48 AddressMap GetAddressMap() const; 50 AddressMap GetAddressMap() const;
51 base::hash_set<int> GetOnlineLinks() const;
49 52
50 // Implementation of NetworkChangeNotifierLinux::GetCurrentConnectionType(). 53 // Implementation of NetworkChangeNotifierLinux::GetCurrentConnectionType().
51 // Safe to call from any thread, but will block until Init() has completed. 54 // Safe to call from any thread, but will block until Init() has completed.
52 NetworkChangeNotifier::ConnectionType GetCurrentConnectionType(); 55 NetworkChangeNotifier::ConnectionType GetCurrentConnectionType();
53 56
54 private: 57 private:
55 friend class AddressTrackerLinuxTest; 58 friend class AddressTrackerLinuxTest;
56 59
57 // A function that returns the name of an interface given the interface index 60 // A function that returns the name of an interface given the interface index
58 // in |interface_index|. 61 // in |interface_index|.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 base::Closure link_callback_; 101 base::Closure link_callback_;
99 base::Closure tunnel_callback_; 102 base::Closure tunnel_callback_;
100 103
101 int netlink_fd_; 104 int netlink_fd_;
102 base::MessageLoopForIO::FileDescriptorWatcher watcher_; 105 base::MessageLoopForIO::FileDescriptorWatcher watcher_;
103 106
104 mutable base::Lock address_map_lock_; 107 mutable base::Lock address_map_lock_;
105 AddressMap address_map_; 108 AddressMap address_map_;
106 109
107 // Set of interface indices for links that are currently online. 110 // Set of interface indices for links that are currently online.
111 mutable base::Lock online_links_lock_;
108 base::hash_set<int> online_links_; 112 base::hash_set<int> online_links_;
109 113
110 base::Lock is_offline_lock_; 114 base::Lock is_offline_lock_;
111 bool is_offline_; 115 bool is_offline_;
112 bool is_offline_initialized_; 116 bool is_offline_initialized_;
113 base::ConditionVariable is_offline_initialized_cv_; 117 base::ConditionVariable is_offline_initialized_cv_;
114 }; 118 };
115 119
116 } // namespace internal 120 } // namespace internal
117 } // namespace net 121 } // namespace net
118 122
119 #endif // NET_BASE_ADDRESS_TRACKER_LINUX_H_ 123 #endif // NET_BASE_ADDRESS_TRACKER_LINUX_H_
OLDNEW
« no previous file with comments | « no previous file | net/base/address_tracker_linux.cc » ('j') | net/base/address_tracker_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698