Index: net/base/address_tracker_linux.h |
diff --git a/net/base/address_tracker_linux.h b/net/base/address_tracker_linux.h |
index 29cb8c0437d20c841c0c51b630570e97d14fdcd0..cf430a92dd684c4df8006f2fa0f987d77274fc7c 100644 |
--- a/net/base/address_tracker_linux.h |
+++ b/net/base/address_tracker_linux.h |
@@ -12,6 +12,7 @@ |
#undef net |
#include <map> |
+#include <string> |
#include "base/basictypes.h" |
#include "base/callback.h" |
@@ -34,6 +35,9 @@ class NET_EXPORT_PRIVATE AddressTrackerLinux : |
public: |
typedef std::map<IPAddressNumber, struct ifaddrmsg> AddressMap; |
+ // A function that returns the SSID of an interface given the interface name. |
+ typedef std::string (*GetInterfaceSSIDFunction)(const std::string& ifname); |
+ |
// Non-tracking version constructor: it takes a snapshot of the |
// current system configuration. Once Init() returns, the |
// configuration is available through GetOnlineLinks() and |
@@ -65,6 +69,11 @@ class NET_EXPORT_PRIVATE AddressTrackerLinux : |
// Safe to call from any thread, but will block until Init() has completed. |
NetworkChangeNotifier::ConnectionType GetCurrentConnectionType(); |
+ // Implementation of NetworkChangeNotifierLinux::GetCurrentWiFiSSID(). |
+ // Safe to call from any thread. Doesn't wait for initialization to complete, |
+ // so may return empty string. |
+ std::string GetCurrentWiFiSSID(); |
+ |
// 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 |
@@ -72,6 +81,15 @@ class NET_EXPORT_PRIVATE AddressTrackerLinux : |
// with exclusively talking to the kernel and not the C library. |
static char* GetInterfaceName(int interface_index, char* buf); |
+ // Gets the current Wi-Fi SSID based on |interfaces|. Returns |
+ // empty string if there are no interfaces or if two interfaces have different |
+ // connection types. Otherwise returns the SSID of all interfaces if they have |
+ // the same SSID. This is adapted from |
+ // NetworkChangeNotifier::ConnectionTypeFromInterfaceList. |
+ static std::string ConnectionSSIDFromInterfaceList( |
+ const NetworkInterfaceList& interfaces, |
+ GetInterfaceSSIDFunction get_interface_ssid); |
+ |
private: |
friend class AddressTrackerLinuxTest; |
@@ -125,8 +143,9 @@ class NET_EXPORT_PRIVATE AddressTrackerLinux : |
// Does |interface_index| refer to a tunnel interface? |
bool IsTunnelInterface(int interface_index) const; |
- // Updates current_connection_type_ based on the network list. |
- void UpdateCurrentConnectionType(); |
+ // Updates current_connection_type_ and current_wifi_ssid_ based on the |
+ // network list. |
+ void UpdateCurrentConnectionTypeAndSSID(); |
// 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 |
@@ -151,6 +170,10 @@ class NET_EXPORT_PRIVATE AddressTrackerLinux : |
bool connection_type_initialized_; |
base::ConditionVariable connection_type_initialized_cv_; |
NetworkChangeNotifier::ConnectionType current_connection_type_; |
+ |
+ base::Lock wifi_ssid_lock_; |
+ std::string current_wifi_ssid_; |
+ |
bool tracking_; |
// Used to verify single-threaded access in non-tracking mode. |