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/stats/rtcstats_unittest.cc b/webrtc/stats/rtcstats_unittest.cc
index 44e75c4..1d4e016 100644
--- a/webrtc/stats/rtcstats_unittest.cc
+++ b/webrtc/stats/rtcstats_unittest.cc
@@ -17,8 +17,8 @@
class RTCTestStats : public RTCStats {
public:
- RTCTestStats(const std::string& id, double timestamp)
- : RTCStats(id, timestamp),
+ RTCTestStats(const std::string& id, int64_t timestamp_us)
+ : RTCStats(id, timestamp_us),
m_int32("mInt32"),
m_uint32("mUint32"),
m_int64("mInt64"),
@@ -72,8 +72,8 @@
class RTCChildStats : public RTCStats {
public:
- RTCChildStats(const std::string& id, double timestamp)
- : RTCStats(id, timestamp),
+ RTCChildStats(const std::string& id, int64_t timestamp_us)
+ : RTCStats(id, timestamp_us),
child_int("childInt") {}
WEBRTC_RTCSTATS_IMPL(RTCStats, RTCChildStats,
@@ -86,8 +86,8 @@
class RTCGrandChildStats : public RTCChildStats {
public:
- RTCGrandChildStats(const std::string& id, double timestamp)
- : RTCChildStats(id, timestamp),
+ RTCGrandChildStats(const std::string& id, int64_t timestamp_us)
+ : RTCChildStats(id, timestamp_us),
grandchild_int("grandchildInt") {}
WEBRTC_RTCSTATS_IMPL(RTCChildStats, RTCGrandChildStats,
@@ -99,9 +99,9 @@
const char RTCGrandChildStats::kType[] = "grandchild-stats";
TEST(RTCStatsTest, RTCStatsAndMembers) {
- RTCTestStats stats("testId", 42.0);
+ RTCTestStats stats("testId", 42);
EXPECT_EQ(stats.id(), "testId");
- EXPECT_EQ(stats.timestamp(), 42.0);
+ EXPECT_EQ(stats.timestamp_us(), static_cast<int64_t>(42));
std::vector<const RTCStatsMemberInterface*> members = stats.Members();
EXPECT_EQ(members.size(), static_cast<size_t>(14));
for (const RTCStatsMemberInterface* member : members) {