Chromium Code Reviews| Index: talk/app/webrtc/webrtcsession.cc |
| diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc |
| index 5c8b2df754fe8d69dd5928e2a0477e3f2e8e50ab..d3463aecce27fa9d9314222d415ba1391d37e7cc 100644 |
| --- a/talk/app/webrtc/webrtcsession.cc |
| +++ b/talk/app/webrtc/webrtcsession.cc |
| @@ -1392,7 +1392,11 @@ void WebRtcSession::OnTransportCompleted(cricket::Transport* transport) { |
| SetIceConnectionState(PeerConnectionInterface::kIceConnectionCompleted); |
| // Only report once when Ice connection is completed. |
| if (old_state != PeerConnectionInterface::kIceConnectionCompleted) { |
| - ReportBestConnectionState(transport); |
| + cricket::TransportStats stats; |
| + if (metrics_observer_ && transport->GetStats(&stats)) { |
| + ReportBestConnectionState(stats); |
| + ReportNegotiatedCiphers(stats); |
| + } |
| } |
| } |
| @@ -1872,16 +1876,9 @@ bool WebRtcSession::ReadyToUseRemoteCandidate( |
| // Walk through the ConnectionInfos to gather best connection usage |
| // for IPv4 and IPv6. |
| -void WebRtcSession::ReportBestConnectionState(cricket::Transport* transport) { |
| - if (!metrics_observer_) { |
| - return; |
| - } |
| - |
| - cricket::TransportStats stats; |
| - if (!transport->GetStats(&stats)) { |
| - return; |
| - } |
| - |
| +void WebRtcSession::ReportBestConnectionState( |
| + const cricket::TransportStats& stats) { |
| + ASSERT(metrics_observer_ != NULL); |
|
tommi (sloooow) - chröme
2015/07/02 11:32:29
DCHECK? (same below if we can switch)
joachim
2015/07/02 22:06:06
Done and also changed the "ASSERT(false)" to RTC_N
|
| for (cricket::TransportChannelStatsList::const_iterator it = |
| stats.channel_stats.begin(); |
| it != stats.channel_stats.end(); ++it) { |
| @@ -1904,4 +1901,41 @@ void WebRtcSession::ReportBestConnectionState(cricket::Transport* transport) { |
| } |
| } |
| +void WebRtcSession::ReportNegotiatedCiphers( |
| + const cricket::TransportStats& stats) { |
| + ASSERT(metrics_observer_ != NULL); |
| + if (!dtls_enabled_ || stats.channel_stats.empty()) { |
| + return; |
| + } |
| + |
| + const std::string& srtp_cipher = stats.channel_stats[0].srtp_cipher; |
| + const std::string& ssl_cipher = stats.channel_stats[0].ssl_cipher; |
| + if (srtp_cipher.empty() && ssl_cipher.empty()) { |
| + return; |
| + } |
| + |
| + PeerConnectionMetricsName srtp_name; |
| + PeerConnectionMetricsName ssl_name; |
| + if (stats.content_name == cricket::CN_AUDIO) { |
| + srtp_name = kAudioSrtpCipher; |
| + ssl_name = kAudioSslCipher; |
| + } else if (stats.content_name == cricket::CN_VIDEO) { |
| + srtp_name = kVideoSrtpCipher; |
| + ssl_name = kVideoSslCipher; |
| + } else if (stats.content_name == cricket::CN_DATA) { |
| + srtp_name = kDataSrtpCipher; |
| + ssl_name = kDataSslCipher; |
| + } else { |
| + ASSERT(false); |
| + return; |
| + } |
| + |
| + if (!srtp_cipher.empty()) { |
| + metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher); |
| + } |
| + if (!ssl_cipher.empty()) { |
| + metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher); |
| + } |
| +} |
| + |
| } // namespace webrtc |