diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc index dc78c58c56..3aa1d52f11 100644 --- a/p2p/base/port_unittest.cc +++ b/p2p/base/port_unittest.cc @@ -530,10 +530,10 @@ class PortTest : public testing::Test, public sigslot::has_slots<> { ProtocolType int_proto, ProtocolType ext_proto, const rtc::SocketAddress& server_addr) { - return TurnPort::CreateUnique( - &main_, socket_factory, MakeNetwork(addr), 0, 0, username_, password_, - ProtocolAddress(server_addr, int_proto), kRelayCredentials, 0, "", {}, - {}, nullptr, nullptr); + return TurnPort::Create(&main_, socket_factory, MakeNetwork(addr), 0, 0, + username_, password_, + ProtocolAddress(server_addr, int_proto), + kRelayCredentials, 0, "", {}, {}, nullptr, nullptr); } std::unique_ptr CreateGturnPort(const SocketAddress& addr, ProtocolType int_proto, diff --git a/p2p/base/turnport.h b/p2p/base/turnport.h index fe5929866e..b4eb13d77d 100644 --- a/p2p/base/turnport.h +++ b/p2p/base/turnport.h @@ -51,25 +51,7 @@ class TurnPort : public Port { // packets. }; // Create a TURN port using the shared UDP socket, |socket|. - // TODO(steveanton): Change to unique_ptr once downstream clients have - // converted. - static TurnPort* Create(rtc::Thread* thread, - rtc::PacketSocketFactory* factory, - rtc::Network* network, - rtc::AsyncPacketSocket* socket, - const std::string& username, // ice username. - const std::string& password, // ice password. - const ProtocolAddress& server_address, - const RelayCredentials& credentials, - int server_priority, - const std::string& origin, - webrtc::TurnCustomizer* customizer) { - return CreateUnique(thread, factory, network, socket, username, password, - server_address, credentials, server_priority, origin, - customizer) - .release(); - } - static std::unique_ptr CreateUnique( + static std::unique_ptr Create( rtc::Thread* thread, rtc::PacketSocketFactory* factory, rtc::Network* network, @@ -86,35 +68,27 @@ class TurnPort : public Port { thread, factory, network, socket, username, password, server_address, credentials, server_priority, origin, customizer)); } - - // Create a TURN port that will use a new socket, bound to |network| and - // using a port in the range between |min_port| and |max_port|. - // TODO(steveanton): Change to unique_ptr once downstream clients have - // converted. - static TurnPort* Create( + // TODO(steveanton): Remove once downstream clients have moved to |Create|. + static std::unique_ptr CreateUnique( rtc::Thread* thread, rtc::PacketSocketFactory* factory, rtc::Network* network, - uint16_t min_port, - uint16_t max_port, + rtc::AsyncPacketSocket* socket, const std::string& username, // ice username. const std::string& password, // ice password. const ProtocolAddress& server_address, const RelayCredentials& credentials, int server_priority, const std::string& origin, - const std::vector& tls_alpn_protocols, - const std::vector& tls_elliptic_curves, - webrtc::TurnCustomizer* customizer, - rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr) { - // Using `new` to access a non-public constructor. - return CreateUnique(thread, factory, network, min_port, max_port, username, - password, server_address, credentials, server_priority, - origin, tls_alpn_protocols, tls_elliptic_curves, - customizer, tls_cert_verifier) - .release(); + webrtc::TurnCustomizer* customizer) { + return Create(thread, factory, network, socket, username, password, + server_address, credentials, server_priority, origin, + customizer); } - static std::unique_ptr CreateUnique( + + // Create a TURN port that will use a new socket, bound to |network| and + // using a port in the range between |min_port| and |max_port|. + static std::unique_ptr Create( rtc::Thread* thread, rtc::PacketSocketFactory* factory, rtc::Network* network, @@ -137,6 +111,28 @@ class TurnPort : public Port { origin, tls_alpn_protocols, tls_elliptic_curves, customizer, tls_cert_verifier)); } + // TODO(steveanton): Remove once downstream clients have moved to |Create|. + static std::unique_ptr CreateUnique( + rtc::Thread* thread, + rtc::PacketSocketFactory* factory, + rtc::Network* network, + uint16_t min_port, + uint16_t max_port, + const std::string& username, // ice username. + const std::string& password, // ice password. + const ProtocolAddress& server_address, + const RelayCredentials& credentials, + int server_priority, + const std::string& origin, + const std::vector& tls_alpn_protocols, + const std::vector& tls_elliptic_curves, + webrtc::TurnCustomizer* customizer, + rtc::SSLCertificateVerifier* tls_cert_verifier = nullptr) { + return Create(thread, factory, network, min_port, max_port, username, + password, server_address, credentials, server_priority, + origin, tls_alpn_protocols, tls_elliptic_curves, customizer, + tls_cert_verifier); + } ~TurnPort() override; diff --git a/p2p/base/turnport_unittest.cc b/p2p/base/turnport_unittest.cc index 27657a382e..16f89e946a 100644 --- a/p2p/base/turnport_unittest.cc +++ b/p2p/base/turnport_unittest.cc @@ -270,7 +270,7 @@ class TurnPortTest : public testing::Test, const ProtocolAddress& server_address, const std::string& origin) { RelayCredentials credentials(username, password); - turn_port_ = TurnPort::CreateUnique( + turn_port_ = TurnPort::Create( &main_, &socket_factory_, network, 0, 0, kIceUfrag1, kIcePwd1, server_address, credentials, 0, origin, {}, {}, turn_customizer_.get()); // This TURN port will be the controlling. @@ -300,10 +300,10 @@ class TurnPortTest : public testing::Test, } RelayCredentials credentials(username, password); - turn_port_ = TurnPort::CreateUnique(&main_, &socket_factory_, - MakeNetwork(kLocalAddr1), socket_.get(), - kIceUfrag1, kIcePwd1, server_address, - credentials, 0, std::string(), nullptr); + turn_port_ = + TurnPort::Create(&main_, &socket_factory_, MakeNetwork(kLocalAddr1), + socket_.get(), kIceUfrag1, kIcePwd1, server_address, + credentials, 0, std::string(), nullptr); // This TURN port will be the controlling. turn_port_->SetIceRole(ICEROLE_CONTROLLING); ConnectSignals();