Don't create PacketSocketFactory inside BasicPortAllocatorSession

This extends AlwaysValidPointer to avoid creating a unique_ptr inside it.

Bug: webrtc:13145
Change-Id: I73a4f18d0a7037b57f575b04b134e4f7eadceb79
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/263240
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Commit-Queue: Daniel.L (Byoungchan) Lee <daniel.l@hpcnt.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37048}
This commit is contained in:
Byoungchan Lee
2022-05-30 23:59:55 +09:00
committed by WebRTC LUCI CQ
parent ad924e5578
commit 7d4634cef7
14 changed files with 284 additions and 63 deletions

View File

@ -161,8 +161,10 @@ class BasicPortAllocatorTestBase : public ::testing::Test,
ServerAddresses stun_servers;
stun_servers.insert(kStunAddr);
allocator_ =
std::make_unique<BasicPortAllocator>(&network_manager_, stun_servers);
allocator_ = std::make_unique<BasicPortAllocator>(
&network_manager_,
std::make_unique<rtc::BasicPacketSocketFactory>(fss_.get()),
stun_servers);
allocator_->Initialize();
allocator_->set_step_delay(kMinimumStepDelay);
webrtc::metrics::Reset();
@ -199,7 +201,9 @@ class BasicPortAllocatorTestBase : public ::testing::Test,
}
// Endpoint is on the public network. No STUN or TURN.
void ResetWithNoServersOrNat() {
allocator_.reset(new BasicPortAllocator(&network_manager_));
allocator_.reset(new BasicPortAllocator(
&network_manager_,
std::make_unique<rtc::BasicPacketSocketFactory>(fss_.get())));
allocator_->Initialize();
allocator_->set_step_delay(kMinimumStepDelay);
}
@ -578,7 +582,9 @@ class BasicPortAllocatorTest : public FakeClockBase,
// Add two IP addresses on the same interface.
AddInterface(kClientAddr, "net1");
AddInterface(kClientIPv6Addr, "net1");
allocator_.reset(new BasicPortAllocator(&network_manager_));
allocator_.reset(new BasicPortAllocator(
&network_manager_,
std::make_unique<rtc::BasicPacketSocketFactory>(fss_.get())));
allocator_->Initialize();
allocator_->SetConfiguration(allocator_->stun_servers(),
allocator_->turn_servers(), 0,
@ -619,7 +625,9 @@ class BasicPortAllocatorTest : public FakeClockBase,
bool tcp_pruned) {
turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP);
AddInterface(kClientAddr);
allocator_.reset(new BasicPortAllocator(&network_manager_));
allocator_.reset(new BasicPortAllocator(
&network_manager_,
std::make_unique<rtc::BasicPacketSocketFactory>(fss_.get())));
allocator_->Initialize();
allocator_->SetConfiguration(allocator_->stun_servers(),
allocator_->turn_servers(), 0, prune_policy);
@ -671,7 +679,9 @@ class BasicPortAllocatorTest : public FakeClockBase,
AddInterface(kClientIPv6Addr, "net1", rtc::ADAPTER_TYPE_WIFI);
AddInterface(kClientAddr2, "net2", rtc::ADAPTER_TYPE_CELLULAR);
AddInterface(kClientIPv6Addr2, "net2", rtc::ADAPTER_TYPE_CELLULAR);
allocator_.reset(new BasicPortAllocator(&network_manager_));
allocator_.reset(new BasicPortAllocator(
&network_manager_,
std::make_unique<rtc::BasicPacketSocketFactory>(fss_.get())));
allocator_->Initialize();
allocator_->SetConfiguration(allocator_->stun_servers(),
allocator_->turn_servers(), 0,
@ -1637,7 +1647,9 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNat) {
TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) {
turn_server_.AddInternalSocket(kTurnTcpIntAddr, PROTO_TCP);
AddInterface(kClientAddr);
allocator_.reset(new BasicPortAllocator(&network_manager_));
allocator_.reset(new BasicPortAllocator(
&network_manager_,
std::make_unique<rtc::BasicPacketSocketFactory>(fss_.get())));
allocator_->Initialize();
AddTurnServers(kTurnUdpIntAddr, kTurnTcpIntAddr);
@ -1772,7 +1784,9 @@ TEST_F(BasicPortAllocatorTestWithRealClock,
turn_server_.AddInternalSocket(rtc::SocketAddress("127.0.0.1", 3478),
PROTO_UDP);
AddInterface(kClientAddr);
allocator_.reset(new BasicPortAllocator(&network_manager_));
allocator_.reset(new BasicPortAllocator(
&network_manager_,
std::make_unique<rtc::BasicPacketSocketFactory>(fss_.get())));
allocator_->Initialize();
RelayServerConfig turn_server;
RelayCredentials credentials(kTurnUsername, kTurnPassword);