Index: net/base/network_change_notifier_linux.cc |
diff --git a/net/base/network_change_notifier_linux.cc b/net/base/network_change_notifier_linux.cc |
index f77025a33d8904750a0d3e227c59f7086305c09b..82daf7fffa0792ffdf82326a3a9233d752f299fc 100644 |
--- a/net/base/network_change_notifier_linux.cc |
+++ b/net/base/network_change_notifier_linux.cc |
@@ -33,9 +33,12 @@ class NetworkChangeNotifierLinux::Thread : public base::Thread { |
void CleanUp() override; |
private: |
+ void OnIPAddressChanged(); |
+ void OnLinkChanged(); |
scoped_ptr<DnsConfigService> dns_config_service_; |
// Used to detect online/offline state and IP address changes. |
internal::AddressTrackerLinux address_tracker_; |
+ NetworkChangeNotifier::ConnectionType last_type_; |
DISALLOW_COPY_AND_ASSIGN(Thread); |
}; |
@@ -43,11 +46,12 @@ class NetworkChangeNotifierLinux::Thread : public base::Thread { |
NetworkChangeNotifierLinux::Thread::Thread() |
: base::Thread("NetworkChangeNotifier"), |
address_tracker_( |
- base::Bind(&NetworkChangeNotifier:: |
- NotifyObserversOfIPAddressChange), |
- base::Bind(&NetworkChangeNotifier:: |
- NotifyObserversOfConnectionTypeChange), |
- base::Bind(base::DoNothing)) { |
+ base::Bind(&NetworkChangeNotifierLinux::Thread::OnIPAddressChanged, |
+ base::Unretained(this)), |
+ base::Bind(&NetworkChangeNotifierLinux::Thread::OnLinkChanged, |
+ base::Unretained(this)), |
+ base::Bind(base::DoNothing)), |
+ last_type_(NetworkChangeNotifier::CONNECTION_NONE) { |
} |
NetworkChangeNotifierLinux::Thread::~Thread() { |
@@ -65,6 +69,20 @@ void NetworkChangeNotifierLinux::Thread::CleanUp() { |
dns_config_service_.reset(); |
} |
+void NetworkChangeNotifierLinux::Thread::OnIPAddressChanged() { |
+ NetworkChangeNotifier::NotifyObserversOfIPAddressChange(); |
+ // When the IP address of a network interface is added/deleted, the |
+ // connection type may have changed. |
+ OnLinkChanged(); |
+} |
+ |
+void NetworkChangeNotifierLinux::Thread::OnLinkChanged() { |
+ if (last_type_ != GetCurrentConnectionType()) { |
+ NetworkChangeNotifier::NotifyObserversOfConnectionTypeChange(); |
+ last_type_ = GetCurrentConnectionType(); |
+ } |
+} |
+ |
NetworkChangeNotifierLinux* NetworkChangeNotifierLinux::Create() { |
return new NetworkChangeNotifierLinux(); |
} |