[Stats] Align RTCStatsMember<T> closer to absl::optional<T>.
Step 1: Make reading RTCStatsMember look the same as reading
absl::optional (this CL).
Step 2: Migrate uses of "is_defined()" to "has_value()".
Step 3: Delete "is_defined()".
Step 4: Make RTCStatsMember+Interface an implementation detail of
RTCStats::Members(), only used for abstract iteration ("for
each metric"). Lazy instantiate it upon Members().
Step 5: Replace RTCStatsMember with absl::optional for use in RTCStats
dictionaries (rtcstats_objects.h/cc).
Bug: webrtc:15164
Change-Id: I5a2c9fe56707e3c7d89e8ea62fb37171ae806a7c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/304840
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40048}
This commit is contained in:
parent
2ec9abdc40
commit
36fd351562
@ -353,7 +353,12 @@ class RTCStatsMember : public RTCStatsMemberInterface {
|
||||
return value_.value();
|
||||
}
|
||||
|
||||
// Value getters.
|
||||
// Getter methods that look the same as absl::optional<T>. Please prefer these
|
||||
// in order to unblock replacing RTCStatsMember<T> with absl::optional<T> in
|
||||
// the future (https://crbug.com/webrtc/15164).
|
||||
bool has_value() const { return value_.has_value(); }
|
||||
const T& value() const { return value_.value(); }
|
||||
T& value() { return value_.value(); }
|
||||
T& operator*() {
|
||||
RTC_DCHECK(value_);
|
||||
return *value_;
|
||||
@ -362,8 +367,6 @@ class RTCStatsMember : public RTCStatsMemberInterface {
|
||||
RTC_DCHECK(value_);
|
||||
return *value_;
|
||||
}
|
||||
|
||||
// Value getters, arrow operator.
|
||||
T* operator->() {
|
||||
RTC_DCHECK(value_);
|
||||
return &(*value_);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user