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

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

Issue 429113002: Webrtc deps roll. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use webrtc version 6825 and rebase and switch back to original workspace. Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/p2p/ipc_network_manager.h ('k') | content/renderer/p2p/ipc_socket_factory.h » ('j') | 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 6
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"
11 #include "content/public/common/content_switches.h" 11 #include "content/public/common/content_switches.h"
12 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 namespace { 16 namespace {
17 17
18 talk_base::AdapterType ConvertConnectionTypeToAdapterType( 18 rtc::AdapterType ConvertConnectionTypeToAdapterType(
19 net::NetworkChangeNotifier::ConnectionType type) { 19 net::NetworkChangeNotifier::ConnectionType type) {
20 switch (type) { 20 switch (type) {
21 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN: 21 case net::NetworkChangeNotifier::CONNECTION_UNKNOWN:
22 return talk_base::ADAPTER_TYPE_UNKNOWN; 22 return rtc::ADAPTER_TYPE_UNKNOWN;
23 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: 23 case net::NetworkChangeNotifier::CONNECTION_ETHERNET:
24 return talk_base::ADAPTER_TYPE_ETHERNET; 24 return rtc::ADAPTER_TYPE_ETHERNET;
25 case net::NetworkChangeNotifier::CONNECTION_WIFI: 25 case net::NetworkChangeNotifier::CONNECTION_WIFI:
26 return talk_base::ADAPTER_TYPE_WIFI; 26 return rtc::ADAPTER_TYPE_WIFI;
27 case net::NetworkChangeNotifier::CONNECTION_2G: 27 case net::NetworkChangeNotifier::CONNECTION_2G:
28 case net::NetworkChangeNotifier::CONNECTION_3G: 28 case net::NetworkChangeNotifier::CONNECTION_3G:
29 case net::NetworkChangeNotifier::CONNECTION_4G: 29 case net::NetworkChangeNotifier::CONNECTION_4G:
30 return talk_base::ADAPTER_TYPE_CELLULAR; 30 return rtc::ADAPTER_TYPE_CELLULAR;
31 default: 31 default:
32 return talk_base::ADAPTER_TYPE_UNKNOWN; 32 return rtc::ADAPTER_TYPE_UNKNOWN;
33 } 33 }
34 } 34 }
35 35
36 } // namespace 36 } // namespace
37 37
38 IpcNetworkManager::IpcNetworkManager(P2PSocketDispatcher* socket_dispatcher) 38 IpcNetworkManager::IpcNetworkManager(P2PSocketDispatcher* socket_dispatcher)
39 : socket_dispatcher_(socket_dispatcher), 39 : socket_dispatcher_(socket_dispatcher),
40 start_count_(0), 40 start_count_(0),
41 network_list_received_(false), 41 network_list_received_(false),
42 weak_factory_(this) { 42 weak_factory_(this) {
(...skipping 23 matching lines...) Expand all
66 66
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 // Note: 32 and 64 are the arbitrary(kind of) prefix length used to 74 // Note: 32 and 64 are the arbitrary(kind of) prefix length used to
75 // differentiate IPv4 and IPv6 addresses. 75 // differentiate IPv4 and IPv6 addresses.
76 // talk_base::Network uses these prefix_length to compare network 76 // rtc::Network uses these prefix_length to compare network
77 // interfaces discovered. 77 // interfaces discovered.
78 std::vector<talk_base::Network*> networks; 78 std::vector<rtc::Network*> networks;
79 int ipv4_interfaces = 0; 79 int ipv4_interfaces = 0;
80 int ipv6_interfaces = 0; 80 int ipv6_interfaces = 0;
81 for (net::NetworkInterfaceList::const_iterator it = list.begin(); 81 for (net::NetworkInterfaceList::const_iterator it = list.begin();
82 it != list.end(); it++) { 82 it != list.end(); it++) {
83 if (it->address.size() == net::kIPv4AddressSize) { 83 if (it->address.size() == net::kIPv4AddressSize) {
84 uint32 address; 84 uint32 address;
85 memcpy(&address, &it->address[0], sizeof(uint32)); 85 memcpy(&address, &it->address[0], sizeof(uint32));
86 address = talk_base::NetworkToHost32(address); 86 address = rtc::NetworkToHost32(address);
87 talk_base::Network* network = new talk_base::Network( 87 rtc::Network* network = new rtc::Network(
88 it->name, it->name, talk_base::IPAddress(address), 32, 88 it->name, it->name, rtc::IPAddress(address), 32,
89 ConvertConnectionTypeToAdapterType(it->type)); 89 ConvertConnectionTypeToAdapterType(it->type));
90 network->AddIP(talk_base::IPAddress(address)); 90 network->AddIP(rtc::IPAddress(address));
91 networks.push_back(network); 91 networks.push_back(network);
92 ++ipv4_interfaces; 92 ++ipv4_interfaces;
93 } else if (it->address.size() == net::kIPv6AddressSize) { 93 } else if (it->address.size() == net::kIPv6AddressSize) {
94 in6_addr address; 94 in6_addr address;
95 memcpy(&address, &it->address[0], sizeof(in6_addr)); 95 memcpy(&address, &it->address[0], sizeof(in6_addr));
96 talk_base::IPAddress ip6_addr(address); 96 rtc::IPAddress ip6_addr(address);
97 if (!talk_base::IPIsPrivate(ip6_addr)) { 97 if (!rtc::IPIsPrivate(ip6_addr)) {
98 talk_base::Network* network = new talk_base::Network( 98 rtc::Network* network = new rtc::Network(
99 it->name, it->name, ip6_addr, 64, 99 it->name, it->name, ip6_addr, 64,
100 ConvertConnectionTypeToAdapterType(it->type)); 100 ConvertConnectionTypeToAdapterType(it->type));
101 network->AddIP(ip6_addr); 101 network->AddIP(ip6_addr);
102 networks.push_back(network); 102 networks.push_back(network);
103 ++ipv6_interfaces; 103 ++ipv6_interfaces;
104 } 104 }
105 } 105 }
106 } 106 }
107 107
108 108
109 // Send interface counts to UMA. 109 // Send interface counts to UMA.
110 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4Interfaces", 110 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv4Interfaces",
111 ipv4_interfaces); 111 ipv4_interfaces);
112 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6Interfaces", 112 UMA_HISTOGRAM_COUNTS_100("WebRTC.PeerConnection.IPv6Interfaces",
113 ipv6_interfaces); 113 ipv6_interfaces);
114 114
115 if (CommandLine::ForCurrentProcess()->HasSwitch( 115 if (CommandLine::ForCurrentProcess()->HasSwitch(
116 switches::kAllowLoopbackInPeerConnection)) { 116 switches::kAllowLoopbackInPeerConnection)) {
117 std::string name_v4("loopback_ipv4"); 117 std::string name_v4("loopback_ipv4");
118 talk_base::IPAddress ip_address_v4(INADDR_LOOPBACK); 118 rtc::IPAddress ip_address_v4(INADDR_LOOPBACK);
119 talk_base::Network* network_v4 = new talk_base::Network( 119 rtc::Network* network_v4 = new rtc::Network(
120 name_v4, name_v4, ip_address_v4, 32, talk_base::ADAPTER_TYPE_UNKNOWN); 120 name_v4, name_v4, ip_address_v4, 32, rtc::ADAPTER_TYPE_UNKNOWN);
121 network_v4->AddIP(ip_address_v4); 121 network_v4->AddIP(ip_address_v4);
122 networks.push_back(network_v4); 122 networks.push_back(network_v4);
123 123
124 std::string name_v6("loopback_ipv6"); 124 std::string name_v6("loopback_ipv6");
125 talk_base::IPAddress ip_address_v6(in6addr_loopback); 125 rtc::IPAddress ip_address_v6(in6addr_loopback);
126 talk_base::Network* network_v6 = new talk_base::Network( 126 rtc::Network* network_v6 = new rtc::Network(
127 name_v6, name_v6, ip_address_v6, 64, talk_base::ADAPTER_TYPE_UNKNOWN); 127 name_v6, name_v6, ip_address_v6, 64, rtc::ADAPTER_TYPE_UNKNOWN);
128 network_v6->AddIP(ip_address_v6); 128 network_v6->AddIP(ip_address_v6);
129 networks.push_back(network_v6); 129 networks.push_back(network_v6);
130 } 130 }
131 131
132 bool changed = false; 132 bool changed = false;
133 MergeNetworkList(networks, &changed); 133 MergeNetworkList(networks, &changed);
134 if (changed) 134 if (changed)
135 SignalNetworksChanged(); 135 SignalNetworksChanged();
136 } 136 }
137 137
138 void IpcNetworkManager::SendNetworksChangedSignal() { 138 void IpcNetworkManager::SendNetworksChangedSignal() {
139 SignalNetworksChanged(); 139 SignalNetworksChanged();
140 } 140 }
141 141
142 } // namespace content 142 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/p2p/ipc_network_manager.h ('k') | content/renderer/p2p/ipc_socket_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698