Chromium Code Reviews| Index: content/renderer/p2p/ipc_network_manager.cc |
| diff --git a/content/renderer/p2p/ipc_network_manager.cc b/content/renderer/p2p/ipc_network_manager.cc |
| index d1ea5ca5d26560fda2b0802e6b689c77c168d0bd..c40232aa03883f3c5d6d7d9361879e000df43223 100644 |
| --- a/content/renderer/p2p/ipc_network_manager.cc |
| +++ b/content/renderer/p2p/ipc_network_manager.cc |
| @@ -13,10 +13,12 @@ |
| #include "base/sys_byteorder.h" |
| #include "base/thread_task_runner_handle.h" |
| #include "content/public/common/content_switches.h" |
| +#include "jingle/glue/utils.h" |
| #include "net/base/ip_address_number.h" |
| #include "net/base/net_util.h" |
| #include "net/base/network_change_notifier.h" |
| #include "net/base/network_interfaces.h" |
| +#include "third_party/webrtc/base/socketaddress.h" |
| namespace content { |
| @@ -71,32 +73,41 @@ void IpcNetworkManager::StopUpdating() { |
| } |
| void IpcNetworkManager::OnNetworkListChanged( |
| - const net::NetworkInterfaceList& list) { |
| - |
| + const net::NetworkInterfaceList& list, |
| + const net::IPAddressNumber& default_ipv4_local_address, |
| + const net::IPAddressNumber& default_ipv6_local_address) { |
| // Update flag if network list received for the first time. |
| if (!network_list_received_) |
| network_list_received_ = true; |
| + // Update the default local interfaces. |
| + rtc::IPAddress ipv4 = |
|
Sergey Ulanov
2015/11/11 23:23:26
nit: Don't think you need these as variables. Move
guoweis_webrtc
2015/11/11 23:42:31
Done.
|
| + jingle_glue::IPAddressNumberToIPAddress(default_ipv4_local_address); |
| + rtc::IPAddress ipv6 = |
| + jingle_glue::IPAddressNumberToIPAddress(default_ipv6_local_address); |
| + set_default_local_addresses(ipv4, ipv6); |
| + |
| // rtc::Network uses these prefix_length to compare network |
| // interfaces discovered. |
| std::vector<rtc::Network*> networks; |
| for (net::NetworkInterfaceList::const_iterator it = list.begin(); |
| it != list.end(); it++) { |
| + rtc::IPAddress ip_address = |
| + jingle_glue::IPAddressNumberToIPAddress(it->address); |
| + if (ip_address.IsNil()) |
|
Sergey Ulanov
2015/11/11 23:23:26
I think this can be DCHECK(ip_address.IsNil()). We
guoweis_webrtc
2015/11/11 23:42:31
Done.
|
| + continue; |
| + |
| + rtc::IPAddress prefix = rtc::TruncateIP(ip_address, it->prefix_length); |
| + scoped_ptr<rtc::Network> network( |
| + new rtc::Network(it->name, it->name, prefix, it->prefix_length, |
| + ConvertConnectionTypeToAdapterType(it->type))); |
| + network->set_default_local_address_provider(this); |
| + |
| if (it->address.size() == net::kIPv4AddressSize) { |
| - uint32 address; |
| - memcpy(&address, &it->address[0], sizeof(uint32)); |
| - address = rtc::NetworkToHost32(address); |
| - rtc::IPAddress prefix = |
| - rtc::TruncateIP(rtc::IPAddress(address), it->prefix_length); |
| - rtc::Network* network = |
| - new rtc::Network(it->name, it->name, prefix, it->prefix_length, |
| - ConvertConnectionTypeToAdapterType(it->type)); |
| - network->AddIP(rtc::IPAddress(address)); |
| - networks.push_back(network); |
| + network->AddIP(ip_address); |
| + networks.push_back(network.release()); |
| } else if (it->address.size() == net::kIPv6AddressSize) { |
| - in6_addr address; |
| - memcpy(&address, &it->address[0], sizeof(in6_addr)); |
| - rtc::InterfaceAddress ip6_addr(address, it->ip_address_attributes); |
| + rtc::InterfaceAddress ip6_addr(ip_address, it->ip_address_attributes); |
| // Only allow non-deprecated IPv6 addresses which don't contain MAC. |
| if (rtc::IPIsMacBased(ip6_addr) || |
| @@ -105,13 +116,8 @@ void IpcNetworkManager::OnNetworkListChanged( |
| } |
| if (!rtc::IPIsPrivate(ip6_addr)) { |
| - rtc::IPAddress prefix = |
| - rtc::TruncateIP(rtc::IPAddress(ip6_addr), it->prefix_length); |
| - rtc::Network* network = |
| - new rtc::Network(it->name, it->name, prefix, it->prefix_length, |
| - ConvertConnectionTypeToAdapterType(it->type)); |
| network->AddIP(ip6_addr); |
| - networks.push_back(network); |
| + networks.push_back(network.release()); |
|
Sergey Ulanov
2015/11/11 23:23:26
These two lines are still duplicated and that can
guoweis_webrtc
2015/11/11 23:42:31
Done.
|
| } |
| } |
| } |
| @@ -122,6 +128,7 @@ void IpcNetworkManager::OnNetworkListChanged( |
| rtc::IPAddress ip_address_v4(INADDR_LOOPBACK); |
| rtc::Network* network_v4 = new rtc::Network( |
| name_v4, name_v4, ip_address_v4, 32, rtc::ADAPTER_TYPE_UNKNOWN); |
| + network_v4->set_default_local_address_provider(this); |
| network_v4->AddIP(ip_address_v4); |
| networks.push_back(network_v4); |
| @@ -129,6 +136,7 @@ void IpcNetworkManager::OnNetworkListChanged( |
| rtc::IPAddress ip_address_v6(in6addr_loopback); |
| rtc::Network* network_v6 = new rtc::Network( |
| name_v6, name_v6, ip_address_v6, 64, rtc::ADAPTER_TYPE_UNKNOWN); |
| + network_v6->set_default_local_address_provider(this); |
| network_v6->AddIP(ip_address_v6); |
| networks.push_back(network_v6); |
| } |