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

Unified Diff: webrtc/api/stats/rtcstats.h

Issue 2983243002: Make RTCStatsReport::ToString() return JSON-parseable string. (Closed)
Patch Set: Replace ToString with ToJson in test files. Created 3 years, 5 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 | « no previous file | webrtc/api/stats/rtcstatsreport.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/stats/rtcstats.h
diff --git a/webrtc/api/stats/rtcstats.h b/webrtc/api/stats/rtcstats.h
index 6730672012abd919b088d0a7bbf6341d4c50796c..d9ed7bc2f6df2601f531c28d9c7cc937ba4f5c0a 100644
--- a/webrtc/api/stats/rtcstats.h
+++ b/webrtc/api/stats/rtcstats.h
@@ -72,9 +72,9 @@ class RTCStats {
bool operator==(const RTCStats& other) const;
bool operator!=(const RTCStats& other) const;
- // Creates a human readable string representation of the stats object, listing
- // all of its members (names and values).
- std::string ToString() const;
+ // Creates a JSON readable string representation of the stats
+ // object, listing all of its members (names and values).
+ std::string ToJson() const;
// Downcasts the stats object to an |RTCStats| subclass |T|. DCHECKs that the
// object is of type |T|.
@@ -222,6 +222,12 @@ class RTCStatsMemberInterface {
return !(*this == other);
}
virtual std::string ValueToString() const = 0;
+ // This is the same as ValueToString except for kInt64 and kUint64 types,
+ // where the value is represented as a double instead of as an integer.
+ // Since JSON stores numbers as floating point numbers, very large integers
+ // cannot be accurately represented, so we prefer to display them as doubles
+ // instead.
+ virtual std::string ValueToJson() const = 0;
template<typename T>
const T& cast_to() const {
@@ -277,6 +283,7 @@ class RTCStatsMember : public RTCStatsMemberInterface {
return value_ == other_t.value_;
}
std::string ValueToString() const override;
+ std::string ValueToJson() const override;
// Assignment operators.
T& operator=(const T& value) {
« no previous file with comments | « no previous file | webrtc/api/stats/rtcstatsreport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698