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

Side by Side Diff: webrtc/stats/rtcstats.cc

Issue 2441543002: RTCStats equality operator added (Closed)
Patch Set: Addressed comments and rebase with master Created 4 years, 1 month 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/rtcstats.h ('k') | webrtc/stats/rtcstats_unittest.cc » ('j') | 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 30 matching lines...) Expand all
41 oss << "{ \"" << rtc::ToString<T>(strings[0]) << '\"'; 41 oss << "{ \"" << rtc::ToString<T>(strings[0]) << '\"';
42 for (size_t i = 1; i < strings.size(); ++i) { 42 for (size_t i = 1; i < strings.size(); ++i) {
43 oss << ", \"" << rtc::ToString<T>(strings[i]) << '\"'; 43 oss << ", \"" << rtc::ToString<T>(strings[i]) << '\"';
44 } 44 }
45 oss << " }"; 45 oss << " }";
46 return oss.str(); 46 return oss.str();
47 } 47 }
48 48
49 } // namespace 49 } // namespace
50 50
51 bool RTCStats::operator==(const RTCStats& other) const {
52 if (type() != other.type() || id() != other.id() ||
53 timestamp_us() != other.timestamp_us()) {
54 return false;
55 }
56 std::vector<const RTCStatsMemberInterface*> members = Members();
57 std::vector<const RTCStatsMemberInterface*> other_members = other.Members();
58 RTC_DCHECK_EQ(members.size(), other_members.size());
59 for (size_t i = 0; i < members.size(); ++i) {
60 const RTCStatsMemberInterface* member = members[i];
61 const RTCStatsMemberInterface* other_member = other_members[i];
62 RTC_DCHECK_EQ(member->type(), other_member->type());
63 RTC_DCHECK_EQ(member->name(), other_member->name());
64 if (*member != *other_member)
65 return false;
66 }
67 return true;
68 }
69
70 bool RTCStats::operator!=(const RTCStats& other) const {
71 return !(*this == other);
72 }
73
51 std::string RTCStats::ToString() const { 74 std::string RTCStats::ToString() const {
52 std::ostringstream oss; 75 std::ostringstream oss;
53 oss << type() << " {\n id: \"" << id_ << "\"\n timestamp: " 76 oss << type() << " {\n id: \"" << id_ << "\"\n timestamp: "
54 << timestamp_us_ << '\n'; 77 << timestamp_us_ << '\n';
55 for (const RTCStatsMemberInterface* member : Members()) { 78 for (const RTCStatsMemberInterface* member : Members()) {
56 oss << " " << member->name() << ": "; 79 oss << " " << member->name() << ": ";
57 if (member->is_defined()) { 80 if (member->is_defined()) {
58 if (member->is_string()) 81 if (member->is_string())
59 oss << '"' << member->ValueToString() << "\"\n"; 82 oss << '"' << member->ValueToString() << "\"\n";
60 else 83 else
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 std::vector<uint64_t>, kSequenceUint64, true, false, 146 std::vector<uint64_t>, kSequenceUint64, true, false,
124 VectorToString(value_)); 147 VectorToString(value_));
125 WEBRTC_DEFINE_RTCSTATSMEMBER( 148 WEBRTC_DEFINE_RTCSTATSMEMBER(
126 std::vector<double>, kSequenceDouble, true, false, 149 std::vector<double>, kSequenceDouble, true, false,
127 VectorToString(value_)); 150 VectorToString(value_));
128 WEBRTC_DEFINE_RTCSTATSMEMBER( 151 WEBRTC_DEFINE_RTCSTATSMEMBER(
129 std::vector<std::string>, kSequenceString, true, false, 152 std::vector<std::string>, kSequenceString, true, false,
130 VectorOfStringsToString(value_)); 153 VectorOfStringsToString(value_));
131 154
132 } // namespace webrtc 155 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/stats/rtcstats.h ('k') | webrtc/stats/rtcstats_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698