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

Unified Diff: webrtc/stats/rtcstatsreport.cc

Issue 2278433003: RTCStatsReport: Take ownership of other's stats with TakeMembersFrom (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added comment Created 4 years, 4 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 | « webrtc/stats/rtcstats_unittest.cc ('k') | webrtc/stats/rtcstatsreport_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/stats/rtcstatsreport.cc
diff --git a/webrtc/stats/rtcstatsreport.cc b/webrtc/stats/rtcstatsreport.cc
index 870651d2dfc52b1afff2bda5f227ee57274c34ed..00a55f41fc7e03d83c5ae7e08c8d1334e4d0e9cd 100644
--- a/webrtc/stats/rtcstatsreport.cc
+++ b/webrtc/stats/rtcstatsreport.cc
@@ -66,13 +66,22 @@ bool RTCStatsReport::AddStats(std::unique_ptr<const RTCStats> stats) {
std::move(stats))).second;
}
-const RTCStats* RTCStatsReport::operator[](const std::string& id) const {
+const RTCStats* RTCStatsReport::Get(const std::string& id) const {
StatsMap::const_iterator it = stats_.find(id);
if (it != stats_.cend())
return it->second.get();
return nullptr;
}
+void RTCStatsReport::TakeMembersFrom(
+ rtc::scoped_refptr<RTCStatsReport> victim) {
+ for (StatsMap::iterator it = victim->stats_.begin();
+ it != victim->stats_.end(); ++it) {
+ AddStats(std::unique_ptr<const RTCStats>(it->second.release()));
+ }
+ victim->stats_.clear();
+}
+
RTCStatsReport::ConstIterator RTCStatsReport::begin() const {
return ConstIterator(rtc::scoped_refptr<const RTCStatsReport>(this),
stats_.cbegin());
« no previous file with comments | « webrtc/stats/rtcstats_unittest.cc ('k') | webrtc/stats/rtcstatsreport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698