OLD | NEW |
---|---|
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/sys_byteorder.h" | 8 #include "base/sys_byteorder.h" |
9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 void IpcNetworkManager::OnNetworkListChanged( | 42 void IpcNetworkManager::OnNetworkListChanged( |
43 const net::NetworkInterfaceList& list) { | 43 const net::NetworkInterfaceList& list) { |
44 | 44 |
45 // Update flag if network list received for the first time. | 45 // Update flag if network list received for the first time. |
46 if (!network_list_received_) | 46 if (!network_list_received_) |
47 network_list_received_ = true; | 47 network_list_received_ = true; |
48 | 48 |
49 std::vector<talk_base::Network*> networks; | 49 std::vector<talk_base::Network*> networks; |
50 for (net::NetworkInterfaceList::const_iterator it = list.begin(); | 50 for (net::NetworkInterfaceList::const_iterator it = list.begin(); |
51 it != list.end(); it++) { | 51 it != list.end(); it++) { |
52 uint32 address; | 52 if (it->address.size() == net::kIPv4AddressSize) { |
53 if (it->address.size() != net::kIPv4AddressSize) | 53 uint32 address; |
54 continue; | 54 memcpy(&address, &it->address[0], sizeof(uint32)); |
55 memcpy(&address, &it->address[0], sizeof(uint32)); | 55 address = talk_base::NetworkToHost32(address); |
56 address = talk_base::NetworkToHost32(address); | 56 talk_base::Network* network = new talk_base::Network( |
57 talk_base::Network* network = new talk_base::Network( | 57 it->name, it->name, talk_base::IPAddress(address), 32); |
Ronghua Wu (Left Chromium)
2013/10/18 23:38:28
Should we use NetworkInterface::network_prefix as
Mallinath (Gone from Chromium)
2013/10/19 00:09:39
Now it's more aligned with the libjingle native co
| |
58 it->name, it->name, talk_base::IPAddress(address), 32); | 58 network->AddIP(talk_base::IPAddress(address)); |
59 network->AddIP(talk_base::IPAddress(address)); | 59 networks.push_back(network); |
60 networks.push_back(network); | 60 } else if (it->address.size() == net::kIPv6AddressSize) { |
61 in6_addr address; | |
62 memcpy(&address, &it->address[0], sizeof(in6_addr)); | |
63 talk_base::IPAddress ip6_addr(address); | |
64 talk_base::Network* network = new talk_base::Network( | |
65 it->name, it->name, ip6_addr, 64); | |
Ronghua Wu (Left Chromium)
2013/10/18 23:38:28
dito
Mallinath (Gone from Chromium)
2013/10/19 00:09:39
same as above.
On 2013/10/18 23:38:28, Ronghua Wu
| |
66 network->AddIP(ip6_addr); | |
67 networks.push_back(network); | |
68 } | |
61 } | 69 } |
62 | 70 |
63 bool changed = false; | 71 bool changed = false; |
64 MergeNetworkList(networks, &changed); | 72 MergeNetworkList(networks, &changed); |
65 if (changed) | 73 if (changed) |
66 SignalNetworksChanged(); | 74 SignalNetworksChanged(); |
67 } | 75 } |
68 | 76 |
69 void IpcNetworkManager::SendNetworksChangedSignal() { | 77 void IpcNetworkManager::SendNetworksChangedSignal() { |
70 SignalNetworksChanged(); | 78 SignalNetworksChanged(); |
71 } | 79 } |
72 | 80 |
73 } // namespace content | 81 } // namespace content |
OLD | NEW |