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

Side by Side 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: Renamed properties and provide accessors. Created 5 years, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 } 1385 }
1386 } 1386 }
1387 } 1387 }
1388 1388
1389 void WebRtcSession::OnTransportCompleted(cricket::Transport* transport) { 1389 void WebRtcSession::OnTransportCompleted(cricket::Transport* transport) {
1390 ASSERT(signaling_thread()->IsCurrent()); 1390 ASSERT(signaling_thread()->IsCurrent());
1391 PeerConnectionInterface::IceConnectionState old_state = ice_connection_state_; 1391 PeerConnectionInterface::IceConnectionState old_state = ice_connection_state_;
1392 SetIceConnectionState(PeerConnectionInterface::kIceConnectionCompleted); 1392 SetIceConnectionState(PeerConnectionInterface::kIceConnectionCompleted);
1393 // Only report once when Ice connection is completed. 1393 // Only report once when Ice connection is completed.
1394 if (old_state != PeerConnectionInterface::kIceConnectionCompleted) { 1394 if (old_state != PeerConnectionInterface::kIceConnectionCompleted) {
1395 ReportBestConnectionState(transport); 1395 cricket::TransportStats stats;
1396 if (metrics_observer_ && transport->GetStats(&stats)) {
1397 ReportBestConnectionState(stats);
1398 ReportNegotiatedCiphers(stats);
1399 }
1396 } 1400 }
1397 } 1401 }
1398 1402
1399 void WebRtcSession::OnTransportFailed(cricket::Transport* transport) { 1403 void WebRtcSession::OnTransportFailed(cricket::Transport* transport) {
1400 ASSERT(signaling_thread()->IsCurrent()); 1404 ASSERT(signaling_thread()->IsCurrent());
1401 SetIceConnectionState(PeerConnectionInterface::kIceConnectionFailed); 1405 SetIceConnectionState(PeerConnectionInterface::kIceConnectionFailed);
1402 } 1406 }
1403 1407
1404 void WebRtcSession::OnTransportProxyCandidatesReady( 1408 void WebRtcSession::OnTransportProxyCandidatesReady(
1405 cricket::TransportProxy* proxy, const cricket::Candidates& candidates) { 1409 cricket::TransportProxy* proxy, const cricket::Candidates& candidates) {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 cricket::ContentInfo content = 1869 cricket::ContentInfo content =
1866 current_remote_desc->description()->contents()[mediacontent_index]; 1870 current_remote_desc->description()->contents()[mediacontent_index];
1867 transport_proxy = GetTransportProxy(content.name); 1871 transport_proxy = GetTransportProxy(content.name);
1868 1872
1869 return transport_proxy && transport_proxy->local_description_set() && 1873 return transport_proxy && transport_proxy->local_description_set() &&
1870 transport_proxy->remote_description_set(); 1874 transport_proxy->remote_description_set();
1871 } 1875 }
1872 1876
1873 // Walk through the ConnectionInfos to gather best connection usage 1877 // Walk through the ConnectionInfos to gather best connection usage
1874 // for IPv4 and IPv6. 1878 // for IPv4 and IPv6.
1875 void WebRtcSession::ReportBestConnectionState(cricket::Transport* transport) { 1879 void WebRtcSession::ReportBestConnectionState(
1876 if (!metrics_observer_) { 1880 const cricket::TransportStats& stats) {
1877 return; 1881 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
1878 }
1879
1880 cricket::TransportStats stats;
1881 if (!transport->GetStats(&stats)) {
1882 return;
1883 }
1884
1885 for (cricket::TransportChannelStatsList::const_iterator it = 1882 for (cricket::TransportChannelStatsList::const_iterator it =
1886 stats.channel_stats.begin(); 1883 stats.channel_stats.begin();
1887 it != stats.channel_stats.end(); ++it) { 1884 it != stats.channel_stats.end(); ++it) {
1888 for (cricket::ConnectionInfos::const_iterator it_info = 1885 for (cricket::ConnectionInfos::const_iterator it_info =
1889 it->connection_infos.begin(); 1886 it->connection_infos.begin();
1890 it_info != it->connection_infos.end(); ++it_info) { 1887 it_info != it->connection_infos.end(); ++it_info) {
1891 if (!it_info->best_connection) { 1888 if (!it_info->best_connection) {
1892 continue; 1889 continue;
1893 } 1890 }
1894 if (it_info->local_candidate.address().family() == AF_INET) { 1891 if (it_info->local_candidate.address().family() == AF_INET) {
1895 metrics_observer_->IncrementCounter(kBestConnections_IPv4); 1892 metrics_observer_->IncrementCounter(kBestConnections_IPv4);
1896 } else if (it_info->local_candidate.address().family() == 1893 } else if (it_info->local_candidate.address().family() ==
1897 AF_INET6) { 1894 AF_INET6) {
1898 metrics_observer_->IncrementCounter(kBestConnections_IPv6); 1895 metrics_observer_->IncrementCounter(kBestConnections_IPv6);
1899 } else { 1896 } else {
1900 ASSERT(false); 1897 ASSERT(false);
1901 } 1898 }
1902 return; 1899 return;
1903 } 1900 }
1904 } 1901 }
1905 } 1902 }
1906 1903
1904 void WebRtcSession::ReportNegotiatedCiphers(
1905 const cricket::TransportStats& stats) {
1906 ASSERT(metrics_observer_ != NULL);
1907 if (!dtls_enabled_ || stats.channel_stats.empty()) {
1908 return;
1909 }
1910
1911 const std::string& srtp_cipher = stats.channel_stats[0].srtp_cipher;
1912 const std::string& ssl_cipher = stats.channel_stats[0].ssl_cipher;
1913 if (srtp_cipher.empty() && ssl_cipher.empty()) {
1914 return;
1915 }
1916
1917 PeerConnectionMetricsName srtp_name;
1918 PeerConnectionMetricsName ssl_name;
1919 if (stats.content_name == cricket::CN_AUDIO) {
1920 srtp_name = kAudioSrtpCipher;
1921 ssl_name = kAudioSslCipher;
1922 } else if (stats.content_name == cricket::CN_VIDEO) {
1923 srtp_name = kVideoSrtpCipher;
1924 ssl_name = kVideoSslCipher;
1925 } else if (stats.content_name == cricket::CN_DATA) {
1926 srtp_name = kDataSrtpCipher;
1927 ssl_name = kDataSslCipher;
1928 } else {
1929 ASSERT(false);
1930 return;
1931 }
1932
1933 if (!srtp_cipher.empty()) {
1934 metrics_observer_->AddHistogramSample(srtp_name, srtp_cipher);
1935 }
1936 if (!ssl_cipher.empty()) {
1937 metrics_observer_->AddHistogramSample(ssl_name, ssl_cipher);
1938 }
1939 }
1940
1907 } // namespace webrtc 1941 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698