From 2b116774d45296e8ad76725bd762873a56760e5b Mon Sep 17 00:00:00 2001 From: guoweis Date: Mon, 9 Feb 2015 14:27:03 -0800 Subject: [PATCH] Use network counting from webrtc for UMA. Chrome passes each IP address in its own Network object. These IPv4Interfaces and IPv6Interfaces are really counting the number of IP addresses, not interfaces. To make these UMA accurate, a new stats struct is returned from WebRTC's MergeNetworkList which should control the grouping policy of IP addresses into network. BUG=413437 Review URL: https://codereview.chromium.org/905663002 Cr-Commit-Position: refs/heads/master@{#315409} --- content/renderer/p2p/ipc_network_manager.cc | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/content/renderer/p2p/ipc_network_manager.cc b/content/renderer/p2p/ipc_network_manager.cc index f1db22b5f844..ac7661209b51 100644 --- a/content/renderer/p2p/ipc_network_manager.cc +++ b/content/renderer/p2p/ipc_network_manager.cc @@ -74,8 +74,6 @@ void IpcNetworkManager::OnNetworkListChanged( // rtc::Network uses these prefix_length to compare network // interfaces discovered. std::vector networks; - int ipv4_interfaces = 0; - int ipv6_interfaces = 0; for (net::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); it++) { if (it->address.size() == net::kIPv4AddressSize) { @@ -89,7 +87,6 @@ void IpcNetworkManager::OnNetworkListChanged( ConvertConnectionTypeToAdapterType(it->type)); network->AddIP(rtc::IPAddress(address)); networks.push_back(network); - ++ipv4_interfaces; } else if (it->address.size() == net::kIPv6AddressSize) { in6_addr address; memcpy(&address, &it->address[0], sizeof(in6_addr)); @@ -102,18 +99,10 @@ void IpcNetworkManager::OnNetworkListChanged( ConvertConnectionTypeToAdapterType(it->type)); network->AddIP(ip6_addr); networks.push_back(network); - ++ipv6_interfaces; } } } - - // Send interface counts to UMA. - UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4Interfaces", - ipv4_interfaces); - UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6Interfaces", - ipv6_interfaces); - if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kAllowLoopbackInPeerConnection)) { std::string name_v4("loopback_ipv4"); @@ -132,9 +121,16 @@ void IpcNetworkManager::OnNetworkListChanged( } bool changed = false; - MergeNetworkList(networks, &changed); + NetworkManager::Stats stats; + MergeNetworkList(networks, &changed, &stats); if (changed) SignalNetworksChanged(); + + // Send interface counts to UMA. + UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4Interfaces", + stats.ipv4_network_count); + UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6Interfaces", + stats.ipv6_network_count); } void IpcNetworkManager::SendNetworksChangedSignal() { -- 2.11.4.GIT