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

Side by Side Diff: webrtc/api/webrtcsession.cc

Issue 2567243003: RTCStatsCollector: Utilize network thread to minimize thread hops. (Closed)
Patch Set: Addressed comments Created 4 years 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 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 } 999 }
1000 const TransportInfo* transport_info = 1000 const TransportInfo* transport_info =
1001 description->GetTransportInfoByName(content_name); 1001 description->GetTransportInfoByName(content_name);
1002 if (!transport_info) { 1002 if (!transport_info) {
1003 return false; 1003 return false;
1004 } 1004 }
1005 *tdesc = transport_info->description; 1005 *tdesc = transport_info->description;
1006 return true; 1006 return true;
1007 } 1007 }
1008 1008
1009 bool WebRtcSession::GetTransportStats(SessionStats* stats) { 1009 std::unique_ptr<SessionStats> WebRtcSession::GetSessionStats() {
pthatcher1 2016/12/15 23:18:59 Why not just "GetStats()"?
hbos 2016/12/16 10:38:02 Done.
1010 ASSERT(signaling_thread()->IsCurrent()); 1010 ASSERT(signaling_thread()->IsCurrent());
1011 return (GetChannelTransportStats(voice_channel(), stats) && 1011 ChannelNamePairs channel_name_pairs;
1012 GetChannelTransportStats(video_channel(), stats) && 1012 if (voice_channel()) {
1013 GetChannelTransportStats(data_channel(), stats)); 1013 channel_name_pairs.voice = rtc::Optional<ChannelNamePair>(ChannelNamePair(
1014 voice_channel()->content_name(), voice_channel()->transport_name()));
1015 }
1016 if (video_channel()) {
1017 channel_name_pairs.video = rtc::Optional<ChannelNamePair>(ChannelNamePair(
1018 video_channel()->content_name(), video_channel()->transport_name()));
1019 }
1020 if (data_channel()) {
1021 channel_name_pairs.data = rtc::Optional<ChannelNamePair>(ChannelNamePair(
1022 data_channel()->content_name(), data_channel()->transport_name()));
1023 }
1024 return GetSessionStats(channel_name_pairs);
pthatcher1 2016/12/15 23:18:59 I don't understand. Why not just put everything i
hbos 2016/12/16 10:38:02 Because what if there is a race between e.g. blah_
1014 } 1025 }
1015 1026
1016 bool WebRtcSession::GetChannelTransportStats(cricket::BaseChannel* ch, 1027 std::unique_ptr<SessionStats> WebRtcSession::GetSessionStats(
1017 SessionStats* stats) { 1028 const ChannelNamePairs& channel_name_pairs) {
1018 ASSERT(signaling_thread()->IsCurrent()); 1029 if (network_thread()->IsCurrent())
1019 if (!ch) { 1030 return GetSessionStats_n(channel_name_pairs);
pthatcher1 2016/12/15 23:18:59 {}s please
hbos 2016/12/16 10:38:02 Done.
1020 // Not using this channel. 1031 return network_thread()->Invoke<std::unique_ptr<SessionStats>>(
1021 return true; 1032 RTC_FROM_HERE,
1022 } 1033 rtc::Bind(&WebRtcSession::GetSessionStats_n, this, channel_name_pairs));
1023
1024 const std::string& content_name = ch->content_name();
1025 const std::string& transport_name = ch->transport_name();
1026 stats->proxy_to_transport[content_name] = transport_name;
1027 if (stats->transport_stats.find(transport_name) !=
1028 stats->transport_stats.end()) {
1029 // Transport stats already done for this transport.
1030 return true;
1031 }
1032
1033 cricket::TransportStats tstats;
1034 if (!transport_controller_->GetStats(transport_name, &tstats)) {
1035 return false;
1036 }
1037
1038 stats->transport_stats[transport_name] = tstats;
1039 return true;
1040 } 1034 }
1041 1035
1042 bool WebRtcSession::GetLocalCertificate( 1036 bool WebRtcSession::GetLocalCertificate(
1043 const std::string& transport_name, 1037 const std::string& transport_name,
1044 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) { 1038 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
1045 ASSERT(signaling_thread()->IsCurrent());
1046 return transport_controller_->GetLocalCertificate(transport_name, 1039 return transport_controller_->GetLocalCertificate(transport_name,
1047 certificate); 1040 certificate);
1048 } 1041 }
1049 1042
1050 std::unique_ptr<rtc::SSLCertificate> WebRtcSession::GetRemoteSSLCertificate( 1043 std::unique_ptr<rtc::SSLCertificate> WebRtcSession::GetRemoteSSLCertificate(
1051 const std::string& transport_name) { 1044 const std::string& transport_name) {
1052 ASSERT(signaling_thread()->IsCurrent());
1053 return transport_controller_->GetRemoteSSLCertificate(transport_name); 1045 return transport_controller_->GetRemoteSSLCertificate(transport_name);
1054 } 1046 }
1055 1047
1056 bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) { 1048 bool WebRtcSession::EnableBundle(const cricket::ContentGroup& bundle) {
1057 const std::string* first_content_name = bundle.FirstContentName(); 1049 const std::string* first_content_name = bundle.FirstContentName();
1058 if (!first_content_name) { 1050 if (!first_content_name) {
1059 LOG(LS_WARNING) << "Tried to BUNDLE with no contents."; 1051 LOG(LS_WARNING) << "Tried to BUNDLE with no contents.";
1060 return false; 1052 return false;
1061 } 1053 }
1062 const std::string& transport_name = *first_content_name; 1054 const std::string& transport_name = *first_content_name;
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 } 1734 }
1743 1735
1744 data_channel_->SignalDtlsSetupFailure.connect( 1736 data_channel_->SignalDtlsSetupFailure.connect(
1745 this, &WebRtcSession::OnDtlsSetupFailure); 1737 this, &WebRtcSession::OnDtlsSetupFailure);
1746 1738
1747 SignalDataChannelCreated(); 1739 SignalDataChannelCreated();
1748 data_channel_->SignalSentPacket.connect(this, &WebRtcSession::OnSentPacket_w); 1740 data_channel_->SignalSentPacket.connect(this, &WebRtcSession::OnSentPacket_w);
1749 return true; 1741 return true;
1750 } 1742 }
1751 1743
1744 std::unique_ptr<SessionStats> WebRtcSession::GetSessionStats_n(
1745 const ChannelNamePairs& channel_name_pairs) {
1746 ASSERT(network_thread()->IsCurrent());
1747 std::unique_ptr<SessionStats> session_stats(new SessionStats());
1748 if (channel_name_pairs.voice) {
1749 cricket::TransportStats voice_transport_stats;
1750 if (!transport_controller_->GetStats(
1751 channel_name_pairs.voice->transport_name, &voice_transport_stats)) {
1752 return nullptr;
1753 }
1754 session_stats->proxy_to_transport[channel_name_pairs.voice->content_name] =
1755 channel_name_pairs.voice->transport_name;
1756 session_stats->transport_stats[channel_name_pairs.voice->transport_name] =
1757 std::move(voice_transport_stats);
1758 }
1759 if (channel_name_pairs.video) {
1760 cricket::TransportStats video_transport_stats;
1761 if (!transport_controller_->GetStats(
1762 channel_name_pairs.video->transport_name, &video_transport_stats)) {
1763 return nullptr;
1764 }
1765 session_stats->proxy_to_transport[channel_name_pairs.video->content_name] =
1766 channel_name_pairs.video->transport_name;
1767 session_stats->transport_stats[channel_name_pairs.video->transport_name] =
1768 std::move(video_transport_stats);
1769 }
1770 if (channel_name_pairs.data) {
1771 cricket::TransportStats data_transport_stats;
1772 if (!transport_controller_->GetStats(
1773 channel_name_pairs.data->transport_name, &data_transport_stats)) {
1774 return nullptr;
1775 }
1776 session_stats->proxy_to_transport[channel_name_pairs.data->content_name] =
1777 channel_name_pairs.data->transport_name;
1778 session_stats->transport_stats[channel_name_pairs.data->transport_name] =
1779 std::move(data_transport_stats);
1780 }
pthatcher1 2016/12/15 23:18:59 There's some duplication that could be removed and
hbos 2016/12/16 10:38:02 Oh nice, good idea. Done.
1781 return session_stats;
1782 }
1783
1752 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) { 1784 void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) {
1753 SetError(ERROR_TRANSPORT, 1785 SetError(ERROR_TRANSPORT,
1754 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp); 1786 rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp);
1755 } 1787 }
1756 1788
1757 void WebRtcSession::OnDataChannelMessageReceived( 1789 void WebRtcSession::OnDataChannelMessageReceived(
1758 cricket::DataChannel* channel, 1790 cricket::DataChannel* channel,
1759 const cricket::ReceiveDataParams& params, 1791 const cricket::ReceiveDataParams& params,
1760 const rtc::CopyOnWriteBuffer& payload) { 1792 const rtc::CopyOnWriteBuffer& payload) {
1761 RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP); 1793 RTC_DCHECK(data_channel_type_ == cricket::DCT_SCTP);
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
2087 } 2119 }
2088 2120
2089 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) { 2121 void WebRtcSession::OnDtlsHandshakeError(rtc::SSLHandshakeError error) {
2090 if (metrics_observer_) { 2122 if (metrics_observer_) {
2091 metrics_observer_->IncrementEnumCounter( 2123 metrics_observer_->IncrementEnumCounter(
2092 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error), 2124 webrtc::kEnumCounterDtlsHandshakeError, static_cast<int>(error),
2093 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE)); 2125 static_cast<int>(rtc::SSLHandshakeError::MAX_VALUE));
2094 } 2126 }
2095 } 2127 }
2096 } // namespace webrtc 2128 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698