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

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel.cc

Issue 2936553003: Adding PortAllocator option to support cases where sockets can't be bound. (Closed)
Patch Set: Minor changes (comments, renaming, etc.) Created 3 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
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 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 void P2PTransportChannel::PruneConnections() { 1346 void P2PTransportChannel::PruneConnections() {
1347 // We can prune any connection for which there is a connected, writable 1347 // We can prune any connection for which there is a connected, writable
1348 // connection on the same network with better or equal priority. We leave 1348 // connection on the same network with better or equal priority. We leave
1349 // those with better priority just in case they become writable later (at 1349 // those with better priority just in case they become writable later (at
1350 // which point, we would prune out the current selected connection). We leave 1350 // which point, we would prune out the current selected connection). We leave
1351 // connections on other networks because they may not be using the same 1351 // connections on other networks because they may not be using the same
1352 // resources and they may represent very distinct paths over which we can 1352 // resources and they may represent very distinct paths over which we can
1353 // switch. If |best_conn_on_network| is not connected, we may be reconnecting 1353 // switch. If |best_conn_on_network| is not connected, we may be reconnecting
1354 // a TCP connection and should not prune connections in this network. 1354 // a TCP connection and should not prune connections in this network.
1355 // See the big comment in CompareConnectionStates. 1355 // See the big comment in CompareConnectionStates.
1356 //
1357 // An exception is made for connections on an "any address" network, meaning
1358 // not bound to any specific network interface. We don't want to keep one of
1359 // these alive as a backup, since it could be using the same network
1360 // interface as the higher-priority, selected candidate pair.
1356 auto best_connection_by_network = GetBestConnectionByNetwork(); 1361 auto best_connection_by_network = GetBestConnectionByNetwork();
1357 for (Connection* conn : connections_) { 1362 for (Connection* conn : connections_) {
1358 // Do not prune connections if the current best connection on this network 1363 Connection* best_conn = selected_connection_;
1359 // is weak. Otherwise, it may delete connections prematurely. 1364 if (!rtc::IPIsAny(conn->port()->Network()->ip())) {
1360 Connection* best_conn_on_network = 1365 // If the connection is bound to a specific network interface (not an
1361 best_connection_by_network[conn->port()->Network()]; 1366 // "any address" network), compare it against the best connection for
1362 if (best_conn_on_network && conn != best_conn_on_network && 1367 // that network interface rather than the best connection overall. This
1363 !best_conn_on_network->weak() && 1368 // ensures that at least one connection per network will be left
1364 CompareConnectionCandidates(best_conn_on_network, conn) >= 0) { 1369 // unpruned.
1370 best_conn = best_connection_by_network[conn->port()->Network()];
1371 }
1372 // Do not prune connections if the connection being compared against is
1373 // weak. Otherwise, it may delete connections prematurely.
1374 if (best_conn && conn != best_conn && !best_conn->weak() &&
1375 CompareConnectionCandidates(best_conn, conn) >= 0) {
1365 conn->Prune(); 1376 conn->Prune();
1366 } 1377 }
1367 } 1378 }
1368 } 1379 }
1369 1380
1370 // Change the selected connection, and let listeners know. 1381 // Change the selected connection, and let listeners know.
1371 void P2PTransportChannel::SwitchSelectedConnection(Connection* conn) { 1382 void P2PTransportChannel::SwitchSelectedConnection(Connection* conn) {
1372 // Note: if conn is NULL, the previous |selected_connection_| has been 1383 // Note: if conn is NULL, the previous |selected_connection_| has been
1373 // destroyed, so don't use it. 1384 // destroyed, so don't use it.
1374 Connection* old_selected_connection = selected_connection_; 1385 Connection* old_selected_connection = selected_connection_;
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 2060
2050 void P2PTransportChannel::set_receiving(bool receiving) { 2061 void P2PTransportChannel::set_receiving(bool receiving) {
2051 if (receiving_ == receiving) { 2062 if (receiving_ == receiving) {
2052 return; 2063 return;
2053 } 2064 }
2054 receiving_ = receiving; 2065 receiving_ = receiving;
2055 SignalReceivingState(this); 2066 SignalReceivingState(this);
2056 } 2067 }
2057 2068
2058 } // namespace cricket 2069 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/basicpacketsocketfactory.cc ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698