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

Unified Diff: webrtc/api/webrtcsession.cc

Issue 2567243003: RTCStatsCollector: Utilize network thread to minimize thread hops. (Closed)
Patch Set: Rebase and rename Get[Session]Stats_n 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/webrtcsession.h ('k') | webrtc/api/webrtcsession_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/webrtcsession.cc
diff --git a/webrtc/api/webrtcsession.cc b/webrtc/api/webrtcsession.cc
index b05862d37c6a5c03dac76333d6edae8a071186a7..a0a439a4cb499bc47d2f6870ae2b57e8f8c1e26f 100644
--- a/webrtc/api/webrtcsession.cc
+++ b/webrtc/api/webrtcsession.cc
@@ -970,50 +970,43 @@ bool WebRtcSession::GetTransportDescription(
return true;
}
-bool WebRtcSession::GetTransportStats(SessionStats* stats) {
+std::unique_ptr<SessionStats> WebRtcSession::GetStats() {
ASSERT(signaling_thread()->IsCurrent());
- return (GetChannelTransportStats(voice_channel(), stats) &&
- GetChannelTransportStats(video_channel(), stats) &&
- GetChannelTransportStats(data_channel(), stats));
-}
-
-bool WebRtcSession::GetChannelTransportStats(cricket::BaseChannel* ch,
- SessionStats* stats) {
- ASSERT(signaling_thread()->IsCurrent());
- if (!ch) {
- // Not using this channel.
- return true;
+ ChannelNamePairs channel_name_pairs;
+ if (voice_channel()) {
+ channel_name_pairs.voice = rtc::Optional<ChannelNamePair>(ChannelNamePair(
+ voice_channel()->content_name(), voice_channel()->transport_name()));
}
-
- const std::string& content_name = ch->content_name();
- const std::string& transport_name = ch->transport_name();
- stats->proxy_to_transport[content_name] = transport_name;
- if (stats->transport_stats.find(transport_name) !=
- stats->transport_stats.end()) {
- // Transport stats already done for this transport.
- return true;
+ if (video_channel()) {
+ channel_name_pairs.video = rtc::Optional<ChannelNamePair>(ChannelNamePair(
+ video_channel()->content_name(), video_channel()->transport_name()));
}
-
- cricket::TransportStats tstats;
- if (!transport_controller_->GetStats(transport_name, &tstats)) {
- return false;
+ if (data_channel()) {
+ channel_name_pairs.data = rtc::Optional<ChannelNamePair>(ChannelNamePair(
+ data_channel()->content_name(), data_channel()->transport_name()));
}
+ return GetStats(channel_name_pairs);
+}
- stats->transport_stats[transport_name] = tstats;
- return true;
+std::unique_ptr<SessionStats> WebRtcSession::GetStats(
+ const ChannelNamePairs& channel_name_pairs) {
+ if (network_thread()->IsCurrent()) {
+ return GetStats_n(channel_name_pairs);
+ }
+ return network_thread()->Invoke<std::unique_ptr<SessionStats>>(
+ RTC_FROM_HERE,
+ rtc::Bind(&WebRtcSession::GetStats_n, this, channel_name_pairs));
}
bool WebRtcSession::GetLocalCertificate(
const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
- ASSERT(signaling_thread()->IsCurrent());
return transport_controller_->GetLocalCertificate(transport_name,
certificate);
}
std::unique_ptr<rtc::SSLCertificate> WebRtcSession::GetRemoteSSLCertificate(
const std::string& transport_name) {
- ASSERT(signaling_thread()->IsCurrent());
return transport_controller_->GetRemoteSSLCertificate(transport_name);
}
@@ -1716,6 +1709,28 @@ bool WebRtcSession::CreateDataChannel(const cricket::ContentInfo* content,
return true;
}
+std::unique_ptr<SessionStats> WebRtcSession::GetStats_n(
+ const ChannelNamePairs& channel_name_pairs) {
+ ASSERT(network_thread()->IsCurrent());
+ std::unique_ptr<SessionStats> session_stats(new SessionStats());
+ for (const auto channel_name_pair : { &channel_name_pairs.voice,
+ &channel_name_pairs.video,
+ &channel_name_pairs.data }) {
+ if (*channel_name_pair) {
+ cricket::TransportStats transport_stats;
+ if (!transport_controller_->GetStats((*channel_name_pair)->transport_name,
+ &transport_stats)) {
+ return nullptr;
+ }
+ session_stats->proxy_to_transport[(*channel_name_pair)->content_name] =
+ (*channel_name_pair)->transport_name;
+ session_stats->transport_stats[(*channel_name_pair)->transport_name] =
+ std::move(transport_stats);
+ }
+ }
+ return session_stats;
+}
+
void WebRtcSession::OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp) {
SetError(ERROR_TRANSPORT,
rtcp ? kDtlsSetupFailureRtcp : kDtlsSetupFailureRtp);
« no previous file with comments | « webrtc/api/webrtcsession.h ('k') | webrtc/api/webrtcsession_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698