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

Unified 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: Test ethtool for CONNECTION_ETHERNET 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/address_tracker_linux.cc » ('j') | net/base/address_tracker_linux.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/address_tracker_linux.h
diff --git a/net/base/address_tracker_linux.h b/net/base/address_tracker_linux.h
index a960287d4ad2abd2270ace41cd6596b13b6b5a94..c7f4d14e605d13775c67b723683a94783a62fe1e 100644
--- a/net/base/address_tracker_linux.h
+++ b/net/base/address_tracker_linux.h
@@ -65,6 +65,13 @@ class NET_EXPORT_PRIVATE AddressTrackerLinux :
// Safe to call from any thread, but will block until Init() has completed.
NetworkChangeNotifier::ConnectionType GetCurrentConnectionType();
+ // Returns the name for the interface with interface index |interface_index|.
+ // |buf| should be a pointer to an array of size IFNAMSIZ. The returned
+ // pointer will point to |buf|. This function acts like if_indextoname which
+ // cannot be used as net/if.h cannot be mixed with linux/if.h. We'll stick
+ // with exclusively talking to the kernel and not the C library.
+ static char* GetInterfaceName(int interface_index, char* buf);
+
private:
friend class AddressTrackerLinuxTest;
@@ -83,8 +90,9 @@ class NET_EXPORT_PRIVATE AddressTrackerLinux :
};
// A function that returns the name of an interface given the interface index
- // in |interface_index|.
- typedef const char* (*GetInterfaceNameFunction)(int interface_index);
+ // in |interface_index|. |ifname| should be a buffer of size IFNAMSIZ. The
+ // function should return a pointer to |ifname|.
+ typedef char* (*GetInterfaceNameFunction)(int interface_index, char* ifname);
// Sets |*address_changed| to indicate whether |address_map_| changed and
// sets |*link_changed| to indicate if |online_links_| changed and sets
@@ -117,6 +125,9 @@ class NET_EXPORT_PRIVATE AddressTrackerLinux :
// Does |msg| refer to a tunnel interface?
bool IsTunnelInterface(const struct ifinfomsg* msg) const;
+ // Updates current_connection_type_ based on the network list.
+ void UpdateCurrentConnectionType();
+
// Gets the name of an interface given the interface index |interface_index|.
// May return empty string if it fails but should not return NULL. This is
// overridden by tests.
@@ -136,10 +147,10 @@ class NET_EXPORT_PRIVATE AddressTrackerLinux :
mutable base::Lock online_links_lock_;
base::hash_set<int> online_links_;
- base::Lock is_offline_lock_;
- bool is_offline_;
- bool is_offline_initialized_;
- base::ConditionVariable is_offline_initialized_cv_;
+ base::Lock connection_type_lock_;
+ bool connection_type_initialized_;
+ base::ConditionVariable connection_type_initialized_cv_;
+ NetworkChangeNotifier::ConnectionType current_connection_type_;
bool tracking_;
// Used to verify single-threaded access in non-tracking mode.
« 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