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

Unified Diff: talk/app/webrtc/webrtcsession.cc

Issue 1156143005: Report metrics about negotiated ciphers. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Overload "AddHistogramSample" to store metrics. Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
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);
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

Powered by Google App Engine
This is Rietveld 408576698