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

Unified Diff: webrtc/stats/rtcstats.cc

Issue 2441543002: RTCStats equality operator added (Closed)
Patch Set: Created 4 years, 2 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
Index: webrtc/stats/rtcstats.cc
diff --git a/webrtc/stats/rtcstats.cc b/webrtc/stats/rtcstats.cc
index 543ef420139512c32f428ce3ef0dd23a4dacdf82..0edd1deb8529f66813fcad55d447927edd21415c 100644
--- a/webrtc/stats/rtcstats.cc
+++ b/webrtc/stats/rtcstats.cc
@@ -48,6 +48,27 @@ std::string VectorOfStringsToString(const std::vector<T>& strings) {
} // namespace
+bool RTCStats::operator==(const RTCStats& other) const {
+ if (type() != other.type())
+ return false;
+ std::vector<const RTCStatsMemberInterface*> members = Members();
hta-webrtc 2016/10/21 08:56:01 What about the id and the timestamp? Are they sig
hbos_chromium 2016/10/21 18:59:18 They should also be compared too, fixed that. Done
+ std::vector<const RTCStatsMemberInterface*> other_members = other.Members();
+ RTC_DCHECK_EQ(members.size(), other_members.size());
+ for (size_t i = 0; i < members.size(); ++i) {
+ const RTCStatsMemberInterface* member = members[i];
+ const RTCStatsMemberInterface* other_member = other_members[i];
+ RTC_DCHECK_EQ(member->type(), other_member->type());
+ RTC_DCHECK_EQ(member->name(), other_member->name());
+ if (*member != *other_member)
+ return false;
+ }
+ return true;
+}
+
+bool RTCStats::operator!=(const RTCStats& other) const {
+ return !(*this == other);
+}
+
std::string RTCStats::ToString() const {
std::ostringstream oss;
oss << type() << " {\n id: \"" << id_ << "\"\n timestamp: "

Powered by Google App Engine
This is Rietveld 408576698