Index: webrtc/p2p/base/port.cc |
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc |
index bf57cf956815dc1fafe6f1c7cd8d490e82a431d5..c4d797d2bd850027a205e2b03c86bf06e1b04829 100644 |
--- a/webrtc/p2p/base/port.cc |
+++ b/webrtc/p2p/base/port.cc |
@@ -1251,6 +1251,7 @@ void Connection::ReceivedPing() { |
} |
void Connection::ReceivedPingResponse(int rtt, const std::string& request_id) { |
+ RTC_DCHECK_GE(rtt, 0); |
// We've already validated that this is a STUN binding response with |
// the correct local and remote username for this connection. |
// So if we're not already, become writable. We may be bringing a pruned |
@@ -1264,6 +1265,16 @@ void Connection::ReceivedPingResponse(int rtt, const std::string& request_id) { |
acked_nomination_ = iter->nomination; |
} |
+ current_round_trip_time_ms_ = rtc::Optional<uint32_t>( |
+ static_cast<uint32_t>(rtt)); |
+ if (!total_round_trip_time_ms_) { |
+ total_round_trip_time_ms_ = rtc::Optional<uint64_t>( |
+ static_cast<uint64_t>(rtt)); |
+ } else { |
+ total_round_trip_time_ms_ = rtc::Optional<uint64_t>( |
+ *total_round_trip_time_ms_ + rtt); |
+ } |
+ |
pings_since_last_response_.clear(); |
last_ping_response_received_ = rtc::TimeMillis(); |
UpdateReceiving(last_ping_response_received_); |
@@ -1503,6 +1514,8 @@ ConnectionInfo Connection::stats() { |
stats_.key = this; |
stats_.state = state_; |
stats_.priority = priority(); |
+ stats_.total_round_trip_time_ms = total_round_trip_time_ms_; |
+ stats_.current_round_trip_time_ms = current_round_trip_time_ms_; |
return stats_; |
} |