RTCStatsCollector: timestamps updated.
Using a timestamp based on a timer that is monotonically increasing for
the cache, so that cache's freshness can be checked regardless of if
system clock is modified.
Using a system clock for the stats' timestamp, which needs to be
relative to UNIX epoch (Jan 1, 1970, UTC).
This CL removes the dependency on faketiming.h.
BUG=chromium:627816
NOTRY=True
Review-Url: https://codereview.webrtc.org/2299643002
Cr-Commit-Position: refs/heads/master@{#13997}
diff --git a/webrtc/api/rtcstats.h b/webrtc/api/rtcstats.h
index 4b2d70f..1196e97 100644
--- a/webrtc/api/rtcstats.h
+++ b/webrtc/api/rtcstats.h
@@ -49,17 +49,17 @@
// }
class RTCStats {
public:
- RTCStats(const std::string& id, double timestamp)
- : id_(id), timestamp_(timestamp) {}
- RTCStats(std::string&& id, double timestamp)
- : id_(std::move(id)), timestamp_(timestamp) {}
+ RTCStats(const std::string& id, int64_t timestamp_us)
+ : id_(id), timestamp_us_(timestamp_us) {}
+ RTCStats(std::string&& id, int64_t timestamp_us)
+ : id_(std::move(id)), timestamp_us_(timestamp_us) {}
virtual ~RTCStats() {}
virtual std::unique_ptr<RTCStats> copy() const = 0;
const std::string& id() const { return id_; }
- // Time relative to the UNIX epoch (Jan 1, 1970, UTC), in seconds.
- double timestamp() const { return timestamp_; }
+ // Time relative to the UNIX epoch (Jan 1, 1970, UTC), in microseconds.
+ int64_t timestamp_us() const { return timestamp_us_; }
// Returns the static member variable |kType| of the implementing class.
virtual const char* type() const = 0;
// Returns a vector of pointers to all the RTCStatsMemberInterface members of
@@ -88,7 +88,7 @@
size_t additional_capacity) const;
std::string const id_;
- double timestamp_;
+ int64_t timestamp_us_;
};
// All |RTCStats| classes should use this macro in a public section of the class
@@ -112,8 +112,8 @@
// rtcfoostats.h:
// class RTCFooStats : public RTCStats {
// public:
-// RTCFooStats(const std::string& id, double timestamp)
-// : RTCStats(id, timestamp),
+// RTCFooStats(const std::string& id, int64_t timestamp_us)
+// : RTCStats(id, timestamp_us),
// foo("foo"),
// bar("bar") {
// }
diff --git a/webrtc/api/rtcstats_objects.h b/webrtc/api/rtcstats_objects.h
index 8c03edf..4bc889d 100644
--- a/webrtc/api/rtcstats_objects.h
+++ b/webrtc/api/rtcstats_objects.h
@@ -19,8 +19,8 @@
class RTCPeerConnectionStats : public RTCStats {
public:
- RTCPeerConnectionStats(const std::string& id, double timestamp);
- RTCPeerConnectionStats(std::string&& id, double timestamp);
+ RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
+ RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
WEBRTC_RTCSTATS_IMPL(RTCStats, RTCPeerConnectionStats,
&data_channels_opened,