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

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

Issue 1364683002: Do not prune if the current best connection is weak. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Change the test name and merge Created 5 years, 3 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 | « no previous file | webrtc/p2p/base/p2ptransportchannel_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 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 : nullptr; 993 : nullptr;
994 } 994 }
995 995
996 void P2PTransportChannel::PruneConnections() { 996 void P2PTransportChannel::PruneConnections() {
997 // We can prune any connection for which there is a connected, writable 997 // We can prune any connection for which there is a connected, writable
998 // connection on the same network with better or equal priority. We leave 998 // connection on the same network with better or equal priority. We leave
999 // those with better priority just in case they become writable later (at 999 // those with better priority just in case they become writable later (at
1000 // which point, we would prune out the current best connection). We leave 1000 // which point, we would prune out the current best connection). We leave
1001 // connections on other networks because they may not be using the same 1001 // connections on other networks because they may not be using the same
1002 // resources and they may represent very distinct paths over which we can 1002 // resources and they may represent very distinct paths over which we can
1003 // switch. If the |primier| connection is not connected, we may be 1003 // switch. If the |premier| connection is not connected, we may be
1004 // reconnecting a TCP connection and temporarily do not prune connections in 1004 // reconnecting a TCP connection and temporarily do not prune connections in
1005 // this network. See the big comment in CompareConnections. 1005 // this network. See the big comment in CompareConnections.
1006 1006
1007 // Get a list of the networks that we are using. 1007 // Get a list of the networks that we are using.
1008 std::set<rtc::Network*> networks; 1008 std::set<rtc::Network*> networks;
1009 for (const Connection* conn : connections_) { 1009 for (const Connection* conn : connections_) {
1010 networks.insert(conn->port()->Network()); 1010 networks.insert(conn->port()->Network());
1011 } 1011 }
1012 for (rtc::Network* network : networks) { 1012 for (rtc::Network* network : networks) {
1013 Connection* primier = GetBestConnectionOnNetwork(network); 1013 Connection* premier = GetBestConnectionOnNetwork(network);
1014 if (!(primier && primier->writable() && primier->connected())) { 1014 // Do not prune connections if the current best connection is weak on this
1015 // network. Otherwise, it may delete connections prematurely.
1016 if (!premier || premier->Weak()) {
1015 continue; 1017 continue;
1016 } 1018 }
1017 1019
1018 for (Connection* conn : connections_) { 1020 for (Connection* conn : connections_) {
1019 if ((conn != primier) && (conn->port()->Network() == network) && 1021 if ((conn != premier) && (conn->port()->Network() == network) &&
1020 (CompareConnectionCandidates(primier, conn) >= 0)) { 1022 (CompareConnectionCandidates(premier, conn) >= 0)) {
1021 conn->Prune(); 1023 conn->Prune();
1022 } 1024 }
1023 } 1025 }
1024 } 1026 }
1025 } 1027 }
1026 1028
1027 // Track the best connection, and let listeners know 1029 // Track the best connection, and let listeners know
1028 void P2PTransportChannel::SwitchBestConnectionTo(Connection* conn) { 1030 void P2PTransportChannel::SwitchBestConnectionTo(Connection* conn) {
1029 // Note: if conn is NULL, the previous best_connection_ has been destroyed, 1031 // Note: if conn is NULL, the previous best_connection_ has been destroyed,
1030 // so don't use it. 1032 // so don't use it.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 set_writable(false); 1087 set_writable(false);
1086 } 1088 }
1087 } 1089 }
1088 1090
1089 void P2PTransportChannel::HandleAllTimedOut() { 1091 void P2PTransportChannel::HandleAllTimedOut() {
1090 // Currently we are treating this as channel not writable. 1092 // Currently we are treating this as channel not writable.
1091 HandleNotWritable(); 1093 HandleNotWritable();
1092 } 1094 }
1093 1095
1094 bool P2PTransportChannel::Weak() const { 1096 bool P2PTransportChannel::Weak() const {
1095 return !(best_connection_ && best_connection_->receiving() && 1097 return !best_connection_ || best_connection_->Weak();
1096 best_connection_->writable());
1097 } 1098 }
1098 1099
1099 // If we have a best connection, return it, otherwise return top one in the 1100 // If we have a best connection, return it, otherwise return top one in the
1100 // list (later we will mark it best). 1101 // list (later we will mark it best).
1101 Connection* P2PTransportChannel::GetBestConnectionOnNetwork( 1102 Connection* P2PTransportChannel::GetBestConnectionOnNetwork(
1102 rtc::Network* network) const { 1103 rtc::Network* network) const {
1103 // If the best connection is on this network, then it wins. 1104 // If the best connection is on this network, then it wins.
1104 if (best_connection_ && (best_connection_->port()->Network() == network)) 1105 if (best_connection_ && (best_connection_->port()->Network() == network))
1105 return best_connection_; 1106 return best_connection_;
1106 1107
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 } 1342 }
1342 } 1343 }
1343 1344
1344 void P2PTransportChannel::OnReadyToSend(Connection* connection) { 1345 void P2PTransportChannel::OnReadyToSend(Connection* connection) {
1345 if (connection == best_connection_ && writable()) { 1346 if (connection == best_connection_ && writable()) {
1346 SignalReadyToSend(this); 1347 SignalReadyToSend(this);
1347 } 1348 }
1348 } 1349 }
1349 1350
1350 } // namespace cricket 1351 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698