Remove TURN port's duplicate pointer to field_trials.

Base port already keeps an AlwaysValidPointer to field_trials, so
TURN port's duplicate, private copy is redundant.

Bug: webrtc:14319, webrtc:14131
Change-Id: I94ee78ca5140c0b67826fbb94c35e28f30add943
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/270627
Reviewed-by: Jonas Oreland <jonaso@google.com>
Commit-Queue: Sameer Vijaykar <samvi@google.com>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37735}
This commit is contained in:
Sameer Vijaykar 2022-08-10 16:04:35 +02:00 committed by WebRTC LUCI CQ
parent 53cc9adfe2
commit ab5876a8ab
4 changed files with 9 additions and 13 deletions

View File

@ -175,7 +175,7 @@ void Port::Construct() {
password_ = rtc::CreateRandomString(ICE_PWD_LENGTH);
}
network_->SignalTypeChanged.connect(this, &Port::OnNetworkTypeChanged);
network_cost_ = network_->GetCost(*field_trials_);
network_cost_ = network_->GetCost(field_trials());
thread_->PostDelayed(RTC_FROM_HERE, timeout_delay_, this,
MSG_DESTROY_IF_DEAD);
@ -869,7 +869,7 @@ std::string Port::ToString() const {
// TODO(honghaiz): Make the network cost configurable from user setting.
void Port::UpdateNetworkCost() {
RTC_DCHECK_RUN_ON(thread_);
uint16_t new_cost = network_->GetCost(*field_trials_);
uint16_t new_cost = network_->GetCost(field_trials());
if (network_cost_ == new_cost) {
return;
}

View File

@ -465,6 +465,8 @@ class Port : public PortInterface,
mdns_name_registration_status_ = status;
}
const webrtc::FieldTrialsView& field_trials() const { return *field_trials_; }
private:
void Construct();

View File

@ -248,8 +248,7 @@ TurnPort::TurnPort(rtc::Thread* thread,
state_(STATE_CONNECTING),
server_priority_(server_priority),
allocate_mismatch_retries_(0),
turn_customizer_(customizer),
field_trials_(field_trials) {}
turn_customizer_(customizer) {}
TurnPort::TurnPort(rtc::Thread* thread,
rtc::PacketSocketFactory* factory,
@ -292,8 +291,7 @@ TurnPort::TurnPort(rtc::Thread* thread,
state_(STATE_CONNECTING),
server_priority_(server_priority),
allocate_mismatch_retries_(0),
turn_customizer_(customizer),
field_trials_(field_trials) {}
turn_customizer_(customizer) {}
TurnPort::~TurnPort() {
// TODO(juberti): Should this even be necessary?
@ -358,7 +356,7 @@ void TurnPort::PrepareAddress() {
server_address_.address.SetPort(TURN_DEFAULT_PORT);
}
if (!AllowedTurnPort(server_address_.address.port(), field_trials_)) {
if (!AllowedTurnPort(server_address_.address.port(), &field_trials())) {
// This can only happen after a 300 ALTERNATE SERVER, since the port can't
// be created with a disallowed port number.
RTC_LOG(LS_ERROR) << "Attempt to start allocation with disallowed port# "
@ -1253,8 +1251,7 @@ bool TurnPort::CreateOrRefreshEntry(const rtc::SocketAddress& addr,
RTC_DCHECK(GetConnection(addr));
}
if (field_trials_ &&
field_trials_->IsEnabled("WebRTC-TurnAddMultiMapping")) {
if (field_trials().IsEnabled("WebRTC-TurnAddMultiMapping")) {
if (entry->get_remote_ufrag() != remote_ufrag) {
RTC_LOG(LS_INFO) << ToString()
<< ": remote ufrag updated."
@ -1655,8 +1652,7 @@ TurnCreatePermissionRequest::TurnCreatePermissionRequest(
RTC_DCHECK_EQ(message->type(), TURN_CREATE_PERMISSION_REQUEST);
message->AddAttribute(std::make_unique<StunXorAddressAttribute>(
STUN_ATTR_XOR_PEER_ADDRESS, ext_addr_));
if (port_->field_trials_ &&
port_->field_trials_->IsEnabled("WebRTC-TurnAddMultiMapping")) {
if (port_->field_trials().IsEnabled("WebRTC-TurnAddMultiMapping")) {
message->AddAttribute(std::make_unique<cricket::StunByteStringAttribute>(
STUN_ATTR_MULTI_MAPPING, remote_ufrag_));
}

View File

@ -368,8 +368,6 @@ class TurnPort : public Port {
// must outlive the TurnPort's lifetime.
webrtc::TurnCustomizer* turn_customizer_ = nullptr;
const webrtc::FieldTrialsView* field_trials_;
// Optional TurnLoggingId.
// An identifier set by application that is added to TURN_ALLOCATE_REQUEST
// and can be used to match client/backend logs.