OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 if (merged_list.size() != networks_.size()) { | 310 if (merged_list.size() != networks_.size()) { |
311 *changed = true; | 311 *changed = true; |
312 } | 312 } |
313 | 313 |
314 // If the network list changes, we re-assign |networks_| to the merged list | 314 // If the network list changes, we re-assign |networks_| to the merged list |
315 // and re-sort it. | 315 // and re-sort it. |
316 if (*changed) { | 316 if (*changed) { |
317 networks_ = merged_list; | 317 networks_ = merged_list; |
318 // Reset the active states of all networks. | 318 // Reset the active states of all networks. |
319 for (const auto& kv : networks_map_) { | 319 for (const auto& kv : networks_map_) { |
320 kv.second->set_active(false); | 320 Network* network = kv.second; |
321 } | 321 // If |network| is in the newly generated |networks_|, it is active. |
322 for (Network* network : networks_) { | 322 bool found = std::find(networks_.begin(), networks_.end(), network) != |
323 network->set_active(true); | 323 networks_.end(); |
| 324 network->set_active(found); |
324 } | 325 } |
325 std::sort(networks_.begin(), networks_.end(), SortNetworks); | 326 std::sort(networks_.begin(), networks_.end(), SortNetworks); |
326 // Now network interfaces are sorted, we should set the preference value | 327 // Now network interfaces are sorted, we should set the preference value |
327 // for each of the interfaces we are planning to use. | 328 // for each of the interfaces we are planning to use. |
328 // Preference order of network interfaces might have changed from previous | 329 // Preference order of network interfaces might have changed from previous |
329 // sorting due to addition of higher preference network interface. | 330 // sorting due to addition of higher preference network interface. |
330 // Since we have already sorted the network interfaces based on our | 331 // Since we have already sorted the network interfaces based on our |
331 // requirements, we will just assign a preference value starting with 127, | 332 // requirements, we will just assign a preference value starting with 127, |
332 // in decreasing order. | 333 // in decreasing order. |
333 int pref = kHighestNetworkPreference; | 334 int pref = kHighestNetworkPreference; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 std::stringstream ss; | 919 std::stringstream ss; |
919 // Print out the first space-terminated token of the network desc, plus | 920 // Print out the first space-terminated token of the network desc, plus |
920 // the IP address. | 921 // the IP address. |
921 ss << "Net[" << description_.substr(0, description_.find(' ')) | 922 ss << "Net[" << description_.substr(0, description_.find(' ')) |
922 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ | 923 << ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ |
923 << ":" << AdapterTypeToString(type_) << "]"; | 924 << ":" << AdapterTypeToString(type_) << "]"; |
924 return ss.str(); | 925 return ss.str(); |
925 } | 926 } |
926 | 927 |
927 } // namespace rtc | 928 } // namespace rtc |
OLD | NEW |