Use void* instead of uintptr_t for tracking pointers.
RTCStatsCollector internally keeps track of open data channels but does not need (or want) to interact directly with those channels, hence uintptr_t was used instead of pointers to the channel objects. This changes that to use void* to avoid having to do the cast. This is a follow-up action item to https://webrtc-review.googlesource.com/c/src/+/295781 This CL also changes the container type: std::set -> webrtc::flat_set Bug: webrtc:12689 Change-Id: I13d3f4a41ef83dab38411193187e872b9d6d3cff Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/295871 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39468}
This commit is contained in:
parent
c2429a080d
commit
60d4adcde0
@ -1063,6 +1063,7 @@ rtc_source_set("rtc_stats_collector") {
|
|||||||
"../rtc_base:stringutils",
|
"../rtc_base:stringutils",
|
||||||
"../rtc_base:threading",
|
"../rtc_base:threading",
|
||||||
"../rtc_base:timeutils",
|
"../rtc_base:timeutils",
|
||||||
|
"../rtc_base/containers:flat_set",
|
||||||
"../rtc_base/synchronization:mutex",
|
"../rtc_base/synchronization:mutex",
|
||||||
]
|
]
|
||||||
absl_deps = [
|
absl_deps = [
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -2496,16 +2497,13 @@ void RTCStatsCollector::OnSctpDataChannelStateChanged(
|
|||||||
DataChannelInterface::DataState state) {
|
DataChannelInterface::DataState state) {
|
||||||
RTC_DCHECK_RUN_ON(signaling_thread_);
|
RTC_DCHECK_RUN_ON(signaling_thread_);
|
||||||
if (state == DataChannelInterface::DataState::kOpen) {
|
if (state == DataChannelInterface::DataState::kOpen) {
|
||||||
bool result = internal_record_.opened_data_channels
|
bool result = internal_record_.opened_data_channels.insert(channel).second;
|
||||||
.insert(reinterpret_cast<uintptr_t>(channel))
|
|
||||||
.second;
|
|
||||||
RTC_DCHECK(result);
|
RTC_DCHECK(result);
|
||||||
++internal_record_.data_channels_opened;
|
++internal_record_.data_channels_opened;
|
||||||
} else if (state == DataChannelInterface::DataState::kClosed) {
|
} else if (state == DataChannelInterface::DataState::kClosed) {
|
||||||
// Only channels that have been fully opened (and have increased the
|
// Only channels that have been fully opened (and have increased the
|
||||||
// `data_channels_opened_` counter) increase the closed counter.
|
// `data_channels_opened_` counter) increase the closed counter.
|
||||||
if (internal_record_.opened_data_channels.erase(
|
if (internal_record_.opened_data_channels.erase(channel)) {
|
||||||
reinterpret_cast<uintptr_t>(channel))) {
|
|
||||||
++internal_record_.data_channels_closed;
|
++internal_record_.data_channels_closed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -39,6 +38,7 @@
|
|||||||
#include "pc/track_media_info_map.h"
|
#include "pc/track_media_info_map.h"
|
||||||
#include "pc/transport_stats.h"
|
#include "pc/transport_stats.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
|
#include "rtc_base/containers/flat_set.h"
|
||||||
#include "rtc_base/event.h"
|
#include "rtc_base/event.h"
|
||||||
#include "rtc_base/ref_count.h"
|
#include "rtc_base/ref_count.h"
|
||||||
#include "rtc_base/ssl_certificate.h"
|
#include "rtc_base/ssl_certificate.h"
|
||||||
@ -323,7 +323,10 @@ class RTCStatsCollector : public rtc::RefCountInterface {
|
|||||||
uint32_t data_channels_closed;
|
uint32_t data_channels_closed;
|
||||||
// Identifies by address channels that have been opened, which remain in the
|
// Identifies by address channels that have been opened, which remain in the
|
||||||
// set until they have been fully closed.
|
// set until they have been fully closed.
|
||||||
std::set<uintptr_t> opened_data_channels;
|
// NOTE: There is no reference held here or any other type of guarantee that
|
||||||
|
// these pointers remain valid. So they MUST NOT be followed; hence, void*
|
||||||
|
// is used and not the explicit type.
|
||||||
|
webrtc::flat_set<void*> opened_data_channels;
|
||||||
};
|
};
|
||||||
InternalRecord internal_record_;
|
InternalRecord internal_record_;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user