Fix two problems in network.cc:
1. It signals network changed events whenever there are more than one IP address in a network.
2. It does not signal network changed events if a network disconnects and connects again.
Also changed DumpNetworks for better debugging.
BUG=webrtc:5096
Review URL: https://codereview.webrtc.org/1421433003
Cr-Commit-Position: refs/heads/master@{#11107}
diff --git a/webrtc/base/network.h b/webrtc/base/network.h
index 8980b5d..d2e013e 100644
--- a/webrtc/base/network.h
+++ b/webrtc/base/network.h
@@ -111,11 +111,10 @@
// TODO(guoweis): remove this body when chromium implements this.
virtual void GetAnyAddressNetworks(NetworkList* networks) {}
+ // Dumps the current list of networks in the network manager.
+ virtual void DumpNetworks() {}
bool GetDefaultLocalAddress(int family, IPAddress* ipaddr) const override;
- // Dumps a list of networks available to LS_INFO.
- virtual void DumpNetworks(bool include_ignored) {}
-
struct Stats {
int ipv4_network_count;
int ipv6_network_count;
@@ -195,8 +194,7 @@
void StartUpdating() override;
void StopUpdating() override;
- // Logs the available networks.
- void DumpNetworks(bool include_ignored) override;
+ void DumpNetworks() override;
// MessageHandler interface.
void OnMessage(Message* msg) override;
@@ -359,6 +357,12 @@
int preference() const { return preference_; }
void set_preference(int preference) { preference_ = preference; }
+ // When we enumerate networks and find a previously-seen network is missing,
+ // we do not remove it (because it may be used elsewhere). Instead, we mark
+ // it inactive, so that we can detect network changes properly.
+ bool active() const { return active_; }
+ void set_active(bool active) { active_ = active; }
+
// Debugging description of this network
std::string ToString() const;
@@ -374,6 +378,7 @@
bool ignored_;
AdapterType type_;
int preference_;
+ bool active_ = true;
friend class NetworkManager;
};