diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/libwebrtc/p2p/base/test_stun_server.cc | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/p2p/base/test_stun_server.cc')
-rw-r--r-- | third_party/libwebrtc/p2p/base/test_stun_server.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/third_party/libwebrtc/p2p/base/test_stun_server.cc b/third_party/libwebrtc/p2p/base/test_stun_server.cc index d4c3b2d851..a8a5c46f8c 100644 --- a/third_party/libwebrtc/p2p/base/test_stun_server.cc +++ b/third_party/libwebrtc/p2p/base/test_stun_server.cc @@ -10,21 +10,32 @@ #include "p2p/base/test_stun_server.h" +#include <memory> + #include "rtc_base/socket.h" #include "rtc_base/socket_server.h" namespace cricket { -TestStunServer* TestStunServer::Create(rtc::SocketServer* ss, - const rtc::SocketAddress& addr) { +std::unique_ptr<TestStunServer, std::function<void(TestStunServer*)>> +TestStunServer::Create(rtc::SocketServer* ss, + const rtc::SocketAddress& addr, + rtc::Thread& network_thread) { rtc::Socket* socket = ss->CreateSocket(addr.family(), SOCK_DGRAM); rtc::AsyncUDPSocket* udp_socket = rtc::AsyncUDPSocket::Create(socket, addr); - - return new TestStunServer(udp_socket); + TestStunServer* server = nullptr; + network_thread.BlockingCall( + [&]() { server = new TestStunServer(udp_socket, network_thread); }); + std::unique_ptr<TestStunServer, std::function<void(TestStunServer*)>> result( + server, [&](TestStunServer* server) { + network_thread.BlockingCall([server]() { delete server; }); + }); + return result; } void TestStunServer::OnBindingRequest(StunMessage* msg, const rtc::SocketAddress& remote_addr) { + RTC_DCHECK_RUN_ON(&network_thread_); if (fake_stun_addr_.IsNil()) { StunServer::OnBindingRequest(msg, remote_addr); } else { |