OLD | NEW |
---|---|
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 virtual ~RTCStats() {} | 56 virtual ~RTCStats() {} |
57 | 57 |
58 virtual std::unique_ptr<RTCStats> copy() const = 0; | 58 virtual std::unique_ptr<RTCStats> copy() const = 0; |
59 | 59 |
60 const std::string& id() const { return id_; } | 60 const std::string& id() const { return id_; } |
61 // Time relative to the UNIX epoch (Jan 1, 1970, UTC), in microseconds. | 61 // Time relative to the UNIX epoch (Jan 1, 1970, UTC), in microseconds. |
62 int64_t timestamp_us() const { return timestamp_us_; } | 62 int64_t timestamp_us() const { return timestamp_us_; } |
63 // Returns the static member variable |kType| of the implementing class. | 63 // Returns the static member variable |kType| of the implementing class. |
64 virtual const char* type() const = 0; | 64 virtual const char* type() const = 0; |
65 // Returns a vector of pointers to all the RTCStatsMemberInterface members of | 65 // Returns a vector of pointers to all the RTCStatsMemberInterface members of |
66 // this class. This allows for iteration of members. | 66 // this class. This allows for iteration of members. The member order must be |
67 // well-defined, the i-th member of two |RTCStats| objects of the same type | |
68 // must correspond to the same member. | |
hta-webrtc
2016/10/21 08:56:01
This is a reflection of the fact that the Members(
hbos_chromium
2016/10/21 18:59:18
Done.
| |
67 std::vector<const RTCStatsMemberInterface*> Members() const; | 69 std::vector<const RTCStatsMemberInterface*> Members() const; |
70 // Checks if the two stats objects are of the same type and have the same | |
71 // member values. | |
72 bool operator==(const RTCStats& other) const; | |
73 bool operator!=(const RTCStats& other) const; | |
68 | 74 |
69 // Creates a human readable string representation of the report, listing all | 75 // Creates a human readable string representation of the report, listing all |
70 // of its members (names and values). | 76 // of its members (names and values). |
71 std::string ToString() const; | 77 std::string ToString() const; |
72 | 78 |
73 // Downcasts the stats object to an |RTCStats| subclass |T|. DCHECKs that the | 79 // Downcasts the stats object to an |RTCStats| subclass |T|. DCHECKs that the |
74 // object is of type |T|. | 80 // object is of type |T|. |
75 template<typename T> | 81 template<typename T> |
76 const T& cast_to() const { | 82 const T& cast_to() const { |
77 RTC_DCHECK_EQ(type(), T::kType); | 83 RTC_DCHECK_EQ(type(), T::kType); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 kSequenceString, // std::vector<std::string> | 208 kSequenceString, // std::vector<std::string> |
203 }; | 209 }; |
204 | 210 |
205 virtual ~RTCStatsMemberInterface() {} | 211 virtual ~RTCStatsMemberInterface() {} |
206 | 212 |
207 const char* name() const { return name_; } | 213 const char* name() const { return name_; } |
208 virtual Type type() const = 0; | 214 virtual Type type() const = 0; |
209 virtual bool is_sequence() const = 0; | 215 virtual bool is_sequence() const = 0; |
210 virtual bool is_string() const = 0; | 216 virtual bool is_string() const = 0; |
211 bool is_defined() const { return is_defined_; } | 217 bool is_defined() const { return is_defined_; } |
218 // Type and value comparator (can be true even if name and type isn't). | |
hta-webrtc
2016/10/21 08:56:01
Even if name and type isn't what?
hbos_chromium
2016/10/21 18:59:18
That was a bit nonsensey. Changed to "Type and val
| |
219 virtual bool operator==(const RTCStatsMemberInterface& other) const = 0; | |
220 bool operator!=(const RTCStatsMemberInterface& other) const { | |
221 return !(*this == other); | |
222 } | |
212 virtual std::string ValueToString() const = 0; | 223 virtual std::string ValueToString() const = 0; |
213 | 224 |
214 template<typename T> | 225 template<typename T> |
215 const T& cast_to() const { | 226 const T& cast_to() const { |
216 RTC_DCHECK_EQ(type(), T::kType); | 227 RTC_DCHECK_EQ(type(), T::kType); |
217 return static_cast<const T&>(*this); | 228 return static_cast<const T&>(*this); |
218 } | 229 } |
219 | 230 |
220 protected: | 231 protected: |
221 RTCStatsMemberInterface(const char* name, bool is_defined) | 232 RTCStatsMemberInterface(const char* name, bool is_defined) |
(...skipping 24 matching lines...) Expand all Loading... | |
246 explicit RTCStatsMember(const RTCStatsMember<T>& other) | 257 explicit RTCStatsMember(const RTCStatsMember<T>& other) |
247 : RTCStatsMemberInterface(other.name_, other.is_defined_), | 258 : RTCStatsMemberInterface(other.name_, other.is_defined_), |
248 value_(other.value_) {} | 259 value_(other.value_) {} |
249 explicit RTCStatsMember(RTCStatsMember<T>&& other) | 260 explicit RTCStatsMember(RTCStatsMember<T>&& other) |
250 : RTCStatsMemberInterface(other.name_, other.is_defined_), | 261 : RTCStatsMemberInterface(other.name_, other.is_defined_), |
251 value_(std::move(other.value_)) {} | 262 value_(std::move(other.value_)) {} |
252 | 263 |
253 Type type() const override { return kType; } | 264 Type type() const override { return kType; } |
254 bool is_sequence() const override; | 265 bool is_sequence() const override; |
255 bool is_string() const override; | 266 bool is_string() const override; |
267 bool operator==(const RTCStatsMemberInterface& other) const override { | |
268 if (type() != other.type()) | |
269 return false; | |
270 const RTCStatsMember<T>& other_t = | |
271 static_cast<const RTCStatsMember<T>&>(other); | |
272 if (!is_defined_) | |
273 return !other_t.is_defined(); | |
274 return value_ == other_t.value_; | |
275 } | |
hta-webrtc
2016/10/21 08:56:01
Didn't the presubmit check yell at you over having
hbos_chromium
2016/10/21 18:59:18
It does not, this is a template class.
| |
256 std::string ValueToString() const override; | 276 std::string ValueToString() const override; |
257 | 277 |
258 // Assignment operators. | 278 // Assignment operators. |
259 T& operator=(const T& value) { | 279 T& operator=(const T& value) { |
260 value_ = value; | 280 value_ = value; |
261 is_defined_ = true; | 281 is_defined_ = true; |
262 return value_; | 282 return value_; |
263 } | 283 } |
264 T& operator=(const T&& value) { | 284 T& operator=(const T&& value) { |
265 value_ = std::move(value); | 285 value_ = std::move(value); |
(...skipping 27 matching lines...) Expand all Loading... | |
293 return &value_; | 313 return &value_; |
294 } | 314 } |
295 | 315 |
296 private: | 316 private: |
297 T value_; | 317 T value_; |
298 }; | 318 }; |
299 | 319 |
300 } // namespace webrtc | 320 } // namespace webrtc |
301 | 321 |
302 #endif // WEBRTC_API_STATS_RTCSTATS_H_ | 322 #endif // WEBRTC_API_STATS_RTCSTATS_H_ |
OLD | NEW |