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

Side by Side Diff: webrtc/p2p/client/basicportallocator.cc

Issue 1987833002: Add a flag to filter out high-cost networks. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: merge with head Created 4 years, 6 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 | « webrtc/p2p/base/portallocator.h ('k') | webrtc/p2p/client/basicportallocator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 network_manager->GetAnyAddressNetworks(networks); 410 network_manager->GetAnyAddressNetworks(networks);
411 } else { 411 } else {
412 network_manager->GetNetworks(networks); 412 network_manager->GetNetworks(networks);
413 } 413 }
414 networks->erase(std::remove_if(networks->begin(), networks->end(), 414 networks->erase(std::remove_if(networks->begin(), networks->end(),
415 [this](rtc::Network* network) { 415 [this](rtc::Network* network) {
416 return allocator_->network_ignore_mask() & 416 return allocator_->network_ignore_mask() &
417 network->type(); 417 network->type();
418 }), 418 }),
419 networks->end()); 419 networks->end());
420
421 if (flags() & PORTALLOCATOR_DISABLE_COSTLY_NETWORKS) {
422 uint16_t lowest_cost = rtc::kNetworkCostMax;
423 for (rtc::Network* network : *networks) {
424 lowest_cost = std::min<uint16_t>(lowest_cost, network->GetCost());
425 }
426 networks->erase(std::remove_if(networks->begin(), networks->end(),
427 [lowest_cost](rtc::Network* network) {
428 return network->GetCost() >
429 lowest_cost + rtc::kNetworkCostLow;
430 }),
431 networks->end());
432 }
420 } 433 }
421 434
422 // For each network, see if we have a sequence that covers it already. If not, 435 // For each network, see if we have a sequence that covers it already. If not,
423 // create a new sequence to create the appropriate ports. 436 // create a new sequence to create the appropriate ports.
424 void BasicPortAllocatorSession::DoAllocate() { 437 void BasicPortAllocatorSession::DoAllocate() {
425 bool done_signal_needed = false; 438 bool done_signal_needed = false;
426 std::vector<rtc::Network*> networks; 439 std::vector<rtc::Network*> networks;
427 GetNetworks(&networks); 440 GetNetworks(&networks);
428 441
429 if (networks.empty()) { 442 if (networks.empty()) {
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 ServerAddresses servers; 1235 ServerAddresses servers;
1223 for (size_t i = 0; i < relays.size(); ++i) { 1236 for (size_t i = 0; i < relays.size(); ++i) {
1224 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { 1237 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) {
1225 servers.insert(relays[i].ports.front().address); 1238 servers.insert(relays[i].ports.front().address);
1226 } 1239 }
1227 } 1240 }
1228 return servers; 1241 return servers;
1229 } 1242 }
1230 1243
1231 } // namespace cricket 1244 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/portallocator.h ('k') | webrtc/p2p/client/basicportallocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698