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

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

Issue 739983005: Determine connection type in NetworkChangeNotifierLinux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from patch set 3 Created 5 years, 11 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 base::Lock& lock); 76 base::Lock& lock);
77 ~AddressTrackerAutoLock(); 77 ~AddressTrackerAutoLock();
78 78
79 private: 79 private:
80 const AddressTrackerLinux& tracker_; 80 const AddressTrackerLinux& tracker_;
81 base::Lock& lock_; 81 base::Lock& lock_;
82 DISALLOW_COPY_AND_ASSIGN(AddressTrackerAutoLock); 82 DISALLOW_COPY_AND_ASSIGN(AddressTrackerAutoLock);
83 }; 83 };
84 84
85 // A function that returns the name of an interface given the interface index 85 // A function that returns the name of an interface given the interface index
86 // in |interface_index|. 86 // in |interface_index|. |ifname| should be a buffer of size IFNAMSIZ. The
87 typedef const char* (*GetInterfaceNameFunction)(int interface_index); 87 // function should return a pointer to |ifname|.
88 88 typedef char* (*GetInterfaceNameFunction)(unsigned int interface_index,
pauljensen 2015/01/15 15:05:10 Let's put this back to "int" as ifi_index and ifr_
derekjchow1 2015/01/15 20:32:51 Done. Also changed GetInterfaceNameFunction in net
89 char* ifname);
89 // Sets |*address_changed| to indicate whether |address_map_| changed and 90 // Sets |*address_changed| to indicate whether |address_map_| changed and
90 // sets |*link_changed| to indicate if |online_links_| changed and sets 91 // sets |*link_changed| to indicate if |online_links_| changed and sets
91 // |*tunnel_changed| to indicate if |online_links_| changed with regards to a 92 // |*tunnel_changed| to indicate if |online_links_| changed with regards to a
92 // tunnel interface while reading messages from |netlink_fd_|. 93 // tunnel interface while reading messages from |netlink_fd_|.
93 void ReadMessages(bool* address_changed, 94 void ReadMessages(bool* address_changed,
94 bool* link_changed, 95 bool* link_changed,
95 bool* tunnel_changed); 96 bool* tunnel_changed);
96 97
97 // Sets |*address_changed| to true if |address_map_| changed, sets 98 // Sets |*address_changed| to true if |address_map_| changed, sets
98 // |*link_changed| to true if |online_links_| changed, sets |*tunnel_changed| 99 // |*link_changed| to true if |online_links_| changed, sets |*tunnel_changed|
(...skipping 11 matching lines...) Expand all
110 // MessageLoopForIO::Watcher: 111 // MessageLoopForIO::Watcher:
111 void OnFileCanReadWithoutBlocking(int fd) override; 112 void OnFileCanReadWithoutBlocking(int fd) override;
112 void OnFileCanWriteWithoutBlocking(int /* fd */) override; 113 void OnFileCanWriteWithoutBlocking(int /* fd */) override;
113 114
114 // Close |netlink_fd_| 115 // Close |netlink_fd_|
115 void CloseSocket(); 116 void CloseSocket();
116 117
117 // Does |msg| refer to a tunnel interface? 118 // Does |msg| refer to a tunnel interface?
118 bool IsTunnelInterface(const struct ifinfomsg* msg) const; 119 bool IsTunnelInterface(const struct ifinfomsg* msg) const;
119 120
121 // Updates current_connection_type_ based on the network list.
122 void UpdateCurrentConnectionType();
123
120 // Gets the name of an interface given the interface index |interface_index|. 124 // Gets the name of an interface given the interface index |interface_index|.
121 // May return empty string if it fails but should not return NULL. This is 125 // May return empty string if it fails but should not return NULL. This is
122 // overridden by tests. 126 // overridden by tests.
123 GetInterfaceNameFunction get_interface_name_; 127 GetInterfaceNameFunction get_interface_name_;
124 128
125 base::Closure address_callback_; 129 base::Closure address_callback_;
126 base::Closure link_callback_; 130 base::Closure link_callback_;
127 base::Closure tunnel_callback_; 131 base::Closure tunnel_callback_;
128 132
129 int netlink_fd_; 133 int netlink_fd_;
130 base::MessageLoopForIO::FileDescriptorWatcher watcher_; 134 base::MessageLoopForIO::FileDescriptorWatcher watcher_;
131 135
132 mutable base::Lock address_map_lock_; 136 mutable base::Lock address_map_lock_;
133 AddressMap address_map_; 137 AddressMap address_map_;
134 138
135 // Set of interface indices for links that are currently online. 139 // Set of interface indices for links that are currently online.
136 mutable base::Lock online_links_lock_; 140 mutable base::Lock online_links_lock_;
137 base::hash_set<int> online_links_; 141 base::hash_set<int> online_links_;
138 142
139 base::Lock is_offline_lock_; 143 base::Lock connection_type_lock_;
140 bool is_offline_; 144 bool connection_type_initialized_;
141 bool is_offline_initialized_; 145 base::ConditionVariable connection_type_initialized_cv_;
142 base::ConditionVariable is_offline_initialized_cv_; 146 NetworkChangeNotifier::ConnectionType current_connection_type_;
143 bool tracking_; 147 bool tracking_;
144 148
145 // Used to verify single-threaded access in non-tracking mode. 149 // Used to verify single-threaded access in non-tracking mode.
146 base::ThreadChecker thread_checker_; 150 base::ThreadChecker thread_checker_;
147 }; 151 };
148 152
149 } // namespace internal 153 } // namespace internal
150 } // namespace net 154 } // namespace net
151 155
152 #endif // NET_BASE_ADDRESS_TRACKER_LINUX_H_ 156 #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