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

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

Issue 1520963002: Removing webrtc::PortAllocatorFactoryInterface. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Moving the network ignore mask logic (and unit tests) to BasicPortAllocator. Created 5 years 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/client/basicportallocator.h ('k') | webrtc/p2p/client/fakeportallocator.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 /* 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP | 63 PORTALLOCATOR_DISABLE_UDP | PORTALLOCATOR_DISABLE_TCP |
64 PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY; 64 PORTALLOCATOR_DISABLE_STUN | PORTALLOCATOR_DISABLE_RELAY;
65 65
66 // BasicPortAllocator 66 // BasicPortAllocator
67 BasicPortAllocator::BasicPortAllocator( 67 BasicPortAllocator::BasicPortAllocator(
68 rtc::NetworkManager* network_manager, 68 rtc::NetworkManager* network_manager,
69 rtc::PacketSocketFactory* socket_factory) 69 rtc::PacketSocketFactory* socket_factory)
70 : network_manager_(network_manager), 70 : network_manager_(network_manager),
71 socket_factory_(socket_factory), 71 socket_factory_(socket_factory),
72 stun_servers_() { 72 stun_servers_() {
73 ASSERT(socket_factory_ != NULL); 73 ASSERT(network_manager_ != nullptr);
74 ASSERT(socket_factory_ != nullptr);
74 Construct(); 75 Construct();
75 } 76 }
76 77
77 BasicPortAllocator::BasicPortAllocator( 78 BasicPortAllocator::BasicPortAllocator(rtc::NetworkManager* network_manager)
78 rtc::NetworkManager* network_manager)
79 : network_manager_(network_manager), 79 : network_manager_(network_manager),
80 socket_factory_(NULL), 80 socket_factory_(nullptr),
81 stun_servers_() { 81 stun_servers_() {
82 ASSERT(network_manager_ != nullptr);
82 Construct(); 83 Construct();
83 } 84 }
84 85
85 BasicPortAllocator::BasicPortAllocator( 86 BasicPortAllocator::BasicPortAllocator(
86 rtc::NetworkManager* network_manager, 87 rtc::NetworkManager* network_manager,
87 rtc::PacketSocketFactory* socket_factory, 88 rtc::PacketSocketFactory* socket_factory,
88 const ServerAddresses& stun_servers) 89 const ServerAddresses& stun_servers)
89 : network_manager_(network_manager), 90 : network_manager_(network_manager),
90 socket_factory_(socket_factory), 91 socket_factory_(socket_factory),
91 stun_servers_(stun_servers) { 92 stun_servers_(stun_servers) {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 std::vector<rtc::Network*>* networks) { 312 std::vector<rtc::Network*>* networks) {
312 networks->clear(); 313 networks->clear();
313 rtc::NetworkManager* network_manager = allocator_->network_manager(); 314 rtc::NetworkManager* network_manager = allocator_->network_manager();
314 ASSERT(network_manager != nullptr); 315 ASSERT(network_manager != nullptr);
315 // If the network permission state is BLOCKED, we just act as if the flag has 316 // If the network permission state is BLOCKED, we just act as if the flag has
316 // been passed in. 317 // been passed in.
317 if (network_manager->enumeration_permission() == 318 if (network_manager->enumeration_permission() ==
318 rtc::NetworkManager::ENUMERATION_BLOCKED) { 319 rtc::NetworkManager::ENUMERATION_BLOCKED) {
319 set_flags(flags() | PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION); 320 set_flags(flags() | PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
320 } 321 }
322 std::vector<rtc::Network*> unfiltered_networks;
321 // If the adapter enumeration is disabled, we'll just bind to any address 323 // If the adapter enumeration is disabled, we'll just bind to any address
322 // instead of specific NIC. This is to ensure the same routing for http 324 // instead of specific NIC. This is to ensure the same routing for http
323 // traffic by OS is also used here to avoid any local or public IP leakage 325 // traffic by OS is also used here to avoid any local or public IP leakage
324 // during stun process. 326 // during stun process.
325 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) { 327 if (flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION) {
326 network_manager->GetAnyAddressNetworks(networks); 328 network_manager->GetAnyAddressNetworks(&unfiltered_networks);
327 } else { 329 } else {
328 network_manager->GetNetworks(networks); 330 network_manager->GetNetworks(&unfiltered_networks);
331 }
332 for (rtc::Network* network : unfiltered_networks) {
333 if (!(allocator_->network_ignore_mask() & network->type())) {
pthatcher1 2015/12/15 23:53:18 Might be slightly more readable as: bool ignored
334 networks->push_back(network);
335 }
329 } 336 }
330 } 337 }
331 338
332 // For each network, see if we have a sequence that covers it already. If not, 339 // For each network, see if we have a sequence that covers it already. If not,
333 // create a new sequence to create the appropriate ports. 340 // create a new sequence to create the appropriate ports.
334 void BasicPortAllocatorSession::DoAllocate() { 341 void BasicPortAllocatorSession::DoAllocate() {
335 bool done_signal_needed = false; 342 bool done_signal_needed = false;
336 std::vector<rtc::Network*> networks; 343 std::vector<rtc::Network*> networks;
337 GetNetworks(&networks); 344 GetNetworks(&networks);
338 345
(...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 ServerAddresses servers; 1184 ServerAddresses servers;
1178 for (size_t i = 0; i < relays.size(); ++i) { 1185 for (size_t i = 0; i < relays.size(); ++i) {
1179 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) { 1186 if (relays[i].type == turn_type && SupportsProtocol(relays[i], type)) {
1180 servers.insert(relays[i].ports.front().address); 1187 servers.insert(relays[i].ports.front().address);
1181 } 1188 }
1182 } 1189 }
1183 return servers; 1190 return servers;
1184 } 1191 }
1185 1192
1186 } // namespace cricket 1193 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/client/basicportallocator.h ('k') | webrtc/p2p/client/fakeportallocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698