Change PortInterface::Type to string_view and make type_ member const
Bug: none Change-Id: Id1b0298eede5d2ae5010cc450d7bcb9eadd7b874 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/318080 Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40801}
This commit is contained in:
parent
070d386cfc
commit
6bf2d31e71
@ -162,7 +162,10 @@ rtc_library("candidate") {
|
||||
"../rtc_base:stringutils",
|
||||
"../rtc_base/system:rtc_export",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/base:core_headers",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_source_set("turn_customizer") {
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/network_constants.h"
|
||||
@ -43,7 +44,7 @@ class RTC_EXPORT Candidate {
|
||||
uint32_t priority,
|
||||
absl::string_view username,
|
||||
absl::string_view password,
|
||||
absl::string_view type,
|
||||
absl::string_view type ABSL_ATTRIBUTE_LIFETIME_BOUND,
|
||||
uint32_t generation,
|
||||
absl::string_view foundation,
|
||||
uint16_t network_id = 0,
|
||||
@ -101,7 +102,14 @@ class RTC_EXPORT Candidate {
|
||||
void set_password(absl::string_view password) { Assign(password_, password); }
|
||||
|
||||
const std::string& type() const { return type_; }
|
||||
void set_type(absl::string_view type) { Assign(type_, type); }
|
||||
|
||||
// Setting the type requires a constant string (e.g.
|
||||
// cricket::LOCAL_PORT_TYPE). The type should really be an enum rather than a
|
||||
// string, but until we make that change the lifetime attribute helps us lock
|
||||
// things down. See also the `Port` class.
|
||||
void set_type(absl::string_view type ABSL_ATTRIBUTE_LIFETIME_BOUND) {
|
||||
Assign(type_, type);
|
||||
}
|
||||
|
||||
const std::string& network_name() const { return network_name_; }
|
||||
void set_network_name(absl::string_view network_name) {
|
||||
|
||||
@ -64,6 +64,7 @@ class TestUDPPort : public UDPPort {
|
||||
bool emit_localhost_for_anyaddress,
|
||||
const webrtc::FieldTrialsView* field_trials)
|
||||
: UDPPort(thread,
|
||||
LOCAL_PORT_TYPE,
|
||||
factory,
|
||||
network,
|
||||
min_port,
|
||||
|
||||
@ -192,7 +192,7 @@ Port::~Port() {
|
||||
DestroyAllConnections();
|
||||
}
|
||||
|
||||
const std::string& Port::Type() const {
|
||||
const absl::string_view Port::Type() const {
|
||||
return type_;
|
||||
}
|
||||
const rtc::Network* Port::Network() const {
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/candidate.h"
|
||||
@ -185,14 +186,14 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> {
|
||||
// 30 seconds.
|
||||
enum class State { INIT, KEEP_ALIVE_UNTIL_PRUNED, PRUNED };
|
||||
Port(webrtc::TaskQueueBase* thread,
|
||||
absl::string_view type,
|
||||
absl::string_view type ABSL_ATTRIBUTE_LIFETIME_BOUND,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
const rtc::Network* network,
|
||||
absl::string_view username_fragment,
|
||||
absl::string_view password,
|
||||
const webrtc::FieldTrialsView* field_trials = nullptr);
|
||||
Port(webrtc::TaskQueueBase* thread,
|
||||
absl::string_view type,
|
||||
absl::string_view type ABSL_ATTRIBUTE_LIFETIME_BOUND,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
@ -207,7 +208,7 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> {
|
||||
// uniquely identify subclasses. Whenever a new subclass of Port introduces a
|
||||
// conflit in the value of the 2-tuple, make sure that the implementation that
|
||||
// relies on this 2-tuple for RTTI is properly changed.
|
||||
const std::string& Type() const override;
|
||||
const absl::string_view Type() const override;
|
||||
const rtc::Network* Network() const override;
|
||||
|
||||
// Methods to set/get ICE role and tiebreaker values.
|
||||
@ -394,8 +395,6 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> {
|
||||
protected:
|
||||
virtual void UpdateNetworkCost();
|
||||
|
||||
void set_type(absl::string_view type) { type_ = std::string(type); }
|
||||
|
||||
rtc::WeakPtr<Port> NewWeakPtr() { return weak_factory_.GetWeakPtr(); }
|
||||
|
||||
void AddAddress(const rtc::SocketAddress& address,
|
||||
@ -484,7 +483,7 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> {
|
||||
|
||||
webrtc::TaskQueueBase* const thread_;
|
||||
rtc::PacketSocketFactory* const factory_;
|
||||
std::string type_;
|
||||
const absl::string_view type_;
|
||||
bool send_retransmit_count_attribute_;
|
||||
const rtc::Network* network_;
|
||||
uint16_t min_port_;
|
||||
|
||||
@ -49,7 +49,7 @@ class PortInterface {
|
||||
public:
|
||||
virtual ~PortInterface();
|
||||
|
||||
virtual const std::string& Type() const = 0;
|
||||
virtual const absl::string_view Type() const = 0;
|
||||
virtual const rtc::Network* Network() const = 0;
|
||||
|
||||
// Methods to set/get ICE role and tiebreaker values.
|
||||
|
||||
@ -158,6 +158,7 @@ bool UDPPort::AddressResolver::GetResolvedAddress(
|
||||
}
|
||||
|
||||
UDPPort::UDPPort(rtc::Thread* thread,
|
||||
absl::string_view type,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
const rtc::Network* network,
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
@ -165,13 +166,7 @@ UDPPort::UDPPort(rtc::Thread* thread,
|
||||
absl::string_view password,
|
||||
bool emit_local_for_anyaddress,
|
||||
const webrtc::FieldTrialsView* field_trials)
|
||||
: Port(thread,
|
||||
LOCAL_PORT_TYPE,
|
||||
factory,
|
||||
network,
|
||||
username,
|
||||
password,
|
||||
field_trials),
|
||||
: Port(thread, type, factory, network, username, password, field_trials),
|
||||
request_manager_(
|
||||
thread,
|
||||
[this](const void* data, size_t size, StunRequest* request) {
|
||||
@ -185,6 +180,7 @@ UDPPort::UDPPort(rtc::Thread* thread,
|
||||
emit_local_for_anyaddress_(emit_local_for_anyaddress) {}
|
||||
|
||||
UDPPort::UDPPort(rtc::Thread* thread,
|
||||
absl::string_view type,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
@ -194,7 +190,7 @@ UDPPort::UDPPort(rtc::Thread* thread,
|
||||
bool emit_local_for_anyaddress,
|
||||
const webrtc::FieldTrialsView* field_trials)
|
||||
: Port(thread,
|
||||
LOCAL_PORT_TYPE,
|
||||
type,
|
||||
factory,
|
||||
network,
|
||||
min_port,
|
||||
@ -656,6 +652,7 @@ StunPort::StunPort(rtc::Thread* thread,
|
||||
const ServerAddresses& servers,
|
||||
const webrtc::FieldTrialsView* field_trials)
|
||||
: UDPPort(thread,
|
||||
STUN_PORT_TYPE,
|
||||
factory,
|
||||
network,
|
||||
min_port,
|
||||
@ -664,8 +661,6 @@ StunPort::StunPort(rtc::Thread* thread,
|
||||
password,
|
||||
false,
|
||||
field_trials) {
|
||||
// UDPPort will set these to local udp, updating these to STUN.
|
||||
set_type(STUN_PORT_TYPE);
|
||||
set_server_addresses(servers);
|
||||
}
|
||||
|
||||
|
||||
@ -46,8 +46,8 @@ class RTC_EXPORT UDPPort : public Port {
|
||||
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
||||
// Using `new` to access a non-public constructor.
|
||||
auto port = absl::WrapUnique(
|
||||
new UDPPort(thread, factory, network, socket, username, password,
|
||||
emit_local_for_anyaddress, field_trials));
|
||||
new UDPPort(thread, LOCAL_PORT_TYPE, factory, network, socket, username,
|
||||
password, emit_local_for_anyaddress, field_trials));
|
||||
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
||||
if (!port->Init()) {
|
||||
return nullptr;
|
||||
@ -67,9 +67,9 @@ class RTC_EXPORT UDPPort : public Port {
|
||||
absl::optional<int> stun_keepalive_interval,
|
||||
const webrtc::FieldTrialsView* field_trials = nullptr) {
|
||||
// Using `new` to access a non-public constructor.
|
||||
auto port = absl::WrapUnique(
|
||||
new UDPPort(thread, factory, network, min_port, max_port, username,
|
||||
password, emit_local_for_anyaddress, field_trials));
|
||||
auto port = absl::WrapUnique(new UDPPort(
|
||||
thread, LOCAL_PORT_TYPE, factory, network, min_port, max_port, username,
|
||||
password, emit_local_for_anyaddress, field_trials));
|
||||
port->set_stun_keepalive_delay(stun_keepalive_interval);
|
||||
if (!port->Init()) {
|
||||
return nullptr;
|
||||
@ -120,6 +120,7 @@ class RTC_EXPORT UDPPort : public Port {
|
||||
|
||||
protected:
|
||||
UDPPort(rtc::Thread* thread,
|
||||
absl::string_view type,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
const rtc::Network* network,
|
||||
uint16_t min_port,
|
||||
@ -130,6 +131,7 @@ class RTC_EXPORT UDPPort : public Port {
|
||||
const webrtc::FieldTrialsView* field_trials);
|
||||
|
||||
UDPPort(rtc::Thread* thread,
|
||||
absl::string_view type,
|
||||
rtc::PacketSocketFactory* factory,
|
||||
const rtc::Network* network,
|
||||
rtc::AsyncPacketSocket* socket,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user