Chromium Code Reviews| Index: webrtc/p2p/base/p2ptransportchannel.cc |
| diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc |
| index 92bec6f8970a95878fcb5fe3ed20cb7ed43c1603..fd962d549769a262d717f7f14d276629a24cf927 100644 |
| --- a/webrtc/p2p/base/p2ptransportchannel.cc |
| +++ b/webrtc/p2p/base/p2ptransportchannel.cc |
| @@ -1302,9 +1302,15 @@ void P2PTransportChannel::OnCheckAndPing() { |
| // Make sure the states of the connections are up-to-date (since this affects |
| // which ones are pingable). |
| UpdateConnectionStates(); |
| - // When the best connection is either not receiving or not writable, |
| - // switch to weak ping interval. |
| - int ping_interval = weak() ? weak_ping_interval_ : STRONG_PING_INTERVAL; |
| + // When the best connection is receiving and writable, and all connections |
| + // have been pinged sufficiently, switch to strong (longer) ping interval. |
| + bool all_connections_pinged_sufficiently = std::all_of( |
| + connections_.begin(), connections_.end(), [](Connection* conn) { |
| + return !conn->active() || conn->num_pings_sent() >= kMinNumPingsSent; |
| + }); |
| + int ping_interval = (all_connections_pinged_sufficiently && !weak()) |
| + ? 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.
|
| + : weak_ping_interval_; |
| if (rtc::TimeMillis() >= last_ping_sent_ms_ + ping_interval) { |
| Connection* conn = FindNextPingableConnection(); |
| if (conn) { |