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

Unified Diff: net/base/network_change_notifier_linux.cc

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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 | « net/base/network_change_notifier.cc ('k') | net/base/network_change_notifier_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « net/base/network_change_notifier.cc ('k') | net/base/network_change_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698