Reland "stats: migrate to Timestamp"

This is a reland of commit 2235776597e2f47ec353ac911428eb9a54d64a10

Original change's description:
> stats: migrate to Timestamp
>
> BUG=webrtc:13756
>
> Change-Id: I04ba57f9c2ca5a974a406814023911b4eb2d6d38
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/273942
> Commit-Queue: Philipp Hancke <phancke@microsoft.com>
> Reviewed-by: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#38365}

Bug: webrtc:13756
Change-Id: Ib8dc208197ae5e90f67114e7b043a73ee35421ea
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279080
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38380}
This commit is contained in:
Philipp Hancke
2022-10-12 19:12:23 +02:00
committed by WebRTC LUCI CQ
parent f363d0d4d3
commit 036b3fdea2
7 changed files with 40 additions and 17 deletions

View File

@ -706,6 +706,7 @@ rtc_source_set("rtc_stats_api") {
"../rtc_base:checks",
"../rtc_base:refcount",
"../rtc_base/system:rtc_export",
"units:timestamp",
]
}

View File

@ -23,6 +23,7 @@
#include "api/ref_counted_base.h"
#include "api/scoped_refptr.h"
#include "api/stats/rtc_stats.h"
#include "api/units/timestamp.h"
// TODO(tommi): Remove this include after fixing iwyu issue in chromium.
// See: third_party/blink/renderer/platform/peerconnection/rtc_stats.cc
#include "rtc_base/ref_counted_object.h"
@ -59,15 +60,21 @@ class RTC_EXPORT RTCStatsReport final
StatsMap::const_iterator it_;
};
// TODO(hbos): Remove "= 0" once Chromium unittest has been updated to call
// with a parameter. crbug.com/627816
// 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.
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.
explicit RTCStatsReport(int64_t timestamp_us);
explicit RTCStatsReport(Timestamp timestamp);
RTCStatsReport(const RTCStatsReport& other) = delete;
rtc::scoped_refptr<RTCStatsReport> Copy() const;
int64_t timestamp_us() const { return timestamp_us_; }
int64_t timestamp_us() const { return timestamp_.us_or(-1); }
Timestamp timestamp() const { return timestamp_; }
void AddStats(std::unique_ptr<const RTCStats> stats);
// On success, returns a non-owning pointer to `stats`. If the stats ID is not
// unique, `stats` is not inserted and nullptr is returned.
@ -128,7 +135,7 @@ class RTC_EXPORT RTCStatsReport final
~RTCStatsReport() = default;
private:
int64_t timestamp_us_;
Timestamp timestamp_;
StatsMap stats_;
};