Chromium Code Reviews| 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 1284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1295 void P2PTransportChannel::OnSort() { | 1295 void P2PTransportChannel::OnSort() { |
| 1296 // Resort the connections based on the new statistics. | 1296 // Resort the connections based on the new statistics. |
| 1297 SortConnections(); | 1297 SortConnections(); |
| 1298 } | 1298 } |
| 1299 | 1299 |
| 1300 // Handle queued up check-and-ping request | 1300 // Handle queued up check-and-ping request |
| 1301 void P2PTransportChannel::OnCheckAndPing() { | 1301 void P2PTransportChannel::OnCheckAndPing() { |
| 1302 // Make sure the states of the connections are up-to-date (since this affects | 1302 // Make sure the states of the connections are up-to-date (since this affects |
| 1303 // which ones are pingable). | 1303 // which ones are pingable). |
| 1304 UpdateConnectionStates(); | 1304 UpdateConnectionStates(); |
| 1305 // When the best connection is either not receiving or not writable, | 1305 // When the best connection is receiving and writable, and all connections |
| 1306 // switch to weak ping interval. | 1306 // have been pinged sufficiently, switch to strong (longer) ping interval. |
| 1307 int ping_interval = weak() ? weak_ping_interval_ : STRONG_PING_INTERVAL; | 1307 bool all_connections_pinged_sufficiently = std::all_of( |
| 1308 connections_.begin(), connections_.end(), [](Connection* conn) { | |
| 1309 return !conn->active() || conn->num_pings_sent() >= kMinNumPingsSent; | |
| 1310 }); | |
| 1311 int ping_interval = (all_connections_pinged_sufficiently && !weak()) | |
| 1312 ? STRONG_PING_INTERVAL | |
|
pthatcher1
2016/05/25 17:29:13
This might be more clear as :
bool need_more_ping
honghaiz3
2016/05/25 18:40:02
Done.
| |
| 1313 : weak_ping_interval_; | |
| 1308 if (rtc::TimeMillis() >= last_ping_sent_ms_ + ping_interval) { | 1314 if (rtc::TimeMillis() >= last_ping_sent_ms_ + ping_interval) { |
| 1309 Connection* conn = FindNextPingableConnection(); | 1315 Connection* conn = FindNextPingableConnection(); |
| 1310 if (conn) { | 1316 if (conn) { |
| 1311 PingConnection(conn); | 1317 PingConnection(conn); |
| 1312 MarkConnectionPinged(conn); | 1318 MarkConnectionPinged(conn); |
| 1313 } | 1319 } |
| 1314 } | 1320 } |
| 1315 int delay = std::min(ping_interval, check_receiving_interval_); | 1321 int delay = std::min(ping_interval, check_receiving_interval_); |
| 1316 thread()->PostDelayed(delay, this, MSG_CHECK_AND_PING); | 1322 thread()->PostDelayed(delay, this, MSG_CHECK_AND_PING); |
| 1317 } | 1323 } |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1660 | 1666 |
| 1661 // During the initial state when nothing has been pinged yet, return the first | 1667 // During the initial state when nothing has been pinged yet, return the first |
| 1662 // one in the ordered |connections_|. | 1668 // one in the ordered |connections_|. |
| 1663 return *(std::find_if(connections_.begin(), connections_.end(), | 1669 return *(std::find_if(connections_.begin(), connections_.end(), |
| 1664 [conn1, conn2](Connection* conn) { | 1670 [conn1, conn2](Connection* conn) { |
| 1665 return conn == conn1 || conn == conn2; | 1671 return conn == conn1 || conn == conn2; |
| 1666 })); | 1672 })); |
| 1667 } | 1673 } |
| 1668 | 1674 |
| 1669 } // namespace cricket | 1675 } // namespace cricket |
| OLD | NEW |