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

Side by Side Diff: content/renderer/p2p/ipc_network_manager.cc

Issue 905663002: Use network counting from webrtc for UMA. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/p2p/ipc_network_manager.h" 5 #include "content/renderer/p2p/ipc_network_manager.h"
6 #include <string> 6 #include <string>
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/sys_byteorder.h" 10 #include "base/sys_byteorder.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void IpcNetworkManager::OnNetworkListChanged( 67 void IpcNetworkManager::OnNetworkListChanged(
68 const net::NetworkInterfaceList& list) { 68 const net::NetworkInterfaceList& list) {
69 69
70 // Update flag if network list received for the first time. 70 // Update flag if network list received for the first time.
71 if (!network_list_received_) 71 if (!network_list_received_)
72 network_list_received_ = true; 72 network_list_received_ = true;
73 73
74 // rtc::Network uses these prefix_length to compare network 74 // rtc::Network uses these prefix_length to compare network
75 // interfaces discovered. 75 // interfaces discovered.
76 std::vector<rtc::Network*> networks; 76 std::vector<rtc::Network*> networks;
77 int ipv4_interfaces = 0;
78 int ipv6_interfaces = 0;
79 for (net::NetworkInterfaceList::const_iterator it = list.begin(); 77 for (net::NetworkInterfaceList::const_iterator it = list.begin();
80 it != list.end(); it++) { 78 it != list.end(); it++) {
81 if (it->address.size() == net::kIPv4AddressSize) { 79 if (it->address.size() == net::kIPv4AddressSize) {
82 uint32 address; 80 uint32 address;
83 memcpy(&address, &it->address[0], sizeof(uint32)); 81 memcpy(&address, &it->address[0], sizeof(uint32));
84 address = rtc::NetworkToHost32(address); 82 address = rtc::NetworkToHost32(address);
85 rtc::IPAddress prefix = 83 rtc::IPAddress prefix =
86 rtc::TruncateIP(rtc::IPAddress(address), it->prefix_length); 84 rtc::TruncateIP(rtc::IPAddress(address), it->prefix_length);
87 rtc::Network* network = 85 rtc::Network* network =
88 new rtc::Network(it->name, it->name, prefix, it->prefix_length, 86 new rtc::Network(it->name, it->name, prefix, it->prefix_length,
89 ConvertConnectionTypeToAdapterType(it->type)); 87 ConvertConnectionTypeToAdapterType(it->type));
90 network->AddIP(rtc::IPAddress(address)); 88 network->AddIP(rtc::IPAddress(address));
91 networks.push_back(network); 89 networks.push_back(network);
92 ++ipv4_interfaces;
93 } else if (it->address.size() == net::kIPv6AddressSize) { 90 } else if (it->address.size() == net::kIPv6AddressSize) {
94 in6_addr address; 91 in6_addr address;
95 memcpy(&address, &it->address[0], sizeof(in6_addr)); 92 memcpy(&address, &it->address[0], sizeof(in6_addr));
96 rtc::IPAddress ip6_addr(address); 93 rtc::IPAddress ip6_addr(address);
97 if (!rtc::IPIsPrivate(ip6_addr)) { 94 if (!rtc::IPIsPrivate(ip6_addr)) {
98 rtc::IPAddress prefix = 95 rtc::IPAddress prefix =
99 rtc::TruncateIP(rtc::IPAddress(ip6_addr), it->prefix_length); 96 rtc::TruncateIP(rtc::IPAddress(ip6_addr), it->prefix_length);
100 rtc::Network* network = 97 rtc::Network* network =
101 new rtc::Network(it->name, it->name, prefix, it->prefix_length, 98 new rtc::Network(it->name, it->name, prefix, it->prefix_length,
102 ConvertConnectionTypeToAdapterType(it->type)); 99 ConvertConnectionTypeToAdapterType(it->type));
103 network->AddIP(ip6_addr); 100 network->AddIP(ip6_addr);
104 networks.push_back(network); 101 networks.push_back(network);
105 ++ipv6_interfaces;
106 } 102 }
107 } 103 }
108 } 104 }
109 105
110
111 // Send interface counts to UMA.
112 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4Interfaces",
113 ipv4_interfaces);
114 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6Interfaces",
115 ipv6_interfaces);
116
117 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 106 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
118 switches::kAllowLoopbackInPeerConnection)) { 107 switches::kAllowLoopbackInPeerConnection)) {
119 std::string name_v4("loopback_ipv4"); 108 std::string name_v4("loopback_ipv4");
120 rtc::IPAddress ip_address_v4(INADDR_LOOPBACK); 109 rtc::IPAddress ip_address_v4(INADDR_LOOPBACK);
121 rtc::Network* network_v4 = new rtc::Network( 110 rtc::Network* network_v4 = new rtc::Network(
122 name_v4, name_v4, ip_address_v4, 32, rtc::ADAPTER_TYPE_UNKNOWN); 111 name_v4, name_v4, ip_address_v4, 32, rtc::ADAPTER_TYPE_UNKNOWN);
123 network_v4->AddIP(ip_address_v4); 112 network_v4->AddIP(ip_address_v4);
124 networks.push_back(network_v4); 113 networks.push_back(network_v4);
125 114
126 std::string name_v6("loopback_ipv6"); 115 std::string name_v6("loopback_ipv6");
127 rtc::IPAddress ip_address_v6(in6addr_loopback); 116 rtc::IPAddress ip_address_v6(in6addr_loopback);
128 rtc::Network* network_v6 = new rtc::Network( 117 rtc::Network* network_v6 = new rtc::Network(
129 name_v6, name_v6, ip_address_v6, 64, rtc::ADAPTER_TYPE_UNKNOWN); 118 name_v6, name_v6, ip_address_v6, 64, rtc::ADAPTER_TYPE_UNKNOWN);
130 network_v6->AddIP(ip_address_v6); 119 network_v6->AddIP(ip_address_v6);
131 networks.push_back(network_v6); 120 networks.push_back(network_v6);
132 } 121 }
133 122
134 bool changed = false; 123 bool changed = false;
135 MergeNetworkList(networks, &changed); 124 NetworkManager::Stats stats;
136 if (changed) 125 MergeNetworkList(networks, &changed, &stats);
126 if (changed) {
Sergey Ulanov 2015/02/09 19:23:59 remove {} here or add them in lines 71-72, to make
137 SignalNetworksChanged(); 127 SignalNetworksChanged();
128 }
129
130 // Send interface counts to UMA.
131 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4Interfaces",
132 stats.ipv4_network_count);
133 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6Interfaces",
134 stats.ipv6_network_count);
138 } 135 }
139 136
140 void IpcNetworkManager::SendNetworksChangedSignal() { 137 void IpcNetworkManager::SendNetworksChangedSignal() {
141 SignalNetworksChanged(); 138 SignalNetworksChanged();
142 } 139 }
143 140
144 } // namespace content 141 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698