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

Side by Side Diff: webrtc/stats/rtcstatsreport.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 unified diff | Download patch
« no previous file with comments | « webrtc/api/stats/rtcstatsreport.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 new rtc::RefCountedObject<RTCStatsReport>(timestamp_us)); 62 new rtc::RefCountedObject<RTCStatsReport>(timestamp_us));
63 } 63 }
64 64
65 RTCStatsReport::RTCStatsReport(int64_t timestamp_us) 65 RTCStatsReport::RTCStatsReport(int64_t timestamp_us)
66 : timestamp_us_(timestamp_us) { 66 : timestamp_us_(timestamp_us) {
67 } 67 }
68 68
69 RTCStatsReport::~RTCStatsReport() { 69 RTCStatsReport::~RTCStatsReport() {
70 } 70 }
71 71
72 bool RTCStatsReport::AddStats(std::unique_ptr<const RTCStats> stats) { 72 void RTCStatsReport::AddStats(std::unique_ptr<const RTCStats> stats) {
73 return !stats_.insert(std::make_pair(std::string(stats->id()), 73 auto result = stats_.insert(std::make_pair(std::string(stats->id()),
74 std::move(stats))).second; 74 std::move(stats)));
75 RTC_DCHECK(result.second) <<
76 "A stats object with ID " << result.first->second->id() << " is already "
77 "present in this stats report.";
75 } 78 }
76 79
77 const RTCStats* RTCStatsReport::Get(const std::string& id) const { 80 const RTCStats* RTCStatsReport::Get(const std::string& id) const {
78 StatsMap::const_iterator it = stats_.find(id); 81 StatsMap::const_iterator it = stats_.find(id);
79 if (it != stats_.cend()) 82 if (it != stats_.cend())
80 return it->second.get(); 83 return it->second.get();
81 return nullptr; 84 return nullptr;
82 } 85 }
83 86
84 void RTCStatsReport::TakeMembersFrom( 87 void RTCStatsReport::TakeMembersFrom(
(...skipping 21 matching lines...) Expand all
106 if (it != end()) { 109 if (it != end()) {
107 oss << it->ToString(); 110 oss << it->ToString();
108 for (++it; it != end(); ++it) { 111 for (++it; it != end(); ++it) {
109 oss << '\n' << it->ToString(); 112 oss << '\n' << it->ToString();
110 } 113 }
111 } 114 }
112 return oss.str(); 115 return oss.str();
113 } 116 }
114 117
115 } // namespace webrtc 118 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/stats/rtcstatsreport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698