summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/api/stats/attribute.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/libwebrtc/api/stats/attribute.h
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/api/stats/attribute.h')
-rw-r--r--third_party/libwebrtc/api/stats/attribute.h54
1 files changed, 26 insertions, 28 deletions
diff --git a/third_party/libwebrtc/api/stats/attribute.h b/third_party/libwebrtc/api/stats/attribute.h
index 09211f469c..36500db999 100644
--- a/third_party/libwebrtc/api/stats/attribute.h
+++ b/third_party/libwebrtc/api/stats/attribute.h
@@ -16,37 +16,38 @@
#include <string>
#include <vector>
+#include "absl/types/optional.h"
#include "absl/types/variant.h"
-#include "api/stats/rtc_stats_member.h"
+#include "rtc_base/checks.h"
#include "rtc_base/system/rtc_export.h"
namespace webrtc {
-// A light-weight wrapper of an RTCStats attribute (an individual metric).
+// A light-weight wrapper of an RTCStats attribute, i.e. an individual metric of
+// type absl::optional<T>.
class RTC_EXPORT Attribute {
public:
- // TODO(https://crbug.com/webrtc/15164): Replace uses of RTCStatsMember<T>
- // with absl::optional<T> and update these pointer types.
- typedef absl::variant<const RTCStatsMember<bool>*,
- const RTCStatsMember<int32_t>*,
- const RTCStatsMember<uint32_t>*,
- const RTCStatsMember<int64_t>*,
- const RTCStatsMember<uint64_t>*,
- const RTCStatsMember<double>*,
- const RTCStatsMember<std::string>*,
- const RTCStatsMember<std::vector<bool>>*,
- const RTCStatsMember<std::vector<int32_t>>*,
- const RTCStatsMember<std::vector<uint32_t>>*,
- const RTCStatsMember<std::vector<int64_t>>*,
- const RTCStatsMember<std::vector<uint64_t>>*,
- const RTCStatsMember<std::vector<double>>*,
- const RTCStatsMember<std::vector<std::string>>*,
- const RTCStatsMember<std::map<std::string, uint64_t>>*,
- const RTCStatsMember<std::map<std::string, double>>*>
+ // All supported attribute types.
+ typedef absl::variant<const absl::optional<bool>*,
+ const absl::optional<int32_t>*,
+ const absl::optional<uint32_t>*,
+ const absl::optional<int64_t>*,
+ const absl::optional<uint64_t>*,
+ const absl::optional<double>*,
+ const absl::optional<std::string>*,
+ const absl::optional<std::vector<bool>>*,
+ const absl::optional<std::vector<int32_t>>*,
+ const absl::optional<std::vector<uint32_t>>*,
+ const absl::optional<std::vector<int64_t>>*,
+ const absl::optional<std::vector<uint64_t>>*,
+ const absl::optional<std::vector<double>>*,
+ const absl::optional<std::vector<std::string>>*,
+ const absl::optional<std::map<std::string, uint64_t>>*,
+ const absl::optional<std::map<std::string, double>>*>
StatVariant;
template <typename T>
- explicit Attribute(const char* name, const RTCStatsMember<T>* attribute)
+ Attribute(const char* name, const absl::optional<T>* attribute)
: name_(name), attribute_(attribute) {}
const char* name() const;
@@ -55,21 +56,18 @@ class RTC_EXPORT Attribute {
bool has_value() const;
template <typename T>
bool holds_alternative() const {
- return absl::holds_alternative<const RTCStatsMember<T>*>(attribute_);
+ return absl::holds_alternative<const absl::optional<T>*>(attribute_);
}
template <typename T>
- absl::optional<T> as_optional() const {
+ const absl::optional<T>& as_optional() const {
RTC_CHECK(holds_alternative<T>());
- if (!has_value()) {
- return absl::nullopt;
- }
- return absl::optional<T>(get<T>());
+ return *absl::get<const absl::optional<T>*>(attribute_);
}
template <typename T>
const T& get() const {
RTC_CHECK(holds_alternative<T>());
RTC_CHECK(has_value());
- return absl::get<const RTCStatsMember<T>*>(attribute_)->value();
+ return absl::get<const absl::optional<T>*>(attribute_)->value();
}
bool is_sequence() const;