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.h | |
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.h')
-rw-r--r-- | third_party/libwebrtc/p2p/base/test_stun_server.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/third_party/libwebrtc/p2p/base/test_stun_server.h b/third_party/libwebrtc/p2p/base/test_stun_server.h index 11ac620bb8..7bf7dc1dba 100644 --- a/third_party/libwebrtc/p2p/base/test_stun_server.h +++ b/third_party/libwebrtc/p2p/base/test_stun_server.h @@ -11,19 +11,25 @@ #ifndef P2P_BASE_TEST_STUN_SERVER_H_ #define P2P_BASE_TEST_STUN_SERVER_H_ +#include <memory> + #include "api/transport/stun.h" #include "p2p/base/stun_server.h" #include "rtc_base/async_udp_socket.h" #include "rtc_base/socket_address.h" #include "rtc_base/socket_server.h" +#include "rtc_base/thread.h" namespace cricket { // A test STUN server. Useful for unit tests. class TestStunServer : StunServer { public: - static TestStunServer* Create(rtc::SocketServer* ss, - const rtc::SocketAddress& addr); + using StunServerPtr = + std::unique_ptr<TestStunServer, std::function<void(TestStunServer*)>>; + static StunServerPtr Create(rtc::SocketServer* ss, + const rtc::SocketAddress& addr, + rtc::Thread& network_thread); // Set a fake STUN address to return to the client. void set_fake_stun_addr(const rtc::SocketAddress& addr) { @@ -31,13 +37,17 @@ class TestStunServer : StunServer { } private: - explicit TestStunServer(rtc::AsyncUDPSocket* socket) : StunServer(socket) {} + static void DeleteOnNetworkThread(TestStunServer* server); + + TestStunServer(rtc::AsyncUDPSocket* socket, rtc::Thread& network_thread) + : StunServer(socket), network_thread_(network_thread) {} void OnBindingRequest(StunMessage* msg, const rtc::SocketAddress& remote_addr) override; private: rtc::SocketAddress fake_stun_addr_; + rtc::Thread& network_thread_; }; } // namespace cricket |