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

Unified Diff: webrtc/api/rtcstatscollector.cc

Issue 2593503003: RTCStatsReport::AddStats DCHECKs that the ID is unique. (Closed)
Patch Set: 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 | « no previous file | webrtc/api/rtcstatscollector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/rtcstatscollector.cc
diff --git a/webrtc/api/rtcstatscollector.cc b/webrtc/api/rtcstatscollector.cc
index f1c7ed7e1acb1ae773753d9586c55a3f07c132e8..cf97057c1b6884595618b3083beeacad5727f93d 100644
--- a/webrtc/api/rtcstatscollector.cc
+++ b/webrtc/api/rtcstatscollector.cc
@@ -233,8 +233,17 @@ void ProduceCertificateStatsFromSSLCertificateStats(
RTCCertificateStats* prev_certificate_stats = nullptr;
for (const rtc::SSLCertificateStats* s = &certificate_stats; s;
s = s->issuer.get()) {
+ std::string certificate_stats_id =
+ RTCCertificateIDFromFingerprint(s->fingerprint);
+ // It is possible for the same certificate to show up multiple times, e.g.
+ // if local and remote side use the same certificate in a loopback call.
+ // If the report already contains stats for this certificate, skip it.
+ if (report->Get(certificate_stats_id)) {
+ RTC_DCHECK_EQ(s, &certificate_stats);
+ break;
+ }
RTCCertificateStats* certificate_stats = new RTCCertificateStats(
- RTCCertificateIDFromFingerprint(s->fingerprint), timestamp_us);
+ certificate_stats_id, timestamp_us);
certificate_stats->fingerprint = s->fingerprint;
certificate_stats->fingerprint_algorithm = s->fingerprint_algorithm;
certificate_stats->base64_certificate = s->base64_certificate;
@@ -288,8 +297,9 @@ void ProduceMediaStreamAndTrackStats(
MediaStreamInterface* stream = streams->at(i);
std::unique_ptr<RTCMediaStreamStats> stream_stats(
- new RTCMediaStreamStats("RTCMediaStream_" + stream->label(),
- timestamp_us));
+ new RTCMediaStreamStats(
+ (is_local ? "RTCMediaStream_local_" : "RTCMediaStream_remote_") +
+ stream->label(), timestamp_us));
stream_stats->stream_identifier = stream->label();
stream_stats->track_ids = std::vector<std::string>();
// Audio Tracks
« no previous file with comments | « no previous file | webrtc/api/rtcstatscollector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698