stats: Deprecate RTCStatsReport(int64 timestamp_us)

in favor of the variant with (or returning) a Timestamp object.

BUG=webrtc:14813,webrtc:13756

Change-Id: I7b40f48f640a8be40a134b380a7a1b99cc99913b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/294287
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#39366}
This commit is contained in:
Philipp Hancke 2023-02-21 13:34:48 +01:00 committed by WebRTC LUCI CQ
parent 39dab96b98
commit fe1b39a648
4 changed files with 8 additions and 6 deletions

View File

@ -63,16 +63,20 @@ class RTC_EXPORT RTCStatsReport final
// TODO(bugs.webrtc.org/13756): deprecate this in favor of Timestamp.
// TODO(hbos): Remove "= 0" once downstream has been updated to call with a
// parameter.
ABSL_DEPRECATED("Call Create with Timestamp instead")
static rtc::scoped_refptr<RTCStatsReport> Create(int64_t timestamp_us = 0);
static rtc::scoped_refptr<RTCStatsReport> Create(Timestamp timestamp);
// TODO(bugs.webrtc.org/13756): deprecate this in favor of Timestamp.
ABSL_DEPRECATED("Use constructor with Timestamp instead")
explicit RTCStatsReport(int64_t timestamp_us);
explicit RTCStatsReport(Timestamp timestamp);
RTCStatsReport(const RTCStatsReport& other) = delete;
rtc::scoped_refptr<RTCStatsReport> Copy() const;
// TODO(bugs.webrtc.org/13756): deprecate this in favor of Timestamp.
ABSL_DEPRECATED("Call timestamp() instead")
int64_t timestamp_us() const { return timestamp_.us_or(-1); }
Timestamp timestamp() const { return timestamp_; }
void AddStats(std::unique_ptr<const RTCStats> stats);

View File

@ -2434,7 +2434,7 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock,
// The fake clock ensures that no time has passed so the cache must have been
// explicitly invalidated.
EXPECT_EQ(first_report->timestamp_us(), second_report->timestamp_us());
EXPECT_EQ(first_report->timestamp(), second_report->timestamp());
}
TEST_P(PeerConnectionIntegrationTestWithFakeClock,
@ -2478,7 +2478,7 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock,
// The fake clock ensures that no time has passed so the cache must have been
// explicitly invalidated.
EXPECT_EQ(first_report->timestamp_us(), second_report->timestamp_us());
EXPECT_EQ(first_report->timestamp(), second_report->timestamp());
}
#endif // !defined(THREAD_SANITIZER)

View File

@ -56,7 +56,8 @@ bool RTCStatsReport::ConstIterator::operator!=(
rtc::scoped_refptr<RTCStatsReport> RTCStatsReport::Create(
int64_t timestamp_us) {
return rtc::scoped_refptr<RTCStatsReport>(new RTCStatsReport(timestamp_us));
return rtc::scoped_refptr<RTCStatsReport>(
new RTCStatsReport(Timestamp::Micros(timestamp_us)));
}
rtc::scoped_refptr<RTCStatsReport> RTCStatsReport::Create(Timestamp timestamp) {

View File

@ -55,7 +55,6 @@ WEBRTC_RTCSTATS_IMPL(RTCTestStats3, RTCStats, "test-stats-3", &string)
TEST(RTCStatsReport, AddAndGetStats) {
rtc::scoped_refptr<RTCStatsReport> report =
RTCStatsReport::Create(Timestamp::Micros(1337));
EXPECT_EQ(report->timestamp_us(), 1337u);
EXPECT_EQ(report->timestamp().us_or(-1), 1337u);
EXPECT_EQ(report->size(), static_cast<size_t>(0));
report->AddStats(
@ -140,7 +139,6 @@ TEST(RTCStatsReport, Take) {
TEST(RTCStatsReport, TakeMembersFrom) {
rtc::scoped_refptr<RTCStatsReport> a =
RTCStatsReport::Create(Timestamp::Micros(1337));
EXPECT_EQ(a->timestamp().us(), 1337u);
EXPECT_EQ(a->timestamp().us_or(-1), 1337u);
a->AddStats(
std::unique_ptr<RTCStats>(new RTCTestStats1("B", Timestamp::Micros(1))));
@ -150,7 +148,6 @@ TEST(RTCStatsReport, TakeMembersFrom) {
std::unique_ptr<RTCStats>(new RTCTestStats1("E", Timestamp::Micros(4))));
rtc::scoped_refptr<RTCStatsReport> b =
RTCStatsReport::Create(Timestamp::Micros(1338));
EXPECT_EQ(b->timestamp_us(), 1338u);
EXPECT_EQ(b->timestamp().us_or(-1), 1338u);
b->AddStats(
std::unique_ptr<RTCStats>(new RTCTestStats1("A", Timestamp::Micros(0))));