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

Unified Diff: webrtc/pc/rtcstatscollector.cc

Issue 2975793002: Trace stats in RTCStatsCollector. (Closed)
Patch Set: Rebase. Use '.' instead of '+' as separator. Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/pc/rtcstatscollector.cc
diff --git a/webrtc/pc/rtcstatscollector.cc b/webrtc/pc/rtcstatscollector.cc
index 01764e909a5c89c2a5af9fdd55c2c1bc733d5217..8fe03cc4b4c0f51718a2a28ff0fc0deadce3ef1b 100644
--- a/webrtc/pc/rtcstatscollector.cc
+++ b/webrtc/pc/rtcstatscollector.cc
@@ -24,12 +24,26 @@
#include "webrtc/pc/peerconnection.h"
#include "webrtc/pc/webrtcsession.h"
#include "webrtc/rtc_base/checks.h"
+#include "webrtc/rtc_base/stringutils.h"
#include "webrtc/rtc_base/timeutils.h"
+#include "webrtc/rtc_base/trace_event.h"
namespace webrtc {
namespace {
+const int kStatTypeMemberNameAndIdMaxLen = 120;
+
+std::string GetStatTypeMemberNameAndId(const RTCStats& stats,
+ const RTCStatsMemberInterface* member) {
+ RTC_DCHECK(strlen(stats.type()) + strlen(member->name())
+ + stats.id().size() + 3 < kStatTypeMemberNameAndIdMaxLen);
+ char buffer[kStatTypeMemberNameAndIdMaxLen];
+ rtc::sprintfn(&buffer[0], sizeof(buffer), "%s.%s.%s", stats.type(),
+ member->name(), stats.id().c_str());
+ return buffer;
+}
+
std::string RTCCertificateIDFromFingerprint(const std::string& fingerprint) {
return "RTCCertificate_" + fingerprint;
}
@@ -758,6 +772,19 @@ void RTCStatsCollector::AddPartialResults_s(
channel_name_pairs_.reset();
track_media_info_map_.reset();
track_to_id_.clear();
+ // Trace WebRTC Stats when getStats is called on Javascript.
+ // This allows access to WebRTC stats from trace logs. To enable them,
+ // select the "webrtc_stats" category when recording traces.
+ for (const RTCStats& stats : *cached_report_) {
+ for (const RTCStatsMemberInterface* member : stats.Members()) {
+ if (member->is_defined()) {
+ TRACE_EVENT_INSTANT2("webrtc_stats", "webrtc_stats",
+ "value", member->ValueToString(),
+ "type.name.id", GetStatTypeMemberNameAndId(
+ stats, member));
+ }
+ }
+ }
DeliverCachedReport();
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698