[Stats] Migrate integration test to Attributes().
To unblock replacing RTCStatsMember<T> with absl::optional<T>. RTCStats::GetAttribute() is added to allow obtaining the name of a metric even after the replacement, the only usage of this AFAIK is this test file. Bug: webrtc:15164 Change-Id: I21e8b782ba86d9f864cb90885134c6724ba3398b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/334163 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41515}
This commit is contained in:
parent
2ab1997d9d
commit
40dcdf7fac
@ -71,6 +71,19 @@ class RTC_EXPORT RTCStats {
|
|||||||
// Returns all attributes of this stats object, i.e. a list of its individual
|
// Returns all attributes of this stats object, i.e. a list of its individual
|
||||||
// metrics as viewed via the Attribute wrapper.
|
// metrics as viewed via the Attribute wrapper.
|
||||||
std::vector<Attribute> Attributes() const;
|
std::vector<Attribute> Attributes() const;
|
||||||
|
template <typename T>
|
||||||
|
Attribute GetAttribute(const RTCStatsMember<T>& stat) const {
|
||||||
|
for (const auto& attribute : Attributes()) {
|
||||||
|
if (!attribute.holds_alternative<T>()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (absl::get<const RTCStatsMember<T>*>(attribute.as_variant()) ==
|
||||||
|
&stat) {
|
||||||
|
return attribute;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RTC_CHECK_NOTREACHED();
|
||||||
|
}
|
||||||
// Returns Attributes() as `RTCStatsMemberInterface` pointers.
|
// Returns Attributes() as `RTCStatsMemberInterface` pointers.
|
||||||
// TODO(https://crbug.com/webrtc/15164): Update callers to use Attributes()
|
// TODO(https://crbug.com/webrtc/15164): Update callers to use Attributes()
|
||||||
// instead and delete this method as well as the RTCStatsMemberInterface.
|
// instead and delete this method as well as the RTCStatsMemberInterface.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user