Chromium Code Reviews| Index: webrtc/pc/rtcstatscollector.cc |
| diff --git a/webrtc/pc/rtcstatscollector.cc b/webrtc/pc/rtcstatscollector.cc |
| index f5b8c8a936c1b569826ff20d98741e62ddb5e550..dcb417c885511989538a54756452f8ed7d2d95a2 100644 |
| --- a/webrtc/pc/rtcstatscollector.cc |
| +++ b/webrtc/pc/rtcstatscollector.cc |
| @@ -24,12 +24,21 @@ |
| #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 { |
| +std::string TraceNameFromStatsTypeAndMemberName(const char* stats_type, |
| + const char* member_name) { |
| + char buffer[80]; |
| + rtc::sprintfn(&buffer[0], sizeof(buffer), "%s.%s", stats_type, member_name); |
|
tommi
2017/07/12 16:53:03
You might want to add dchecks for the length of th
|
| + return buffer; |
| +} |
| + |
| std::string RTCCertificateIDFromFingerprint(const std::string& fingerprint) { |
| return "RTCCertificate_" + fingerprint; |
| } |
| @@ -751,6 +760,20 @@ 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", |
| + TraceNameFromStatsTypeAndMemberName( |
| + stats.type(), member->name()).c_str(), |
|
tommi
2017/07/12 16:53:03
Have you checked if this is a concern?
https://cs.
ehmaldonado_webrtc
2017/07/12 18:57:10
Right, I missed that. :(
I think the easiest way
|
| + "value", member->ValueToString(), |
| + "id", stats.id()); |
| + } |
| + } |
| + } |
| DeliverCachedReport(); |
| } |
| } |